diff --git a/core/blockchain.go b/core/blockchain.go index cb4bd42024..8c3ec4d29d 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -31,6 +31,7 @@ import ( "github.com/ethereum/go-ethereum/common/mclock" "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/shyftdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" @@ -876,8 +877,7 @@ 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) + fmt.Println("+++++++++++++++++++Blockchain.go+++++++++++++++++writeBlockWithState()") bc.wg.Add(1) defer bc.wg.Done() @@ -903,6 +903,11 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types. if err := WriteBlock(batch, block); err != nil { return NonStatTy, err } + + explorerBatch := bc.blockExplorerDb.NewBatch() + if err := shyftdb.WriteBlock(explorerBatch, block); err != nil { + return NonStatTy, err + } root, err := state.Commit(bc.chainConfig.IsEIP158(block.Number())) if err != nil { return NonStatTy, err diff --git a/core/database_util.go b/core/database_util.go index 8c46989854..8177e5ac04 100644 --- a/core/database_util.go +++ b/core/database_util.go @@ -455,6 +455,7 @@ func WriteBlock(db ethdb.Putter, block *types.Block) error { if err := WriteHeader(db, block.Header()); err != nil { return err } + return nil } diff --git a/shyftdb/database.go b/shyftdb/database.go index 8c557e4820..b30302a68a 100644 --- a/shyftdb/database.go +++ b/shyftdb/database.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see . -package ethdb +package shyftdb import ( "strconv" diff --git a/shyftdb/interface.go b/shyftdb/interface.go index bee33de2a8..fe361cc791 100644 --- a/shyftdb/interface.go +++ b/shyftdb/interface.go @@ -1,5 +1,5 @@ -package ethdb +package shyftdb // Code using batches should try to add this much data to the batch. // The value was determined empirically. diff --git a/shyftdb/shyft_database_util.go b/shyftdb/shyft_database_util.go new file mode 100644 index 0000000000..d35571f1e9 --- /dev/null +++ b/shyftdb/shyft_database_util.go @@ -0,0 +1,12 @@ +package shyftdb + +import ( + "fmt" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/core/types" +) + +func WriteBlock(db ethdb.Putter, block *types.Block) error { + fmt.Println(block) + return nil +} \ No newline at end of file