mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-22 18:20:11 +00:00
5b6ccddaa0
* Aristo: Rename `Hash256` -> `Hash32` * CoreDb: Rename `Hash256` -> `Hash32` * Ledger: Rename `Hash256` -> `Hash32` * StorageTypes: Rename `Hash256` -> `Hash32` * Aristo: Rename `Blob` -> `seq[byte]`, `keccakHash` -> `keccak256` * Kvt: Rename `Blob` -> `seq[byte]` * CoreDb: Rename `Blob` -> `seq[byte]`, `keccakHash` -> `keccak256` * Ledger: Rename `Blob` -> `seq[byte]`, `keccakHash` -> `keccak256` * CoreDb: Rename `BlockHeader` -> `Header`, `BlockNonce` -> `Bytes8` * Misc: Rename `StorageKey` -> `Bytes32` * Tracer: `Hash256` -> `Hash32`, `BlockHeader` -> `Header`, etc. * Fix copyright header
48 lines
1.6 KiB
Nim
48 lines
1.6 KiB
Nim
# nimbus-eth1
|
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
|
# 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
|
|
std/tables,
|
|
eth/common,
|
|
results,
|
|
".."/[kvt_desc, kvt_utils]
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Public functions
|
|
# ------------------------------------------------------------------------------
|
|
|
|
proc revFilter*(
|
|
db: KvtDbRef; # Database
|
|
filter: LayerRef; # Filter to revert
|
|
): Result[LayerRef,(seq[byte],KvtError)] =
|
|
## Assemble reverse filter for the `filter` argument, i.e. changes to the
|
|
## backend that reverse the effect of applying the this read-only filter.
|
|
##
|
|
## This read-only filter is calculated against the current unfiltered
|
|
## backend (excluding optionally installed read-only filter.)
|
|
##
|
|
let rev = LayerRef()
|
|
|
|
# Calculate reverse changes for the `sTab[]` structural table
|
|
for key in filter.sTab.keys:
|
|
let rc = db.getUbe key
|
|
if rc.isOk:
|
|
rev.sTab[key] = rc.value
|
|
elif rc.error == GetNotFound:
|
|
rev.sTab[key] = EmptyBlob
|
|
else:
|
|
return err((key,rc.error))
|
|
|
|
ok(rev)
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# End
|
|
# ------------------------------------------------------------------------------
|