Skip to content

Commit 3b45a8d

Browse files
committed
chore: nuke export.go
1 parent ee16107 commit 3b45a8d

File tree

2 files changed

+26
-40
lines changed

2 files changed

+26
-40
lines changed

tests/reexecute/export.go

Lines changed: 0 additions & 40 deletions
This file was deleted.

tests/reexecute/vm_executor.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/ava-labs/avalanchego/utils/crypto/bls/signer/localsigner"
3131
"github.com/ava-labs/avalanchego/utils/logging"
3232
"github.com/ava-labs/avalanchego/utils/timer"
33+
"github.com/ava-labs/avalanchego/utils/units"
3334
"github.com/ava-labs/avalanchego/vms"
3435
"github.com/ava-labs/avalanchego/vms/platformvm/warp"
3536
)
@@ -269,6 +270,31 @@ func NewMainnetVM(
269270
return vm, nil
270271
}
271272

273+
// ExportBlockRange copies blocks from a source LevelDB directory to a
274+
// destination LevelDB directory for the specified block range [startBlock, endBlock].
275+
func ExportBlockRange(tb testing.TB, blockDirSrc string, blockDirDst string, startBlock, endBlock uint64, chanSize int) {
276+
r := require.New(tb)
277+
blockChan := createBlockChanFromLevelDB(tb, blockDirSrc, startBlock, endBlock, chanSize)
278+
279+
db, err := leveldb.New(blockDirDst, nil, logging.NoLog{}, prometheus.NewRegistry())
280+
r.NoError(err)
281+
tb.Cleanup(func() {
282+
r.NoError(db.Close())
283+
})
284+
285+
batch := db.NewBatch()
286+
for blkResult := range blockChan {
287+
r.NoError(batch.Put(blockKey(blkResult.height), blkResult.blockBytes))
288+
289+
if batch.Size() > 10*units.MiB {
290+
r.NoError(batch.Write())
291+
batch = db.NewBatch()
292+
}
293+
}
294+
295+
r.NoError(batch.Write())
296+
}
297+
272298
type blockResult struct {
273299
blockBytes []byte
274300
height uint64

0 commit comments

Comments
 (0)