mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-18 08:38:46 +00:00
cmd/evm: genesis db cleanup (#7517)
This commit is contained in:
parent
dfadf495cf
commit
7a4114d55d
@ -450,9 +450,6 @@ func DeveloperGenesisBlock(period uint64, faucet libcommon.Address) *types.Genes
|
||||
}
|
||||
}
|
||||
|
||||
var genesisTmpDB kv.RwDB
|
||||
var genesisDBLock sync.Mutex
|
||||
|
||||
// ToBlock creates the genesis block and writes state of a genesis specification
|
||||
// to the given database (or discards it if nil).
|
||||
func GenesisToBlock(g *types.Genesis, tmpDir string) (*types.Block, *state.IntraBlockState, error) {
|
||||
@ -497,20 +494,19 @@ func GenesisToBlock(g *types.Genesis, tmpDir string) (*types.Block, *state.Intra
|
||||
var statedb *state.IntraBlockState
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
|
||||
var err error
|
||||
go func() { // we may run inside write tx, can't open 2nd write tx in same goroutine
|
||||
// TODO(yperbasis): use memdb.MemoryMutation instead
|
||||
defer wg.Done()
|
||||
genesisDBLock.Lock()
|
||||
defer genesisDBLock.Unlock()
|
||||
if genesisTmpDB == nil {
|
||||
genesisTmpDB = mdbx.NewMDBX(log.New()).InMem(tmpDir).MapSize(2 * datasize.GB).MustOpen()
|
||||
}
|
||||
genesisTmpDB := mdbx.NewMDBX(log.New()).InMem(tmpDir).MapSize(2 * datasize.GB).GrowthStep(1 * datasize.MB).MustOpen()
|
||||
defer genesisTmpDB.Close()
|
||||
var tx kv.RwTx
|
||||
if tx, err = genesisTmpDB.BeginRw(context.Background()); err != nil {
|
||||
return
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
r, w := state.NewDbStateReader(tx), state.NewDbStateWriter(tx, 0)
|
||||
statedb = state.New(r)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user