Skip to content

Commit

Permalink
Merge pull request #200 from eosnetworkfoundation/kayan_fix_timestamp…
Browse files Browse the repository at this point in the history
…_to_blocknum

[release/0.7] Kayan fix timestamp to blocknum
  • Loading branch information
taokayan authored Mar 25, 2024
2 parents dae7362 + 8eec7f5 commit 00a14cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ This repo contains the following GitHub Actions workflows for CI:
- [Documentation](./.github/workflows/node.md)

See the pipeline documentation for more information.

11 changes: 6 additions & 5 deletions src/block_conversion_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ class block_conversion_plugin_impl : std::enable_shared_from_this<block_conversi
: evm_blocks_channel(appbase::app().get_channel<channels::evm_blocks>()){}


uint32_t timestamp_to_evm_block_num(uint64_t timestamp) const {
if (timestamp < bm.value().genesis_timestamp) {
SILK_CRIT << "Invalid timestamp " << timestamp << ", genesis: " << bm->genesis_timestamp;
assert(timestamp >= bm->genesis_timestamp);
uint32_t timestamp_to_evm_block_num(uint64_t timestamp_us) const {
uint64_t timestamp_s = timestamp_us / 1e6;
if (timestamp_s < bm.value().genesis_timestamp) {
SILK_CRIT << "Invalid timestamp " << timestamp_s << ", genesis: " << bm->genesis_timestamp;
assert(timestamp_s >= bm->genesis_timestamp);
}

return bm->timestamp_to_evm_block_num(timestamp);
return bm->timestamp_to_evm_block_num(timestamp_us);
}

void load_head() {
Expand Down

0 comments on commit 00a14cf

Please sign in to comment.