diff options
author | Determinant <[email protected]> | 2019-09-26 22:19:04 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2019-09-26 22:19:04 -0400 |
commit | f3f0b274f2b8aad466b51448f2fbd2d2b8a4d1db (patch) | |
tree | 8b758b3c0d89cadcf9021acf0db206ab215d2663 /eth | |
parent | a96fc7a942fb6f0a9da5b5bf9c84a98af42a24dc (diff) |
expose the database interface
Diffstat (limited to 'eth')
-rw-r--r-- | eth/backend.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/eth/backend.go b/eth/backend.go index 4281d96..d119e89 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -119,7 +119,7 @@ func (s *Ethereum) SetContractBackend(backend bind.ContractBackend) { // New creates a new Ethereum object (including the // initialisation of the common Ethereum object) -func New(ctx *node.ServiceContext, config *Config, cb *dummy.ConsensusCallbacks, mcb *miner.MinerCallbacks) (*Ethereum, error) { +func New(ctx *node.ServiceContext, config *Config, cb *dummy.ConsensusCallbacks, mcb *miner.MinerCallbacks, chainDb ethdb.Database) (*Ethereum, error) { // Ensure configuration values are compatible and sane if config.SyncMode == downloader.LightSync { return nil, errors.New("can't run eth.Ethereum in light sync mode, use les.LightEthereum") @@ -137,10 +137,13 @@ func New(ctx *node.ServiceContext, config *Config, cb *dummy.ConsensusCallbacks, } log.Info("Allocated trie memory caches", "clean", common.StorageSize(config.TrieCleanCache)*1024*1024, "dirty", common.StorageSize(config.TrieDirtyCache)*1024*1024) - // Assemble the Ethereum object - chainDb, err := ctx.OpenDatabaseWithFreezer("chaindata", config.DatabaseCache, config.DatabaseHandles, config.DatabaseFreezer, "eth/db/chaindata/") - if err != nil { - return nil, err + var err error + if chainDb == nil { + // Assemble the Ethereum object + chainDb, err = ctx.OpenDatabaseWithFreezer("chaindata", config.DatabaseCache, config.DatabaseHandles, config.DatabaseFreezer, "eth/db/chaindata/") + if err != nil { + return nil, err + } } chainConfig, genesisHash, genesisErr := mycore.SetupGenesisBlock(chainDb, config.Genesis) if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok { |