Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,19 +739,19 @@ func (bc *BlockChain) Export(w io.Writer) error {

// ExportN writes a subset of the active chain to the given writer.
func (bc *BlockChain) ExportN(w io.Writer, first uint64, last uint64) error {
if !bc.chainmu.TryLock() {
return errChainStopped
}
defer bc.chainmu.Unlock()

if first > last {
return fmt.Errorf("export failed: first (%d) is greater than last (%d)", first, last)
}
log.Info("Exporting batch of blocks", "count", last-first+1)

start, reported := time.Now(), time.Now()
var parentHash common.Hash
for nr := first; nr <= last; nr++ {
block := bc.GetBlockByNumber(nr)
if nr > first && block.Hash() != parentHash {
return fmt.Errorf("export failed: chain reorg during export")
}
parentHash = block.Hash()
if block == nil {
return fmt.Errorf("export failed on #%d: not found", nr)
}
Expand Down