diff --git a/merkledag/batch.go b/merkledag/batch.go index bf3e74048..b6dd286b9 100644 --- a/merkledag/batch.go +++ b/merkledag/batch.go @@ -43,7 +43,8 @@ func (t *Batch) processResults() { } func (t *Batch) asyncCommit() { - if len(t.blocks) == 0 || t.commitError != nil { + numBlocks := len(t.blocks) + if numBlocks == 0 || t.commitError != nil { return } if t.activeCommits >= ParallelBatchCommits { @@ -61,7 +62,7 @@ func (t *Batch) asyncCommit() { }(t.blocks) t.activeCommits++ - t.blocks = nil + t.blocks = make([]blocks.Block, 0, numBlocks) t.size = 0 return