diff --git a/Makefile b/Makefile
index abf99945a8..2b553299f6 100644
--- a/Makefile
+++ b/Makefile
@@ -109,6 +109,7 @@ test: all
build/env.sh go test ./...
travis-test-with-coverage: all
+ build/env.sh go vet ./...
build/env.sh build/test-global-coverage.sh
xgo:
diff --git a/accounts/abi/numbers_test.go b/accounts/abi/numbers_test.go
index 6590e41a6f..d66a43258b 100644
--- a/accounts/abi/numbers_test.go
+++ b/accounts/abi/numbers_test.go
@@ -30,17 +30,17 @@ func TestNumberTypes(t *testing.T) {
unsigned := U256(big.NewInt(1))
if !bytes.Equal(unsigned, ubytes) {
- t.Error("expected %x got %x", ubytes, unsigned)
+ t.Errorf("expected %x got %x", ubytes, unsigned)
}
signed := S256(big.NewInt(1))
if !bytes.Equal(signed, ubytes) {
- t.Error("expected %x got %x", ubytes, unsigned)
+ t.Errorf("expected %x got %x", ubytes, unsigned)
}
signed = S256(big.NewInt(-1))
if !bytes.Equal(signed, sbytesmin) {
- t.Error("expected %x got %x", ubytes, unsigned)
+ t.Errorf("expected %x got %x", ubytes, unsigned)
}
}
@@ -75,10 +75,10 @@ func TestPackNumber(t *testing.T) {
func TestSigned(t *testing.T) {
if isSigned(reflect.ValueOf(uint(10))) {
- t.Error()
+ t.Error("signed")
}
if !isSigned(reflect.ValueOf(int(10))) {
- t.Error()
+ t.Error("not signed")
}
}
diff --git a/cmd/bootnode/main.go b/cmd/bootnode/main.go
index 0cad5321b9..7f74e9c706 100644
--- a/cmd/bootnode/main.go
+++ b/cmd/bootnode/main.go
@@ -79,7 +79,7 @@ func main() {
func writeKey(target string) {
key, err := crypto.GenerateKey()
if err != nil {
- log.Fatal("could not generate key: %v", err)
+ log.Fatalf("could not generate key: %v", err)
}
b := crypto.FromECDSA(key)
if target == "-" {
diff --git a/cmd/ethtest/main.go b/cmd/ethtest/main.go
index 3916e297f9..d8f9696360 100644
--- a/cmd/ethtest/main.go
+++ b/cmd/ethtest/main.go
@@ -76,7 +76,8 @@ func runTestWithReader(test string, r io.Reader) error {
case "bk", "block", "blocktest", "blockchaintest", "blocktests", "blockchaintests":
err = tests.RunBlockTestWithReader(params.MainNetHomesteadBlock, r, skipTests)
case "st", "state", "statetest", "statetests":
- err = tests.RunStateTestWithReader(tests.RuleSet{params.MainNetHomesteadBlock}, r, skipTests)
+ rs := tests.RuleSet{HomesteadBlock: params.MainNetHomesteadBlock}
+ err = tests.RunStateTestWithReader(rs, r, skipTests)
case "tx", "transactiontest", "transactiontests":
err = tests.RunTransactionTestsWithReader(r, skipTests)
case "vm", "vmtest", "vmtests":
diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go
index baf5723598..ddfe0d4000 100644
--- a/cmd/geth/js_test.go
+++ b/cmd/geth/js_test.go
@@ -89,7 +89,10 @@ func testREPL(t *testing.T, config func(*eth.Config)) (string, *testjethre, *nod
// Initialize and register the Ethereum protocol
accman := accounts.NewPlaintextManager(filepath.Join(tmp, "keystore"))
db, _ := ethdb.NewMemDatabase()
- core.WriteGenesisBlockForTesting(db, core.GenesisAccount{common.HexToAddress(testAddress), common.String2Big(testBalance)})
+ core.WriteGenesisBlockForTesting(db, core.GenesisAccount{
+ Address: common.HexToAddress(testAddress),
+ Balance: common.String2Big(testBalance),
+ })
ethConf := ð.Config{
ChainConfig: &core.ChainConfig{HomesteadBlock: new(big.Int)},
TestGenesisState: db,
diff --git a/cmd/utils/jeth.go b/cmd/utils/jeth.go
index 0017790f3b..9410180b01 100644
--- a/cmd/utils/jeth.go
+++ b/cmd/utils/jeth.go
@@ -131,13 +131,11 @@ func (self *Jeth) NewAccount(call otto.FunctionCall) (response otto.Value) {
return otto.FalseValue()
}
- if ret, err := call.Otto.Call("jeth.newAccount", nil, passwd); err == nil {
+ ret, err := call.Otto.Call("jeth.newAccount", nil, passwd)
+ if err == nil {
return ret
- } else {
- fmt.Printf("%v\n", err)
- return otto.FalseValue()
}
-
+ fmt.Println(err)
return otto.FalseValue()
}
@@ -233,7 +231,6 @@ func (self *Jeth) Send(call otto.FunctionCall) (response otto.Value) {
func throwJSExeception(msg interface{}) otto.Value {
p, _ := otto.ToValue(msg)
panic(p)
- return p
}
// Sleep will halt the console for arg[0] seconds.
diff --git a/common/compiler/solidity_test.go b/common/compiler/solidity_test.go
index 258a78f52a..7109b1ec4b 100644
--- a/common/compiler/solidity_test.go
+++ b/common/compiler/solidity_test.go
@@ -57,7 +57,7 @@ func TestCompiler(t *testing.T) {
}
if len(contracts) != 1 {
- t.Errorf("one contract expected, got\n%s", len(contracts))
+ t.Errorf("one contract expected, got %d", len(contracts))
}
if contracts["test"].Code != code {
diff --git a/common/math/dist_test.go b/common/math/dist_test.go
index 1eacfbcaf2..826faea8b3 100644
--- a/common/math/dist_test.go
+++ b/common/math/dist_test.go
@@ -35,7 +35,7 @@ func TestSum(t *testing.T) {
summer := summer{numbers: []*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)}}
sum := Sum(summer)
if sum.Cmp(big.NewInt(6)) != 0 {
- t.Errorf("not 6", sum)
+ t.Errorf("got sum = %d, want 6", sum)
}
}
diff --git a/common/path.go b/common/path.go
index 75a8c1a3e0..cbcd13c4fe 100644
--- a/common/path.go
+++ b/common/path.go
@@ -34,7 +34,7 @@ func MakeName(name, version string) string {
func ExpandHomePath(p string) (path string) {
path = p
- sep := fmt.Sprintf("%s", os.PathSeparator)
+ sep := string(os.PathSeparator)
// Check in case of paths like "/something/~/something/"
if len(p) > 1 && p[:1+len(sep)] == "~"+sep {
diff --git a/core/asm.go b/core/asm.go
index a86a2c44c3..b2e47b5e91 100644
--- a/core/asm.go
+++ b/core/asm.go
@@ -61,6 +61,4 @@ func Disassemble(script []byte) (asm []string) {
pc.Add(pc, common.Big1)
}
-
- return asm
}
diff --git a/core/blockchain.go b/core/blockchain.go
index 177a3bbcea..ecf8297cbf 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -678,7 +678,7 @@ func (self *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain
}
}
// Write all the data out into the database
- if err := WriteBody(self.chainDb, block.Hash(), &types.Body{block.Transactions(), block.Uncles()}); err != nil {
+ if err := WriteBody(self.chainDb, block.Hash(), block.Body()); err != nil {
errs[index] = fmt.Errorf("failed to write block body: %v", err)
atomic.AddInt32(&failed, 1)
glog.Fatal(errs[index])
@@ -993,7 +993,7 @@ func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
// first reduce whoever is higher bound
if oldBlock.NumberU64() > newBlock.NumberU64() {
// reduce old chain
- for oldBlock = oldBlock; oldBlock != nil && oldBlock.NumberU64() != newBlock.NumberU64(); oldBlock = self.GetBlock(oldBlock.ParentHash()) {
+ for ; oldBlock != nil && oldBlock.NumberU64() != newBlock.NumberU64(); oldBlock = self.GetBlock(oldBlock.ParentHash()) {
oldChain = append(oldChain, oldBlock)
deletedTxs = append(deletedTxs, oldBlock.Transactions()...)
@@ -1001,7 +1001,7 @@ func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
}
} else {
// reduce new chain and append new chain blocks for inserting later on
- for newBlock = newBlock; newBlock != nil && newBlock.NumberU64() != oldBlock.NumberU64(); newBlock = self.GetBlock(newBlock.ParentHash()) {
+ for ; newBlock != nil && newBlock.NumberU64() != oldBlock.NumberU64(); newBlock = self.GetBlock(newBlock.ParentHash()) {
newChain = append(newChain, newBlock)
}
}
diff --git a/core/database_util.go b/core/database_util.go
index e1e8136d1f..3ba80062c1 100644
--- a/core/database_util.go
+++ b/core/database_util.go
@@ -318,7 +318,7 @@ func WriteTd(db ethdb.Database, hash common.Hash, td *big.Int) error {
// WriteBlock serializes a block into the database, header and body separately.
func WriteBlock(db ethdb.Database, block *types.Block) error {
// Store the body first to retain database consistency
- if err := WriteBody(db, block.Hash(), &types.Body{block.Transactions(), block.Uncles()}); err != nil {
+ if err := WriteBody(db, block.Hash(), block.Body()); err != nil {
return err
}
// Store the header too, signaling full block ownership
diff --git a/core/database_util_test.go b/core/database_util_test.go
index ce1ffea8ae..9ef7876241 100644
--- a/core/database_util_test.go
+++ b/core/database_util_test.go
@@ -196,7 +196,7 @@ func TestBlockStorage(t *testing.T) {
if entry := GetBody(db, block.Hash()); entry == nil {
t.Fatalf("Stored body not found")
} else if types.DeriveSha(types.Transactions(entry.Transactions)) != types.DeriveSha(block.Transactions()) || types.CalcUncleHash(entry.Uncles) != types.CalcUncleHash(block.Uncles()) {
- t.Fatalf("Retrieved body mismatch: have %v, want %v", entry, &types.Body{block.Transactions(), block.Uncles()})
+ t.Fatalf("Retrieved body mismatch: have %v, want %v", entry, block.Body())
}
// Delete the block and verify the execution
DeleteBlock(db, block.Hash())
@@ -230,7 +230,7 @@ func TestPartialBlockStorage(t *testing.T) {
DeleteHeader(db, block.Hash())
// Store a body and check that it's not recognized as a block
- if err := WriteBody(db, block.Hash(), &types.Body{block.Transactions(), block.Uncles()}); err != nil {
+ if err := WriteBody(db, block.Hash(), block.Body()); err != nil {
t.Fatalf("Failed to write body into database: %v", err)
}
if entry := GetBlock(db, block.Hash()); entry != nil {
@@ -242,7 +242,7 @@ func TestPartialBlockStorage(t *testing.T) {
if err := WriteHeader(db, block.Header()); err != nil {
t.Fatalf("Failed to write header into database: %v", err)
}
- if err := WriteBody(db, block.Hash(), &types.Body{block.Transactions(), block.Uncles()}); err != nil {
+ if err := WriteBody(db, block.Hash(), block.Body()); err != nil {
t.Fatalf("Failed to write body into database: %v", err)
}
if entry := GetBlock(db, block.Hash()); entry == nil {
diff --git a/core/state/dump.go b/core/state/dump.go
index 8eb03e8e44..a328b05374 100644
--- a/core/state/dump.go
+++ b/core/state/dump.go
@@ -46,11 +46,19 @@ func (self *StateDB) RawDump() World {
it := self.trie.Iterator()
for it.Next() {
addr := self.trie.GetKey(it.Key)
- stateObject, _ := DecodeObject(common.BytesToAddress(addr), self.db, it.Value)
-
- account := Account{Balance: stateObject.balance.String(), Nonce: stateObject.nonce, Root: common.Bytes2Hex(stateObject.Root()), CodeHash: common.Bytes2Hex(stateObject.codeHash), Code: common.Bytes2Hex(stateObject.Code())}
- account.Storage = make(map[string]string)
+ stateObject, err := DecodeObject(common.BytesToAddress(addr), self.db, it.Value)
+ if err != nil {
+ panic(err)
+ }
+ account := Account{
+ Balance: stateObject.balance.String(),
+ Nonce: stateObject.nonce,
+ Root: common.Bytes2Hex(stateObject.Root()),
+ CodeHash: common.Bytes2Hex(stateObject.codeHash),
+ Code: common.Bytes2Hex(stateObject.Code()),
+ Storage: make(map[string]string),
+ }
storageIt := stateObject.trie.Iterator()
for storageIt.Next() {
account.Storage[common.Bytes2Hex(self.trie.GetKey(storageIt.Key))] = common.Bytes2Hex(storageIt.Value)
diff --git a/core/state/state_object.go b/core/state/state_object.go
index 3267081189..769c63d42d 100644
--- a/core/state/state_object.go
+++ b/core/state/state_object.go
@@ -287,7 +287,7 @@ func DecodeObject(address common.Address, db trie.Database, data []byte) (*State
}
if !bytes.Equal(ext.CodeHash, emptyCodeHash) {
if obj.code, err = db.Get(ext.CodeHash); err != nil {
- return nil, fmt.Errorf("can't find code for hash %x: %v", ext.CodeHash, err)
+ return nil, fmt.Errorf("can't get code for hash %x: %v", ext.CodeHash, err)
}
}
obj.nonce = ext.Nonce
diff --git a/core/state/state_test.go b/core/state/state_test.go
index a45eddd0d6..ce86a5b768 100644
--- a/core/state/state_test.go
+++ b/core/state/state_test.go
@@ -36,7 +36,6 @@ var _ = checker.Suite(&StateSuite{})
var toAddr = common.BytesToAddress
func (s *StateSuite) TestDump(c *checker.C) {
- return
// generate a few entries
obj1 := s.state.GetOrNewStateObject(toAddr([]byte{0x01}))
obj1.AddBalance(big.NewInt(22))
@@ -48,24 +47,35 @@ func (s *StateSuite) TestDump(c *checker.C) {
// write some of them to the trie
s.state.UpdateStateObject(obj1)
s.state.UpdateStateObject(obj2)
+ s.state.Commit()
// check that dump contains the state objects that are in trie
got := string(s.state.Dump())
want := `{
- "root": "6e277ae8357d013e50f74eedb66a991f6922f93ae03714de58b3d0c5e9eee53f",
+ "root": "71edff0130dd2385947095001c73d9e28d862fc286fca2b922ca6f6f3cddfdd2",
"accounts": {
- "1468288056310c82aa4c01a7e12a10f8111a0560e72b700555479031b86c357d": {
+ "0000000000000000000000000000000000000001": {
"balance": "22",
"nonce": 0,
"root": "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"codeHash": "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
+ "code": "",
"storage": {}
},
- "a17eacbc25cda025e81db9c5c62868822c73ce097cee2a63e33a2e41268358a1": {
+ "0000000000000000000000000000000000000002": {
+ "balance": "44",
+ "nonce": 0,
+ "root": "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
+ "codeHash": "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
+ "code": "",
+ "storage": {}
+ },
+ "0000000000000000000000000000000000000102": {
"balance": "0",
"nonce": 0,
"root": "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"codeHash": "87874902497a5bb968da31a2998d8f22e949d1ef6214bcdedd8bae24cca4b9e3",
+ "code": "03030303030303",
"storage": {}
}
}
diff --git a/core/state/sync_test.go b/core/state/sync_test.go
index a2a1edbdb1..715645c6c9 100644
--- a/core/state/sync_test.go
+++ b/core/state/sync_test.go
@@ -145,7 +145,7 @@ func testIterativeStateSync(t *testing.T, batch int) {
if err != nil {
t.Fatalf("failed to retrieve node data for %x: %v", hash, err)
}
- results[i] = trie.SyncResult{hash, data}
+ results[i] = trie.SyncResult{Hash: hash, Data: data}
}
if index, err := sched.Process(results); err != nil {
t.Fatalf("failed to process result #%d: %v", index, err)
@@ -175,7 +175,7 @@ func TestIterativeDelayedStateSync(t *testing.T) {
if err != nil {
t.Fatalf("failed to retrieve node data for %x: %v", hash, err)
}
- results[i] = trie.SyncResult{hash, data}
+ results[i] = trie.SyncResult{Hash: hash, Data: data}
}
if index, err := sched.Process(results); err != nil {
t.Fatalf("failed to process result #%d: %v", index, err)
@@ -212,7 +212,7 @@ func testIterativeRandomStateSync(t *testing.T, batch int) {
if err != nil {
t.Fatalf("failed to retrieve node data for %x: %v", hash, err)
}
- results = append(results, trie.SyncResult{hash, data})
+ results = append(results, trie.SyncResult{Hash: hash, Data: data})
}
// Feed the retrieved results back and queue new tasks
if index, err := sched.Process(results); err != nil {
@@ -251,7 +251,7 @@ func TestIterativeRandomDelayedStateSync(t *testing.T) {
if err != nil {
t.Fatalf("failed to retrieve node data for %x: %v", hash, err)
}
- results = append(results, trie.SyncResult{hash, data})
+ results = append(results, trie.SyncResult{Hash: hash, Data: data})
if len(results) >= cap(results) {
break
@@ -289,7 +289,7 @@ func TestIncompleteStateSync(t *testing.T) {
if err != nil {
t.Fatalf("failed to retrieve node data for %x: %v", hash, err)
}
- results[i] = trie.SyncResult{hash, data}
+ results[i] = trie.SyncResult{Hash: hash, Data: data}
}
// Process each of the state nodes
if index, err := sched.Process(results); err != nil {
diff --git a/core/types/block.go b/core/types/block.go
index 5e6a9019d6..387a063aeb 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -330,6 +330,9 @@ func (b *Block) Extra() []byte { return common.CopyBytes(b.header.Ext
func (b *Block) Header() *Header { return CopyHeader(b.header) }
+// Body returns the non-header content of the block.
+func (b *Block) Body() *Body { return &Body{b.transactions, b.uncles} }
+
func (b *Block) HashNoNonce() common.Hash {
return b.header.HashNoNonce()
}
diff --git a/core/vm/asm.go b/core/vm/asm.go
index b248838a78..d7dbde5e82 100644
--- a/core/vm/asm.go
+++ b/core/vm/asm.go
@@ -58,6 +58,4 @@ func Disassemble(script []byte) (asm []string) {
pc.Add(pc, common.Big1)
}
-
- return
}
diff --git a/core/vm/jit_util_test.go b/core/vm/jit_util_test.go
index 1f4cb2b165..2123efe59e 100644
--- a/core/vm/jit_util_test.go
+++ b/core/vm/jit_util_test.go
@@ -77,7 +77,7 @@ func TestParser(t *testing.T) {
t.Fatal("empty output")
}
if output[0] != test.output {
- t.Error("%v failed: expected %v but got %v", test.base+OpCode(i), output[0])
+ t.Errorf("%v failed: expected %v but got %v", test.base+OpCode(i), test.output, output[0])
}
}
}
diff --git a/crypto/crypto.go b/crypto/crypto.go
index b24d080109..85f0970956 100644
--- a/crypto/crypto.go
+++ b/crypto/crypto.go
@@ -107,7 +107,7 @@ func ToECDSAPub(pub []byte) *ecdsa.PublicKey {
return nil
}
x, y := elliptic.Unmarshal(secp256k1.S256(), pub)
- return &ecdsa.PublicKey{secp256k1.S256(), x, y}
+ return &ecdsa.PublicKey{Curve: secp256k1.S256(), X: x, Y: y}
}
func FromECDSAPub(pub *ecdsa.PublicKey) []byte {
@@ -189,7 +189,7 @@ func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error) {
}
x, y := elliptic.Unmarshal(secp256k1.S256(), s)
- return &ecdsa.PublicKey{secp256k1.S256(), x, y}, nil
+ return &ecdsa.PublicKey{Curve: secp256k1.S256(), X: x, Y: y}, nil
}
func Sign(hash []byte, prv *ecdsa.PrivateKey) (sig []byte, err error) {
diff --git a/crypto/ecies/ecies.go b/crypto/ecies/ecies.go
index ee42856173..86a70261d2 100644
--- a/crypto/ecies/ecies.go
+++ b/crypto/ecies/ecies.go
@@ -60,7 +60,7 @@ type PublicKey struct {
// Export an ECIES public key as an ECDSA public key.
func (pub *PublicKey) ExportECDSA() *ecdsa.PublicKey {
- return &ecdsa.PublicKey{pub.Curve, pub.X, pub.Y}
+ return &ecdsa.PublicKey{Curve: pub.Curve, X: pub.X, Y: pub.Y}
}
// Import an ECDSA public key as an ECIES public key.
@@ -83,7 +83,7 @@ type PrivateKey struct {
func (prv *PrivateKey) ExportECDSA() *ecdsa.PrivateKey {
pub := &prv.PublicKey
pubECDSA := pub.ExportECDSA()
- return &ecdsa.PrivateKey{*pubECDSA, prv.D}
+ return &ecdsa.PrivateKey{PublicKey: *pubECDSA, D: prv.D}
}
// Import an ECDSA private key as an ECIES private key.
diff --git a/eth/backend.go b/eth/backend.go
index ea12e42153..76cf8783b9 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -557,7 +557,7 @@ func upgradeChainDatabase(db ethdb.Database) error {
if err := core.WriteTd(db, block.Hash(), block.DeprecatedTd()); err != nil {
return err
}
- if err := core.WriteBody(db, block.Hash(), &types.Body{block.Transactions(), block.Uncles()}); err != nil {
+ if err := core.WriteBody(db, block.Hash(), block.Body()); err != nil {
return err
}
if err := core.WriteHeader(db, block.Header()); err != nil {
@@ -573,7 +573,7 @@ func upgradeChainDatabase(db ethdb.Database) error {
if err := core.WriteTd(db, current.Hash(), current.DeprecatedTd()); err != nil {
return err
}
- if err := core.WriteBody(db, current.Hash(), &types.Body{current.Transactions(), current.Uncles()}); err != nil {
+ if err := core.WriteBody(db, current.Hash(), current.Body()); err != nil {
return err
}
if err := core.WriteHeader(db, current.Header()); err != nil {
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index f50a71cf1f..801181712f 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -892,8 +892,7 @@ func (d *Downloader) fetchBlocks61(from uint64) error {
// case, the internal state of the downloader and the queue is very wrong so
// better hard crash and note the error instead of silently accumulating into
// a much bigger issue.
- panic(fmt.Sprintf("%v: fetch assignment failed, hard panic", peer))
- d.queue.CancelBlocks(request) // noop for now
+ panic(fmt.Sprintf("%v: fetch assignment failed", peer))
}
}
// Make sure that we have peers available for fetching. If all peers have been tried
@@ -1525,8 +1524,7 @@ func (d *Downloader) fetchParts(errCancel error, deliveryCh chan dataPack, deliv
// case, the internal state of the downloader and the queue is very wrong so
// better hard crash and note the error instead of silently accumulating into
// a much bigger issue.
- panic(fmt.Sprintf("%v: %s fetch assignment failed, hard panic", peer, strings.ToLower(kind)))
- cancel(request) // noop for now
+ panic(fmt.Sprintf("%v: %s fetch assignment failed", peer, strings.ToLower(kind)))
}
running = true
}
diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go
index f86bae1442..d8d1bddcee 100644
--- a/eth/downloader/queue.go
+++ b/eth/downloader/queue.go
@@ -983,7 +983,7 @@ func (q *queue) DeliverNodeData(id string, data [][]byte, callback func(error, i
continue
}
// Inject the next state trie item into the processing queue
- process = append(process, trie.SyncResult{hash, blob})
+ process = append(process, trie.SyncResult{Hash: hash, Data: blob})
accepted++
delete(request.Hashes, hash)
diff --git a/eth/filters/api.go b/eth/filters/api.go
index 54336aaf9b..9e95ebd83f 100644
--- a/eth/filters/api.go
+++ b/eth/filters/api.go
@@ -331,7 +331,7 @@ func (args *NewFilterArgs) UnmarshalJSON(data []byte) error {
if decAddr, err := hex.DecodeString(strAddr); err == nil {
addresses = append(addresses, common.BytesToAddress(decAddr))
} else {
- fmt.Errorf("invalid address given")
+ return fmt.Errorf("invalid address given")
}
} else {
return fmt.Errorf("invalid address on index %d", i)
@@ -344,10 +344,10 @@ func (args *NewFilterArgs) UnmarshalJSON(data []byte) error {
if decAddr, err := hex.DecodeString(singleAddr); err == nil {
addresses = append(addresses, common.BytesToAddress(decAddr))
} else {
- fmt.Errorf("invalid address given")
+ return fmt.Errorf("invalid address given")
}
} else {
- errors.New("invalid address(es) given")
+ return errors.New("invalid address(es) given")
}
args.Addresses = addresses
}
@@ -394,7 +394,7 @@ func (args *NewFilterArgs) UnmarshalJSON(data []byte) error {
parsedTopics[i] = []common.Hash{t}
}
} else {
- fmt.Errorf("topic[%d][%d] not a string", i, j)
+ return fmt.Errorf("topic[%d][%d] not a string", i, j)
}
}
} else {
diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go
index 7757fb84e5..72824cb088 100644
--- a/eth/filters/filter_system_test.go
+++ b/eth/filters/filter_system_test.go
@@ -76,8 +76,8 @@ func TestCallbacks(t *testing.T) {
mux.Post(core.ChainEvent{})
mux.Post(core.TxPreEvent{})
mux.Post(vm.Logs{&vm.Log{}})
- mux.Post(core.RemovedLogsEvent{vm.Logs{&vm.Log{}}})
- mux.Post(core.PendingLogsEvent{vm.Logs{&vm.Log{}}})
+ mux.Post(core.RemovedLogsEvent{Logs: vm.Logs{&vm.Log{}}})
+ mux.Post(core.PendingLogsEvent{Logs: vm.Logs{&vm.Log{}}})
const dura = 5 * time.Second
failTimer := time.NewTimer(dura)
diff --git a/eth/filters/filter_test.go b/eth/filters/filter_test.go
index 5954ea4c1f..b0f88ffeb5 100644
--- a/eth/filters/filter_test.go
+++ b/eth/filters/filter_test.go
@@ -56,7 +56,7 @@ func BenchmarkMipmaps(b *testing.B) {
)
defer db.Close()
- genesis := core.WriteGenesisBlockForTesting(db, core.GenesisAccount{addr1, big.NewInt(1000000)})
+ genesis := core.WriteGenesisBlockForTesting(db, core.GenesisAccount{Address: addr1, Balance: big.NewInt(1000000)})
chain, receipts := core.GenerateChain(genesis, db, 100010, func(i int, gen *core.BlockGen) {
var receipts types.Receipts
switch i {
@@ -132,7 +132,7 @@ func TestFilters(t *testing.T) {
)
defer db.Close()
- genesis := core.WriteGenesisBlockForTesting(db, core.GenesisAccount{addr, big.NewInt(1000000)})
+ genesis := core.WriteGenesisBlockForTesting(db, core.GenesisAccount{Address: addr, Balance: big.NewInt(1000000)})
chain, receipts := core.GenerateChain(genesis, db, 1000, func(i int, gen *core.BlockGen) {
var receipts types.Receipts
switch i {
diff --git a/eth/handler.go b/eth/handler.go
index 135de37496..d6b474a918 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -245,7 +245,6 @@ func (pm *ProtocolManager) handle(p *peer) error {
return err
}
}
- return nil
}
// handleMsg is invoked whenever an inbound message is received from a remote
diff --git a/eth/handler_test.go b/eth/handler_test.go
index 76748b6e35..9e593f0405 100644
--- a/eth/handler_test.go
+++ b/eth/handler_test.go
@@ -17,7 +17,6 @@
package eth
import (
- "fmt"
"math/big"
"math/rand"
"testing"
@@ -448,12 +447,12 @@ func testGetNodeData(t *testing.T, protocol int) {
switch i {
case 0:
// In block 1, the test bank sends account #1 some ether.
- tx, _ := types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(testBankKey)
+ tx, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(testBankKey)
block.AddTx(tx)
case 1:
// In block 2, the test bank sends some more ether to account #1.
// acc1Addr passes it on to account #2.
- tx1, _ := types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testBankKey)
+ tx1, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testBankKey)
tx2, _ := types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(acc1Key)
block.AddTx(tx1)
block.AddTx(tx2)
@@ -498,14 +497,14 @@ func testGetNodeData(t *testing.T, protocol int) {
// Verify that all hashes correspond to the requested data, and reconstruct a state tree
for i, want := range hashes {
if hash := crypto.Keccak256Hash(data[i]); hash != want {
- fmt.Errorf("data hash mismatch: have %x, want %x", hash, want)
+ t.Errorf("data hash mismatch: have %x, want %x", hash, want)
}
}
statedb, _ := ethdb.NewMemDatabase()
for i := 0; i < len(data); i++ {
statedb.Put(hashes[i].Bytes(), data[i])
}
- accounts := []common.Address{testBankAddress, acc1Addr, acc2Addr}
+ accounts := []common.Address{testBank.Address, acc1Addr, acc2Addr}
for i := uint64(0); i <= pm.blockchain.CurrentBlock().NumberU64(); i++ {
trie, _ := state.New(pm.blockchain.GetBlockByNumber(i).Root(), statedb)
@@ -539,12 +538,12 @@ func testGetReceipt(t *testing.T, protocol int) {
switch i {
case 0:
// In block 1, the test bank sends account #1 some ether.
- tx, _ := types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(testBankKey)
+ tx, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(testBankKey)
block.AddTx(tx)
case 1:
// In block 2, the test bank sends some more ether to account #1.
// acc1Addr passes it on to account #2.
- tx1, _ := types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testBankKey)
+ tx1, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testBankKey)
tx2, _ := types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(acc1Key)
block.AddTx(tx1)
block.AddTx(tx2)
diff --git a/eth/helper_test.go b/eth/helper_test.go
index 575211a55c..5703d44cc2 100644
--- a/eth/helper_test.go
+++ b/eth/helper_test.go
@@ -37,9 +37,11 @@ import (
)
var (
- testBankKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
- testBankAddress = crypto.PubkeyToAddress(testBankKey.PublicKey)
- testBankFunds = big.NewInt(1000000)
+ testBankKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
+ testBank = core.GenesisAccount{
+ Address: crypto.PubkeyToAddress(testBankKey.PublicKey),
+ Balance: big.NewInt(1000000),
+ }
)
// newTestProtocolManager creates a new protocol manager for testing purposes,
@@ -50,7 +52,7 @@ func newTestProtocolManager(fastSync bool, blocks int, generator func(int, *core
evmux = new(event.TypeMux)
pow = new(core.FakePow)
db, _ = ethdb.NewMemDatabase()
- genesis = core.WriteGenesisBlockForTesting(db, core.GenesisAccount{testBankAddress, testBankFunds})
+ genesis = core.WriteGenesisBlockForTesting(db, testBank)
chainConfig = &core.ChainConfig{HomesteadBlock: big.NewInt(0)} // homestead set to 0 because of chain maker
blockchain, _ = core.NewBlockChain(db, chainConfig, pow, evmux)
)
diff --git a/eth/protocol_test.go b/eth/protocol_test.go
index cac3657e7a..0a82e2e795 100644
--- a/eth/protocol_test.go
+++ b/eth/protocol_test.go
@@ -78,7 +78,7 @@ func testStatusMsgErrors(t *testing.T, protocol int) {
select {
case err := <-errc:
if err == nil {
- t.Errorf("test %d: protocol returned nil error, want %q", test.wantError)
+ t.Errorf("test %d: protocol returned nil error, want %q", i, test.wantError)
} else if err.Error() != test.wantError.Error() {
t.Errorf("test %d: wrong error: got %q, want %q", i, err, test.wantError)
}
diff --git a/generators/defaults.go b/generators/defaults.go
index aec4fe8450..107e13e67c 100644
--- a/generators/defaults.go
+++ b/generators/defaults.go
@@ -28,7 +28,7 @@ import (
"strings"
)
-func fatal(str string, v ...interface{}) {
+func fatalf(str string, v ...interface{}) {
fmt.Fprintf(os.Stderr, str, v...)
os.Exit(1)
}
@@ -40,12 +40,12 @@ type setting struct {
func main() {
if len(os.Args) < 3 {
- fatal("usage %s