aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-01-09 22:58:05 +0800
committerGitHub <noreply@github.com>2017-01-09 22:58:05 +0800
commit4268cb8efecceaf506e1b0b71e06714a838a49a8 (patch)
treea0b9b50d4a8c73a4589b0315db982e4604fa2fcf
parent3f1a72908c00a048919536a46ef19efcdb5caa1f (diff)
parent2fed476ce16101e43867b9e2c8cd1625db0180e0 (diff)
downloadgo-tangerine-4268cb8efecceaf506e1b0b71e06714a838a49a8.tar
go-tangerine-4268cb8efecceaf506e1b0b71e06714a838a49a8.tar.gz
go-tangerine-4268cb8efecceaf506e1b0b71e06714a838a49a8.tar.bz2
go-tangerine-4268cb8efecceaf506e1b0b71e06714a838a49a8.tar.lz
go-tangerine-4268cb8efecceaf506e1b0b71e06714a838a49a8.tar.xz
go-tangerine-4268cb8efecceaf506e1b0b71e06714a838a49a8.tar.zst
go-tangerine-4268cb8efecceaf506e1b0b71e06714a838a49a8.zip
Merge pull request #3534 from bas-vk/writemipmaprace
core: fix race condition in WriteMipmapBloom
-rw-r--r--core/database_util.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/database_util.go b/core/database_util.go
index 84669de35..2060b8b6a 100644
--- a/core/database_util.go
+++ b/core/database_util.go
@@ -23,6 +23,7 @@ import (
"errors"
"fmt"
"math/big"
+ "sync"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
@@ -63,6 +64,8 @@ var (
oldBlockHashPrefix = []byte("block-hash-") // [deprecated by the header/block split, remove eventually]
ChainConfigNotFoundErr = errors.New("ChainConfig not found") // general config not found error
+
+ mipmapBloomMu sync.Mutex // protect against race condition when updating mipmap blooms
)
// encodeBlockNumber encodes a block number as big endian uint64
@@ -564,6 +567,9 @@ func mipmapKey(num, level uint64) []byte {
// WriteMapmapBloom writes each address included in the receipts' logs to the
// MIP bloom bin.
func WriteMipmapBloom(db ethdb.Database, number uint64, receipts types.Receipts) error {
+ mipmapBloomMu.Lock()
+ defer mipmapBloomMu.Unlock()
+
batch := db.NewBatch()
for _, level := range MIPMapLevels {
key := mipmapKey(number, level)