diff --git a/blockdag/reachability.go b/blockdag/reachability.go index 765656728..c466ab068 100644 --- a/blockdag/reachability.go +++ b/blockdag/reachability.go @@ -339,8 +339,8 @@ func (rtn *reachabilityTreeNode) countSubtrees(subTreeSizeMap map[*reachabilityT func (rtn *reachabilityTreeNode) propagateInterval(subTreeSizeMap map[*reachabilityTreeNode]uint64) ([]*reachabilityTreeNode, error) { // We set the interval to reset its remainingInterval, so we could reallocate it while reindexing. rtn.setInterval(rtn.interval) - modifiedNodes := []*reachabilityTreeNode{rtn} queue := []*reachabilityTreeNode{rtn} + var modifiedNodes []*reachabilityTreeNode for len(queue) > 0 { var current *reachabilityTreeNode current, queue = queue[0], queue[1:] diff --git a/blockdag/reachabilitystore.go b/blockdag/reachabilitystore.go index a845a7634..af4494a1c 100644 --- a/blockdag/reachabilitystore.go +++ b/blockdag/reachabilitystore.go @@ -88,6 +88,7 @@ func (store *reachabilityStore) flushToDB(dbTx database.Tx) error { } for hash := range store.dirty { + hash := hash // Copy hash to a new variable to avoid passing the same pointer reachabilityData := store.loaded[hash] err := store.dbStoreReachabilityData(dbTx, &hash, reachabilityData) if err != nil { diff --git a/blockdag/utxodiffstore.go b/blockdag/utxodiffstore.go index ec7c2ac87..07707e053 100644 --- a/blockdag/utxodiffstore.go +++ b/blockdag/utxodiffstore.go @@ -166,6 +166,7 @@ func (diffStore *utxoDiffStore) flushToDB(dbTx database.Tx) error { // while writing each entry. buffer := &bytes.Buffer{} for hash := range diffStore.dirty { + hash := hash // Copy hash to a new variable to avoid passing the same pointer buffer.Reset() diffData := diffStore.loaded[hash] err := dbStoreDiffData(dbTx, buffer, &hash, diffData)