mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
M: fetcher.go: optimize bodyFilter in function 'func (f *Fetcher) loop()'
This commit is contained in:
parent
e9e69d6e29
commit
d05b082868
1 changed files with 7 additions and 3 deletions
|
|
@ -515,14 +515,18 @@ func (f *Fetcher) loop() {
|
||||||
|
|
||||||
blocks := []*types.Block{}
|
blocks := []*types.Block{}
|
||||||
for i := 0; i < len(task.transactions) && i < len(task.uncles); i++ {
|
for i := 0; i < len(task.transactions) && i < len(task.uncles); i++ {
|
||||||
|
var txnHash, uncleHash common.Hash
|
||||||
// Match up a body to any possible completion request
|
// Match up a body to any possible completion request
|
||||||
matched := false
|
matched := false
|
||||||
|
|
||||||
for hash, announce := range f.completing {
|
for hash, announce := range f.completing {
|
||||||
if f.queued[hash] == nil {
|
if f.queued[hash] == nil {
|
||||||
txnHash := types.DeriveSha(types.Transactions(task.transactions[i]))
|
if txnHash == (common.Hash{}) {
|
||||||
uncleHash := types.CalcUncleHash(task.uncles[i])
|
txnHash = types.DeriveSha(types.Transactions(task.transactions[i]))
|
||||||
|
}
|
||||||
|
if uncleHash == (common.Hash{}) {
|
||||||
|
uncleHash = types.CalcUncleHash(task.uncles[i])
|
||||||
|
}
|
||||||
if txnHash == announce.header.TxHash && uncleHash == announce.header.UncleHash && announce.origin == task.peer {
|
if txnHash == announce.header.TxHash && uncleHash == announce.header.UncleHash && announce.origin == task.peer {
|
||||||
// Mark the body matched, reassemble if still unknown
|
// Mark the body matched, reassemble if still unknown
|
||||||
matched = true
|
matched = true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue