浏览代码

Merge pull request #22332 from karalabe/fix-fastsync-restart-bloom-crash

trie: fix bloom crash on fast sync restart
Péter Szilágyi 4 年之前
父节点
当前提交
915c614959
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      trie/sync.go

+ 6 - 2
trie/sync.go

@@ -313,11 +313,15 @@ func (s *Sync) Commit(dbw ethdb.Batch) error {
 	// Dump the membatch into a database dbw
 	// Dump the membatch into a database dbw
 	for key, value := range s.membatch.nodes {
 	for key, value := range s.membatch.nodes {
 		rawdb.WriteTrieNode(dbw, key, value)
 		rawdb.WriteTrieNode(dbw, key, value)
-		s.bloom.Add(key[:])
+		if s.bloom != nil {
+			s.bloom.Add(key[:])
+		}
 	}
 	}
 	for key, value := range s.membatch.codes {
 	for key, value := range s.membatch.codes {
 		rawdb.WriteCode(dbw, key, value)
 		rawdb.WriteCode(dbw, key, value)
-		s.bloom.Add(key[:])
+		if s.bloom != nil {
+			s.bloom.Add(key[:])
+		}
 	}
 	}
 	// Drop the membatch data and return
 	// Drop the membatch data and return
 	s.membatch = newSyncMemBatch()
 	s.membatch = newSyncMemBatch()