2023-12-12 17:47:41 +00:00
|
|
|
# Nimbus
|
2024-02-02 20:23:04 +00:00
|
|
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
2023-12-12 17:47:41 +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.
|
|
|
|
|
|
|
|
{.push raises: [].}
|
|
|
|
|
|
|
|
import
|
|
|
|
eth/common,
|
|
|
|
../core_db,
|
2024-07-12 13:12:25 +00:00
|
|
|
./backend/accounts_ledger,
|
|
|
|
./base/[api_tracking, base_config, base_desc]
|
2023-12-12 17:47:41 +00:00
|
|
|
|
|
|
|
when LedgerEnableApiTracking:
|
|
|
|
import
|
|
|
|
std/times,
|
|
|
|
chronicles
|
2024-07-12 13:12:25 +00:00
|
|
|
logScope:
|
|
|
|
topics = "ledger"
|
2023-12-12 17:47:41 +00:00
|
|
|
const
|
2024-07-12 13:12:25 +00:00
|
|
|
apiTxt = "API"
|
2023-12-12 17:47:41 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public iterators
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
iterator accounts*(ldg: LedgerRef): Account =
|
|
|
|
ldg.beginTrackApi LdgAccountsIt
|
2024-05-29 11:06:49 +00:00
|
|
|
for w in ldg.ac.accounts():
|
|
|
|
yield w
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-12-12 17:47:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
iterator addresses*(ldg: LedgerRef): EthAddress =
|
|
|
|
ldg.beginTrackApi LdgAdressesIt
|
2024-05-29 11:06:49 +00:00
|
|
|
for w in ldg.ac.addresses():
|
|
|
|
yield w
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-12-12 17:47:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
iterator cachedStorage*(ldg: LedgerRef, eAddr: EthAddress): (UInt256,UInt256) =
|
|
|
|
ldg.beginTrackApi LdgCachedStorageIt
|
2024-05-29 11:06:49 +00:00
|
|
|
for w in ldg.ac.cachedStorage(eAddr):
|
|
|
|
yield w
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr)
|
2023-12-12 17:47:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
iterator pairs*(ldg: LedgerRef): (EthAddress,Account) =
|
|
|
|
ldg.beginTrackApi LdgPairsIt
|
2024-05-29 11:06:49 +00:00
|
|
|
for w in ldg.ac.pairs():
|
|
|
|
yield w
|
2024-03-18 19:40:23 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
2023-12-12 17:47:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
iterator storage*(
|
|
|
|
ldg: LedgerRef;
|
|
|
|
eAddr: EthAddress;
|
2024-05-20 10:17:51 +00:00
|
|
|
): (UInt256,UInt256) =
|
2023-12-12 17:47:41 +00:00
|
|
|
ldg.beginTrackApi LdgStorageIt
|
2024-05-29 11:06:49 +00:00
|
|
|
for w in ldg.ac.storage(eAddr):
|
|
|
|
yield w
|
2024-07-12 13:12:25 +00:00
|
|
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr)
|
2023-12-12 17:47:41 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# End
|
|
|
|
# ------------------------------------------------------------------------------
|