mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
eth/protocols/snap, trie/trienode: polish the code
This commit is contained in:
parent
df115944d3
commit
bb127178f0
3 changed files with 9 additions and 15 deletions
|
|
@ -332,7 +332,7 @@ func ServiceGetAccountRangeQuery(chain *core.BlockChain, req *GetAccountRangePac
|
|||
return nil, nil
|
||||
}
|
||||
}
|
||||
return accounts, proof.ByteList()
|
||||
return accounts, proof.List()
|
||||
}
|
||||
|
||||
func ServiceGetStorageRangesQuery(chain *core.BlockChain, req *GetStorageRangesPacket) ([][]*StorageData, [][]byte) {
|
||||
|
|
@ -434,9 +434,7 @@ func ServiceGetStorageRangesQuery(chain *core.BlockChain, req *GetStorageRangesP
|
|||
return nil, nil
|
||||
}
|
||||
}
|
||||
for _, blob := range proof.ByteList() {
|
||||
proofs = append(proofs, blob)
|
||||
}
|
||||
proofs = append(proofs, proof.List()...)
|
||||
// Proof terminates the reply as proofs are only added if a node
|
||||
// refuses to serve more data (exception when a contract fetch is
|
||||
// finishing, but that's that).
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ func createAccountRequestResponse(t *testPeer, root common.Hash, origin common.H
|
|||
t.logger.Error("Could not prove last item", "error", err)
|
||||
}
|
||||
}
|
||||
return keys, vals, proof.ByteList()
|
||||
return keys, vals, proof.List()
|
||||
}
|
||||
|
||||
// defaultStorageRequestHandler is a well-behaving storage request handler
|
||||
|
|
@ -368,9 +368,7 @@ func createStorageRequestResponse(t *testPeer, root common.Hash, accounts []comm
|
|||
t.logger.Error("Could not prove last item", "error", err)
|
||||
}
|
||||
}
|
||||
for _, blob := range proof.ByteList() {
|
||||
proofs = append(proofs, blob)
|
||||
}
|
||||
proofs = append(proofs, proof.List()...)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -427,9 +425,7 @@ func createStorageRequestResponseAlwaysProve(t *testPeer, root common.Hash, acco
|
|||
t.logger.Error("Could not prove last item", "error", err)
|
||||
}
|
||||
}
|
||||
for _, blob := range proof.ByteList() {
|
||||
proofs = append(proofs, blob)
|
||||
}
|
||||
proofs = append(proofs, proof.List()...)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -614,7 +610,7 @@ func testSyncBloatedProof(t *testing.T, scheme string) {
|
|||
keys = append(keys[:1], keys[2:]...)
|
||||
vals = append(vals[:1], vals[2:]...)
|
||||
}
|
||||
if err := t.remote.OnAccounts(t, requestId, keys, vals, proof.ByteList()); err != nil {
|
||||
if err := t.remote.OnAccounts(t, requestId, keys, vals, proof.List()); err != nil {
|
||||
t.logger.Info("remote error on delivery (as expected)", "error", err)
|
||||
t.term()
|
||||
// This is actually correct, signal to exit the test successfully
|
||||
|
|
|
|||
|
|
@ -102,12 +102,12 @@ func (db *ProofSet) DataSize() int {
|
|||
return db.dataSize
|
||||
}
|
||||
|
||||
// ByteList converts the node set to a [][]byte
|
||||
func (db *ProofSet) ByteList() [][]byte {
|
||||
// List converts the node set to a slice of bytes.
|
||||
func (db *ProofSet) List() [][]byte {
|
||||
db.lock.RLock()
|
||||
defer db.lock.RUnlock()
|
||||
|
||||
var values = make([][]byte, len(db.order))
|
||||
values := make([][]byte, len(db.order))
|
||||
for i, key := range db.order {
|
||||
values[i] = db.nodes[key]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue