diff options
author | Felix Lange <fjl@twurst.com> | 2016-04-15 17:06:57 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-04-15 17:17:27 +0800 |
commit | 6fdd0893c3ebf57e5a9ba2af569c595c859ab902 (patch) | |
tree | 2df67265a0350b68b2f10ba2f7dcd292fef59ad0 /eth | |
parent | 68c755a238f1a204087c2843f01d48fc6039716f (diff) | |
download | dexon-6fdd0893c3ebf57e5a9ba2af569c595c859ab902.tar dexon-6fdd0893c3ebf57e5a9ba2af569c595c859ab902.tar.gz dexon-6fdd0893c3ebf57e5a9ba2af569c595c859ab902.tar.bz2 dexon-6fdd0893c3ebf57e5a9ba2af569c595c859ab902.tar.lz dexon-6fdd0893c3ebf57e5a9ba2af569c595c859ab902.tar.xz dexon-6fdd0893c3ebf57e5a9ba2af569c595c859ab902.tar.zst dexon-6fdd0893c3ebf57e5a9ba2af569c595c859ab902.zip |
all: fix go vet warnings
Diffstat (limited to 'eth')
-rw-r--r-- | eth/downloader/downloader.go | 6 | ||||
-rw-r--r-- | eth/downloader/queue.go | 2 | ||||
-rw-r--r-- | eth/filters/api.go | 8 | ||||
-rw-r--r-- | eth/filters/filter_system_test.go | 4 | ||||
-rw-r--r-- | eth/filters/filter_test.go | 4 | ||||
-rw-r--r-- | eth/handler.go | 1 | ||||
-rw-r--r-- | eth/handler_test.go | 13 | ||||
-rw-r--r-- | eth/helper_test.go | 10 | ||||
-rw-r--r-- | eth/protocol_test.go | 2 |
9 files changed, 24 insertions, 26 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index f50a71cf1..801181712 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 f86bae144..d8d1bddce 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 54336aaf9..9e95ebd83 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 7757fb84e..72824cb08 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 5954ea4c1..b0f88ffeb 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 135de3749..d6b474a91 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 76748b6e3..9e593f040 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 575211a55..5703d44cc 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 cac3657e7..0a82e2e79 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) } |