pass logger to BC through vmConfig
This commit is contained in:
parent
ee791b2b20
commit
0d25fbc37d
|
@ -2163,15 +2163,15 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
|
|||
cache.TrieDirtyLimit = ctx.Int(CacheFlag.Name) * ctx.Int(CacheGCFlag.Name) / 100
|
||||
}
|
||||
vmcfg := vm.Config{EnablePreimageRecording: ctx.Bool(VMEnableDebugFlag.Name)}
|
||||
|
||||
if ctx.IsSet(VMTraceFlag.Name) {
|
||||
vmcfg.Tracer = tracers.NewPrinter()
|
||||
}
|
||||
// Disable transaction indexing/unindexing by default.
|
||||
chain, err := core.NewBlockChain(chainDb, cache, gspec, nil, engine, vmcfg, nil, nil)
|
||||
if err != nil {
|
||||
Fatalf("Can't create BlockChain: %v", err)
|
||||
}
|
||||
if ctx.IsSet(VMTraceFlag.Name) {
|
||||
chain.SetLogger(tracers.NewPrinter())
|
||||
}
|
||||
|
||||
return chain, chainDb
|
||||
}
|
||||
|
||||
|
|
|
@ -265,6 +265,14 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
|
|||
}
|
||||
log.Info(strings.Repeat("-", 153))
|
||||
log.Info("")
|
||||
var logger BlockchainLogger
|
||||
if vmConfig.Tracer != nil {
|
||||
l, ok := vmConfig.Tracer.(BlockchainLogger)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("only extended tracers are supported for live mode")
|
||||
}
|
||||
logger = l
|
||||
}
|
||||
|
||||
bc := &BlockChain{
|
||||
chainConfig: chainConfig,
|
||||
|
@ -282,6 +290,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
|
|||
futureBlocks: lru.NewCache[common.Hash, *types.Block](maxFutureBlocks),
|
||||
engine: engine,
|
||||
vmConfig: vmConfig,
|
||||
logger: logger,
|
||||
}
|
||||
bc.flushInterval.Store(int64(cacheConfig.TrieTimeLimit))
|
||||
bc.forker = NewForkChoice(bc, shouldPreserve)
|
||||
|
@ -453,12 +462,6 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
|
|||
return bc, nil
|
||||
}
|
||||
|
||||
// TODO: need to move this to NewBlockchain to capture genesis block
|
||||
func (bc *BlockChain) SetLogger(l BlockchainLogger) {
|
||||
bc.logger = l
|
||||
bc.vmConfig.Tracer = l
|
||||
}
|
||||
|
||||
// empty returns an indicator whether the blockchain is empty.
|
||||
// Note, it's a special case that we connect a non-empty ancient
|
||||
// database with an empty node, so that we can plugin the ancient
|
||||
|
|
Loading…
Reference in New Issue