aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-01-06 22:52:03 +0800
committerFelix Lange <fjl@twurst.com>2017-01-06 22:52:03 +0800
commit35a7dcb162546f7f31cb6492f716cb93159218d7 (patch)
tree4828026948031719a703a87e0ce909e82da21d3b /eth
parente0fde022909d272e55fb9ea2d4f8cfe9f178dba8 (diff)
downloaddexon-35a7dcb162546f7f31cb6492f716cb93159218d7.tar
dexon-35a7dcb162546f7f31cb6492f716cb93159218d7.tar.gz
dexon-35a7dcb162546f7f31cb6492f716cb93159218d7.tar.bz2
dexon-35a7dcb162546f7f31cb6492f716cb93159218d7.tar.lz
dexon-35a7dcb162546f7f31cb6492f716cb93159218d7.tar.xz
dexon-35a7dcb162546f7f31cb6492f716cb93159218d7.tar.zst
dexon-35a7dcb162546f7f31cb6492f716cb93159218d7.zip
all: gofmt -w -s
Diffstat (limited to 'eth')
-rw-r--r--eth/backend_test.go4
-rw-r--r--eth/downloader/peer.go4
-rw-r--r--eth/downloader/queue.go4
-rw-r--r--eth/filters/api.go2
-rw-r--r--eth/filters/filter_system_test.go22
-rw-r--r--eth/filters/filter_test.go12
-rw-r--r--eth/handler_test.go12
-rw-r--r--eth/protocol_test.go2
8 files changed, 31 insertions, 31 deletions
diff --git a/eth/backend_test.go b/eth/backend_test.go
index 8d55f30b9..574731fbe 100644
--- a/eth/backend_test.go
+++ b/eth/backend_test.go
@@ -37,12 +37,12 @@ func TestMipmapUpgrade(t *testing.T) {
switch i {
case 1:
receipt := types.NewReceipt(nil, new(big.Int))
- receipt.Logs = []*types.Log{&types.Log{Address: addr}}
+ receipt.Logs = []*types.Log{{Address: addr}}
gen.AddUncheckedReceipt(receipt)
receipts = types.Receipts{receipt}
case 2:
receipt := types.NewReceipt(nil, new(big.Int))
- receipt.Logs = []*types.Log{&types.Log{Address: addr}}
+ receipt.Logs = []*types.Log{{Address: addr}}
gen.AddUncheckedReceipt(receipt)
receipts = types.Receipts{receipt}
}
diff --git a/eth/downloader/peer.go b/eth/downloader/peer.go
index b0bfc66c8..ea4b6a6f2 100644
--- a/eth/downloader/peer.go
+++ b/eth/downloader/peer.go
@@ -205,7 +205,7 @@ func (p *peer) FetchNodeData(request *fetchRequest) error {
// Convert the hash set to a retrievable slice
hashes := make([]common.Hash, 0, len(request.Hashes))
- for hash, _ := range request.Hashes {
+ for hash := range request.Hashes {
hashes = append(hashes, hash)
}
go p.getNodeData(hashes)
@@ -314,7 +314,7 @@ func (p *peer) MarkLacking(hash common.Hash) {
defer p.lock.Unlock()
for len(p.lacking) >= maxLackingHashes {
- for drop, _ := range p.lacking {
+ for drop := range p.lacking {
delete(p.lacking, drop)
break
}
diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go
index 060eaf970..dd9590b28 100644
--- a/eth/downloader/queue.go
+++ b/eth/downloader/queue.go
@@ -844,7 +844,7 @@ func (q *queue) expire(timeout time.Duration, pendPool map[string]*fetchRequest,
}
}
// Remove the expired requests from the pending pool
- for id, _ := range expiries {
+ for id := range expiries {
delete(pendPool, id)
}
return expiries
@@ -1063,7 +1063,7 @@ func (q *queue) DeliverNodeData(id string, data [][]byte, callback func(int, boo
// If no data was retrieved, mark their hashes as unavailable for the origin peer
if len(data) == 0 {
- for hash, _ := range request.Hashes {
+ for hash := range request.Hashes {
request.Peer.MarkLacking(hash)
}
}
diff --git a/eth/filters/api.go b/eth/filters/api.go
index 65d7fd17e..02a544ce1 100644
--- a/eth/filters/api.go
+++ b/eth/filters/api.go
@@ -505,7 +505,7 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
switch topic := t.(type) {
case nil:
// ignore topic when matching logs
- args.Topics[i] = []common.Hash{common.Hash{}}
+ args.Topics[i] = []common.Hash{{}}
case string:
// match specific topic
diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go
index 5f51c0aa8..cd0745ec1 100644
--- a/eth/filters/filter_system_test.go
+++ b/eth/filters/filter_system_test.go
@@ -281,15 +281,15 @@ func TestLogFilter(t *testing.T) {
// match all
0: {FilterCriteria{}, allLogs, ""},
// match none due to no matching addresses
- 1: {FilterCriteria{Addresses: []common.Address{common.Address{}, notUsedAddress}, Topics: [][]common.Hash{allLogs[0].Topics}}, []*types.Log{}, ""},
+ 1: {FilterCriteria{Addresses: []common.Address{{}, notUsedAddress}, Topics: [][]common.Hash{allLogs[0].Topics}}, []*types.Log{}, ""},
// match logs based on addresses, ignore topics
2: {FilterCriteria{Addresses: []common.Address{firstAddr}}, allLogs[:2], ""},
// match none due to no matching topics (match with address)
- 3: {FilterCriteria{Addresses: []common.Address{secondAddr}, Topics: [][]common.Hash{[]common.Hash{notUsedTopic}}}, []*types.Log{}, ""},
+ 3: {FilterCriteria{Addresses: []common.Address{secondAddr}, Topics: [][]common.Hash{{notUsedTopic}}}, []*types.Log{}, ""},
// match logs based on addresses and topics
- 4: {FilterCriteria{Addresses: []common.Address{thirdAddress}, Topics: [][]common.Hash{[]common.Hash{firstTopic, secondTopic}}}, allLogs[3:5], ""},
+ 4: {FilterCriteria{Addresses: []common.Address{thirdAddress}, Topics: [][]common.Hash{{firstTopic, secondTopic}}}, allLogs[3:5], ""},
// match logs based on multiple addresses and "or" topics
- 5: {FilterCriteria{Addresses: []common.Address{secondAddr, thirdAddress}, Topics: [][]common.Hash{[]common.Hash{firstTopic, secondTopic}}}, allLogs[2:5], ""},
+ 5: {FilterCriteria{Addresses: []common.Address{secondAddr, thirdAddress}, Topics: [][]common.Hash{{firstTopic, secondTopic}}}, allLogs[2:5], ""},
// logs in the pending block
6: {FilterCriteria{Addresses: []common.Address{firstAddr}, FromBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), ToBlock: big.NewInt(rpc.PendingBlockNumber.Int64())}, allLogs[:2], ""},
// mined logs with block num >= 2 or pending logs
@@ -299,9 +299,9 @@ func TestLogFilter(t *testing.T) {
// all "mined" logs
9: {FilterCriteria{ToBlock: big.NewInt(rpc.LatestBlockNumber.Int64())}, allLogs, ""},
// all "mined" logs with 1>= block num <=2 and topic secondTopic
- 10: {FilterCriteria{FromBlock: big.NewInt(1), ToBlock: big.NewInt(2), Topics: [][]common.Hash{[]common.Hash{secondTopic}}}, allLogs[3:4], ""},
+ 10: {FilterCriteria{FromBlock: big.NewInt(1), ToBlock: big.NewInt(2), Topics: [][]common.Hash{{secondTopic}}}, allLogs[3:4], ""},
// all "mined" and pending logs with topic firstTopic
- 11: {FilterCriteria{FromBlock: big.NewInt(rpc.LatestBlockNumber.Int64()), ToBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), Topics: [][]common.Hash{[]common.Hash{firstTopic}}}, expectedCase11, ""},
+ 11: {FilterCriteria{FromBlock: big.NewInt(rpc.LatestBlockNumber.Int64()), ToBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), Topics: [][]common.Hash{{firstTopic}}}, expectedCase11, ""},
}
)
@@ -402,19 +402,19 @@ func TestPendingLogsSubscription(t *testing.T) {
// match all
{FilterCriteria{}, convertLogs(allLogs), nil, nil},
// match none due to no matching addresses
- {FilterCriteria{Addresses: []common.Address{common.Address{}, notUsedAddress}, Topics: [][]common.Hash{[]common.Hash{}}}, []*types.Log{}, nil, nil},
+ {FilterCriteria{Addresses: []common.Address{{}, notUsedAddress}, Topics: [][]common.Hash{{}}}, []*types.Log{}, nil, nil},
// match logs based on addresses, ignore topics
{FilterCriteria{Addresses: []common.Address{firstAddr}}, append(convertLogs(allLogs[:2]), allLogs[5].Logs[3]), nil, nil},
// match none due to no matching topics (match with address)
- {FilterCriteria{Addresses: []common.Address{secondAddr}, Topics: [][]common.Hash{[]common.Hash{notUsedTopic}}}, []*types.Log{}, nil, nil},
+ {FilterCriteria{Addresses: []common.Address{secondAddr}, Topics: [][]common.Hash{{notUsedTopic}}}, []*types.Log{}, nil, nil},
// match logs based on addresses and topics
- {FilterCriteria{Addresses: []common.Address{thirdAddress}, Topics: [][]common.Hash{[]common.Hash{firstTopic, secondTopic}}}, append(convertLogs(allLogs[3:5]), allLogs[5].Logs[0]), nil, nil},
+ {FilterCriteria{Addresses: []common.Address{thirdAddress}, Topics: [][]common.Hash{{firstTopic, secondTopic}}}, append(convertLogs(allLogs[3:5]), allLogs[5].Logs[0]), nil, nil},
// match logs based on multiple addresses and "or" topics
- {FilterCriteria{Addresses: []common.Address{secondAddr, thirdAddress}, Topics: [][]common.Hash{[]common.Hash{firstTopic, secondTopic}}}, append(convertLogs(allLogs[2:5]), allLogs[5].Logs[0]), nil, nil},
+ {FilterCriteria{Addresses: []common.Address{secondAddr, thirdAddress}, Topics: [][]common.Hash{{firstTopic, secondTopic}}}, append(convertLogs(allLogs[2:5]), allLogs[5].Logs[0]), nil, nil},
// block numbers are ignored for filters created with New***Filter, these return all logs that match the given criterias when the state changes
{FilterCriteria{Addresses: []common.Address{firstAddr}, FromBlock: big.NewInt(2), ToBlock: big.NewInt(3)}, append(convertLogs(allLogs[:2]), allLogs[5].Logs[3]), nil, nil},
// multiple pending logs, should match only 2 topics from the logs in block 5
- {FilterCriteria{Addresses: []common.Address{thirdAddress}, Topics: [][]common.Hash{[]common.Hash{firstTopic, forthTopic}}}, []*types.Log{allLogs[5].Logs[0], allLogs[5].Logs[2]}, nil, nil},
+ {FilterCriteria{Addresses: []common.Address{thirdAddress}, Topics: [][]common.Hash{{firstTopic, forthTopic}}}, []*types.Log{allLogs[5].Logs[0], allLogs[5].Logs[2]}, nil, nil},
}
)
diff --git a/eth/filters/filter_test.go b/eth/filters/filter_test.go
index 35495e8af..83ff3e9ce 100644
--- a/eth/filters/filter_test.go
+++ b/eth/filters/filter_test.go
@@ -210,7 +210,7 @@ func TestFilters(t *testing.T) {
filter := New(backend, true)
filter.SetAddresses([]common.Address{addr})
- filter.SetTopics([][]common.Hash{[]common.Hash{hash1, hash2, hash3, hash4}})
+ filter.SetTopics([][]common.Hash{{hash1, hash2, hash3, hash4}})
filter.SetBeginBlock(0)
filter.SetEndBlock(-1)
@@ -221,7 +221,7 @@ func TestFilters(t *testing.T) {
filter = New(backend, true)
filter.SetAddresses([]common.Address{addr})
- filter.SetTopics([][]common.Hash{[]common.Hash{hash3}})
+ filter.SetTopics([][]common.Hash{{hash3}})
filter.SetBeginBlock(900)
filter.SetEndBlock(999)
logs, _ = filter.Find(context.Background())
@@ -234,7 +234,7 @@ func TestFilters(t *testing.T) {
filter = New(backend, true)
filter.SetAddresses([]common.Address{addr})
- filter.SetTopics([][]common.Hash{[]common.Hash{hash3}})
+ filter.SetTopics([][]common.Hash{{hash3}})
filter.SetBeginBlock(990)
filter.SetEndBlock(-1)
logs, _ = filter.Find(context.Background())
@@ -246,7 +246,7 @@ func TestFilters(t *testing.T) {
}
filter = New(backend, true)
- filter.SetTopics([][]common.Hash{[]common.Hash{hash1, hash2}})
+ filter.SetTopics([][]common.Hash{{hash1, hash2}})
filter.SetBeginBlock(1)
filter.SetEndBlock(10)
@@ -257,7 +257,7 @@ func TestFilters(t *testing.T) {
failHash := common.BytesToHash([]byte("fail"))
filter = New(backend, true)
- filter.SetTopics([][]common.Hash{[]common.Hash{failHash}})
+ filter.SetTopics([][]common.Hash{{failHash}})
filter.SetBeginBlock(0)
filter.SetEndBlock(-1)
@@ -278,7 +278,7 @@ func TestFilters(t *testing.T) {
}
filter = New(backend, true)
- filter.SetTopics([][]common.Hash{[]common.Hash{failHash}, []common.Hash{hash1}})
+ filter.SetTopics([][]common.Hash{{failHash}, {hash1}})
filter.SetBeginBlock(0)
filter.SetEndBlock(-1)
diff --git a/eth/handler_test.go b/eth/handler_test.go
index 6900f7808..4695b3f60 100644
--- a/eth/handler_test.go
+++ b/eth/handler_test.go
@@ -75,7 +75,7 @@ func testGetBlockHeaders(t *testing.T, protocol int) {
// Create a "random" unknown hash for testing
var unknown common.Hash
- for i, _ := range unknown {
+ for i := range unknown {
unknown[i] = byte(i)
}
// Create a batch of tests for various scenarios
@@ -246,17 +246,17 @@ func testGetBlockBodies(t *testing.T, protocol int) {
{limit + 1, nil, nil, limit}, // No more than the possible block count should be returned
{0, []common.Hash{pm.blockchain.Genesis().Hash()}, []bool{true}, 1}, // The genesis block should be retrievable
{0, []common.Hash{pm.blockchain.CurrentBlock().Hash()}, []bool{true}, 1}, // The chains head block should be retrievable
- {0, []common.Hash{common.Hash{}}, []bool{false}, 0}, // A non existent block should not be returned
+ {0, []common.Hash{{}}, []bool{false}, 0}, // A non existent block should not be returned
// Existing and non-existing blocks interleaved should not cause problems
{0, []common.Hash{
- common.Hash{},
+ {},
pm.blockchain.GetBlockByNumber(1).Hash(),
- common.Hash{},
+ {},
pm.blockchain.GetBlockByNumber(10).Hash(),
- common.Hash{},
+ {},
pm.blockchain.GetBlockByNumber(100).Hash(),
- common.Hash{},
+ {},
}, []bool{false, true, false, true, false, true, false}, 3},
}
// Run each of the tests and verify the results against the chain
diff --git a/eth/protocol_test.go b/eth/protocol_test.go
index 0aac19f43..43149d0c0 100644
--- a/eth/protocol_test.go
+++ b/eth/protocol_test.go
@@ -178,7 +178,7 @@ func testSendTransactions(t *testing.T, protocol int) {
func TestGetBlockHeadersDataEncodeDecode(t *testing.T) {
// Create a "random" hash for testing
var hash common.Hash
- for i, _ := range hash {
+ for i := range hash {
hash[i] = byte(i)
}
// Assemble some table driven tests