File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -283,6 +283,15 @@ func (d *Downloader) Synchronising() bool {
283283 return atomic .LoadInt32 (& d .synchronising ) > 0
284284}
285285
286+ // SyncBloomContains tests if the syncbloom filter contains the given hash:
287+ // - false: the bloom definitely does not contain hash
288+ // - true: the bloom maybe contains hash
289+ //
290+ // While the bloom is being initialized (or is closed), all queries will return true.
291+ func (d * Downloader ) SyncBloomContains (hash []byte ) bool {
292+ return d .stateBloom == nil || d .stateBloom .Contains (hash )
293+ }
294+
286295// RegisterPeer injects a new download peer into the set of block source to be
287296// used for fetching hashes and blocks from.
288297func (d * Downloader ) RegisterPeer (id string , version int , peer Peer ) error {
Original file line number Diff line number Diff line change @@ -610,6 +610,10 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
610610 // Retrieve the requested state entry, stopping if enough was found
611611 // todo now the code and trienode is mixed in the protocol level,
612612 // separate these two types.
613+ if ! pm .downloader .SyncBloomContains (hash [:]) {
614+ // Only lookup the trie node if there's chance that we actually have it
615+ continue
616+ }
613617 entry , err := pm .blockchain .TrieNode (hash )
614618 if len (entry ) == 0 || err != nil {
615619 // Read the contract code with prefix only to save unnecessary lookups.
You can’t perform that action at this time.
0 commit comments