From fcc66a59ea2c2eec21e33a107ef4b56d3b0293cd Mon Sep 17 00:00:00 2001 From: Tim Williams Date: Fri, 13 Apr 2018 16:17:26 -0400 Subject: [PATCH] add in dummy code --- cmd/utils/flags.go | 4 +++- core/blockchain.go | 8 +++++++- core/chain_makers.go | 4 ++-- eth/backend.go | 6 +++++- miner/worker.go | 3 +++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 5c44161c5f..daac8f851c 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1214,6 +1214,7 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis { // MakeChain creates a chain manager from set command line flags. func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chainDb ethdb.Database) { + fmt.Println("+++++++++++++++++cmd/flags.GO+++++++++++++++++++++++++MakeChain()") var err error chainDb = MakeChainDatabase(ctx, stack) @@ -1249,7 +1250,8 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai cache.TrieNodeLimit = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheGCFlag.Name) / 100 } vmcfg := vm.Config{EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name)} - chain, err = core.NewBlockChain(chainDb, cache, config, engine, vmcfg) + fmt.Println("Calling NewBlock CHAIN in flags.go ******************************") + chain, err = core.NewBlockChain(chainDb, chainDb,cache, config, engine, vmcfg) if err != nil { Fatalf("Can't create BlockChain: %v", err) } diff --git a/core/blockchain.go b/core/blockchain.go index b33eb85a44..dbd0df662c 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -90,6 +90,8 @@ type BlockChain struct { cacheConfig *CacheConfig // Cache configuration for pruning db ethdb.Database // Low level persistent database to store final content in + blockExplorerDb int + triegc *prque.Prque // Priority queue mapping block numbers to tries to gc gcproc time.Duration // Accumulates canonical block processing for trie dumping @@ -133,7 +135,8 @@ type BlockChain struct { // NewBlockChain returns a fully initialised block chain using information // available in the database. It initialises the default Ethereum Validator and // Processor. -func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config) (*BlockChain, error) { +func NewBlockChain(db ethdb.Database, blockExplorerDb ethdb.Database, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config) (*BlockChain, error) { + fmt.Printf("+++++++++++++++++core/blockchain.GO+++++++++++++++++++++++++NewBlockChain()") if cacheConfig == nil { cacheConfig = &CacheConfig{ TrieNodeLimit: 256 * 1024 * 1024, @@ -150,6 +153,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par chainConfig: chainConfig, cacheConfig: cacheConfig, db: db, + blockExplorerDb: 101, triegc: prque.New(), stateCache: state.NewDatabase(db), quit: make(chan struct{}), @@ -872,6 +876,8 @@ func (bc *BlockChain) WriteBlockWithoutState(block *types.Block, td *big.Int) (e // WriteBlockWithState writes the block and all associated state to the database. func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types.Receipt, state *state.StateDB) (status WriteStatus, err error) { + fmt.Println("WriteBlockWithState function. bc.blockexplorerDB") + fmt.Println(bc.blockExplorerDb) bc.wg.Add(1) defer bc.wg.Done() diff --git a/core/chain_makers.go b/core/chain_makers.go index 6744428ffb..06e6849871 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -166,7 +166,7 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse genblock := func(i int, parent *types.Block, statedb *state.StateDB) (*types.Block, types.Receipts) { // TODO(karalabe): This is needed for clique, which depends on multiple blocks. // It's nonetheless ugly to spin up a blockchain here. Get rid of this somehow. - blockchain, _ := NewBlockChain(db, nil, config, engine, vm.Config{}) + blockchain, _ := NewBlockChain(db, db,nil, config, engine, vm.Config{}) defer blockchain.Stop() b := &BlockGen{i: i, parent: parent, chain: blocks, chainReader: blockchain, statedb: statedb, config: config, engine: engine} @@ -249,7 +249,7 @@ func newCanonical(engine consensus.Engine, n int, full bool) (ethdb.Database, *B db, _ := ethdb.NewMemDatabase() genesis := gspec.MustCommit(db) - blockchain, _ := NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}) + blockchain, _ := NewBlockChain(db, db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}) // Create and inject the requested chain if n == 0 { return db, blockchain, nil diff --git a/eth/backend.go b/eth/backend.go index 567bbb866b..a956266a25 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -74,6 +74,7 @@ type Ethereum struct { // DB interfaces chainDb ethdb.Database // Block chain database + blockExplorerDb int eventMux *event.TypeMux engine consensus.Engine @@ -102,6 +103,7 @@ func (s *Ethereum) AddLesServer(ls LesServer) { // New creates a new Ethereum object (including the // initialisation of the common Ethereum object) func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { + // @NOTE:shyft Where we instantiate BlockExplorerDB fmt.Println("+++++++++++++++++eth/backend.GO+++++++++++++++++++++++++New()") if config.SyncMode == downloader.LightSync { return nil, errors.New("can't run eth.Ethereum in light sync mode, use les.LightEthereum") @@ -113,6 +115,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { if err != nil { return nil, err } + // @NOTE:shyft instantiate BlockExplorerDB here? stopDbUpgrade := upgradeDeduplicateData(chainDb) chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis) if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok { @@ -123,6 +126,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { eth := &Ethereum{ config: config, chainDb: chainDb, + blockExplorerDb: 42, chainConfig: chainConfig, eventMux: ctx.EventMux, accountManager: ctx.AccountManager, @@ -149,7 +153,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { vmConfig = vm.Config{EnablePreimageRecording: config.EnablePreimageRecording} cacheConfig = &core.CacheConfig{Disabled: config.NoPruning, TrieNodeLimit: config.TrieCache, TrieTimeLimit: config.TrieTimeout} ) - eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, eth.chainConfig, eth.engine, vmConfig) + eth.blockchain, err = core.NewBlockChain(chainDb, chainDb, cacheConfig, eth.chainConfig, eth.engine, vmConfig) if err != nil { return nil, err } diff --git a/miner/worker.go b/miner/worker.go index 15395ae0b9..4aec5f1c63 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -309,6 +309,9 @@ func (self *worker) wait() { for _, log := range work.state.Logs() { log.BlockHash = block.Hash() } + fmt.Println("+++++++++++++++++miner/worker.GO+++++++++++++++++++++++++wait()") + fmt.Println(work.state) + fmt.Println("+++++++++++++++++miner/worker.GO+++++++++++++++++++++++++selt chain") stat, err := self.chain.WriteBlockWithState(block, work.receipts, work.state) if err != nil { log.Error("Failed writing block to chain", "err", err)