File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -283,6 +283,15 @@ func (d *Downloader) Synchronising() bool {
283
283
return atomic .LoadInt32 (& d .synchronising ) > 0
284
284
}
285
285
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
+
286
295
// RegisterPeer injects a new download peer into the set of block source to be
287
296
// used for fetching hashes and blocks from.
288
297
func (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 {
610
610
// Retrieve the requested state entry, stopping if enough was found
611
611
// todo now the code and trienode is mixed in the protocol level,
612
612
// 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
+ }
613
617
entry , err := pm .blockchain .TrieNode (hash )
614
618
if len (entry ) == 0 || err != nil {
615
619
// Read the contract code with prefix only to save unnecessary lookups.
You can’t perform that action at this time.
0 commit comments