diff --git a/core/bodydb.go b/core/bodydb.go index 9993edd1b1..38cfb5198c 100644 --- a/core/bodydb.go +++ b/core/bodydb.go @@ -83,6 +83,11 @@ func (bc *BodyDb) Append(batch ethdb.Batch, block *types.Block, newInboundEtxs t return logs, nil } +// WriteBlock write the block to the bodydb database +func (bc *BodyDb) WriteBlock(block *types.Block) { + rawdb.WriteBlock(bc.db, block) +} + // HasBlock checks if a block is fully present in the database or not. func (bc *BodyDb) HasBlock(hash common.Hash, number uint64) bool { if bc.blockCache.Contains(hash) { diff --git a/core/core.go b/core/core.go index d50f870329..6b2124b3e8 100644 --- a/core/core.go +++ b/core/core.go @@ -92,7 +92,7 @@ func (c *Core) InsertChain(blocks types.Blocks) (int, error) { c.futureHeaders.Remove(block.Hash()) // Resume the downloader if paused - c.sl.downloaderWaitFeed.Send(false) + c.sl.downloaderWaitFeed.Send(false) // If we have a dom, send the dom any pending ETXs which will become // referencable by this block. When this block is referenced in the dom's @@ -200,6 +200,11 @@ func (c *Core) Stop() { // Slice methods // //---------------// +// WriteBlock write the block to the bodydb database +func (c *Core) WriteBlock(block *types.Block) { + c.sl.WriteBlock(block) +} + func (c *Core) Append(header *types.Header, domPendingHeader *types.Header, domTerminus common.Hash, td *big.Int, domOrigin bool, reorg bool, newInboundEtxs types.Transactions) ([]types.Transactions, error) { newPendingEtxs, err := c.sl.Append(header, domPendingHeader, domTerminus, td, domOrigin, reorg, newInboundEtxs) // If dom tries to append the block and sub is not in sync. diff --git a/core/headerchain.go b/core/headerchain.go index 6557cf23c1..7383c74bbd 100644 --- a/core/headerchain.go +++ b/core/headerchain.go @@ -450,6 +450,10 @@ func (hc *HeaderChain) GetHorizon() uint64 { return header.NumberU64() } +func (hc *HeaderChain) WriteBlock(block *types.Block) { + hc.bc.WriteBlock(block) +} + // GetTd retrieves a block's total difficulty in the canonical chain from the // database by hash and number, caching it if found. func (hc *HeaderChain) GetTd(hash common.Hash, number uint64) *big.Int { diff --git a/core/slice.go b/core/slice.go index 14b09e69ae..6b085efffe 100644 --- a/core/slice.go +++ b/core/slice.go @@ -882,3 +882,7 @@ func (sl *Slice) SubscribeDownloaderWait(ch chan<- bool) event.Subscription { func (sl *Slice) SubscribeMissingBody(ch chan<- *types.Header) event.Subscription { return sl.scope.Track(sl.missingBodyFeed.Subscribe(ch)) } + +func (sl *Slice) WriteBlock(block *types.Block) { + sl.hc.WriteBlock(block) +}