2021-07-06 13:14:45 +00:00
|
|
|
# Nimbus
|
2024-05-20 10:17:51 +00:00
|
|
|
# Copyright (c) 2021-2024 Status Research & Development GmbH
|
2021-07-06 13:14:45 +00:00
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
|
|
# http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
|
|
|
import
|
2024-05-20 13:59:18 +00:00
|
|
|
std/os,
|
|
|
|
eth/common,
|
|
|
|
"."/[undump_blocks_era1, undump_blocks_gz]
|
2021-07-06 13:14:45 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public undump
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2024-05-20 13:59:18 +00:00
|
|
|
iterator undumpBlocks*(file: string): (seq[BlockHeader],seq[BlockBody]) =
|
|
|
|
if file.dirExists:
|
|
|
|
for w in file.undumpBlocksEra1:
|
|
|
|
yield w
|
|
|
|
else:
|
|
|
|
let ext = file.splitFile.ext
|
|
|
|
if ext == ".gz":
|
|
|
|
for w in file.undumpBlocksGz:
|
|
|
|
yield w
|
|
|
|
else:
|
|
|
|
raiseAssert "Unsupported extension for \"" &
|
|
|
|
file & "\" (got \"" & ext & "\")"
|
|
|
|
|
|
|
|
iterator undumpBlocks*(files: seq[string]): (seq[BlockHeader],seq[BlockBody]) =
|
|
|
|
for f in files:
|
2023-04-21 21:11:04 +00:00
|
|
|
for w in f.undumpBlocks:
|
2022-03-28 08:35:26 +00:00
|
|
|
yield w
|
|
|
|
|
2021-07-06 13:14:45 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# End
|
|
|
|
# ------------------------------------------------------------------------------
|