mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 09:37:38 +00:00
Shared genesis db (#6465)
This commit is contained in:
parent
a528249b00
commit
ca3bc54428
@ -26,6 +26,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/c2h5oh/datasize"
|
"github.com/c2h5oh/datasize"
|
||||||
@ -90,6 +91,14 @@ type AuthorityRoundSeal struct {
|
|||||||
Signature common.Hash `json:"signature"`
|
Signature common.Hash `json:"signature"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var genesisTmpDB kv.RwDB
|
||||||
|
var genesisDBLock *sync.Mutex
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
genesisTmpDB = mdbx.NewMDBX(log.New()).InMem(os.TempDir()).MapSize(2 * datasize.GB).PageSize(2 * 4096).WriteMergeThreshold(2 * 8192).MustOpen()
|
||||||
|
genesisDBLock = &sync.Mutex{}
|
||||||
|
}
|
||||||
|
|
||||||
func (ga *GenesisAlloc) UnmarshalJSON(data []byte) error {
|
func (ga *GenesisAlloc) UnmarshalJSON(data []byte) error {
|
||||||
m := make(map[common.UnprefixedAddress]GenesisAccount)
|
m := make(map[common.UnprefixedAddress]GenesisAccount)
|
||||||
if err := json.Unmarshal(data, &m); err != nil {
|
if err := json.Unmarshal(data, &m); err != nil {
|
||||||
@ -370,9 +379,9 @@ func (g *Genesis) ToBlock() (*types.Block, *state.IntraBlockState, error) {
|
|||||||
go func() { // we may run inside write tx, can't open 2nd write tx in same goroutine
|
go func() { // we may run inside write tx, can't open 2nd write tx in same goroutine
|
||||||
// TODO(yperbasis): use memdb.MemoryMutation instead
|
// TODO(yperbasis): use memdb.MemoryMutation instead
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
tmpDB := mdbx.NewMDBX(log.New()).InMem("").MapSize(2 * datasize.GB).MustOpen()
|
genesisDBLock.Lock()
|
||||||
defer tmpDB.Close()
|
defer genesisDBLock.Unlock()
|
||||||
tx, err := tmpDB.BeginRw(context.Background())
|
tx, err := genesisTmpDB.BeginRw(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user