Skip to content

Commit

Permalink
make api, indexer, fake aptos db aware of block metadata ext txns
Browse files Browse the repository at this point in the history
  • Loading branch information
zjma committed Feb 28, 2024
1 parent e675e73 commit bd1cc34
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
4 changes: 3 additions & 1 deletion api/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,9 @@ impl Context {
.into_iter()
.map(|t| {
// Update the timestamp if the next block occurs
if let Some(txn) = t.transaction.try_as_block_metadata() {
if let Some(txn) = t.transaction.try_as_block_metadata_ext() {
timestamp = txn.timestamp_usecs();
} else if let Some(txn) = t.transaction.try_as_block_metadata() {
timestamp = txn.timestamp_usecs();
}
let txn = converter.try_into_onchain_transaction(timestamp, t)?;
Expand Down
8 changes: 7 additions & 1 deletion crates/indexer/src/indexer/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,13 @@ async fn fetch_nexts(
// Do not update block_height if first block is block metadata
if ind > 0 {
// Update the timestamp if the next block occurs
if let Some(txn) = raw_txn.transaction.try_as_block_metadata() {
if let Some(txn) = raw_txn.transaction.try_as_block_metadata_ext() {
timestamp = txn.timestamp_usecs();
epoch = txn.epoch();
epoch_bcs = aptos_api_types::U64::from(epoch);
block_height += 1;
block_height_bcs = aptos_api_types::U64::from(block_height);
} else if let Some(txn) = raw_txn.transaction.try_as_block_metadata() {
timestamp = txn.timestamp_usecs();
epoch = txn.epoch();
epoch_bcs = aptos_api_types::U64::from(epoch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,13 @@ impl IndexerStreamCoordinator {
// Do not update block_height if first block is block metadata
if ind > 0 {
// Update the timestamp if the next block occurs
if let Some(txn) = raw_txn.transaction.try_as_block_metadata() {
if let Some(txn) = raw_txn.transaction.try_as_block_metadata_ext() {
timestamp = txn.timestamp_usecs();
epoch = txn.epoch();
epoch_bcs = aptos_api_types::U64::from(epoch);
block_height += 1;
block_height_bcs = aptos_api_types::U64::from(block_height);
} else if let Some(txn) = raw_txn.transaction.try_as_block_metadata() {
timestamp = txn.timestamp_usecs();
epoch = txn.epoch();
epoch_bcs = aptos_api_types::U64::from(epoch);
Expand Down
5 changes: 4 additions & 1 deletion storage/aptosdb/src/fake_aptosdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,10 @@ impl FakeAptosDB {
.or_insert(user_txn.sequence_number());
}

if let Some(txn) = txn_to_commit.transaction().try_as_block_metadata() {
if let Some(txn) = txn_to_commit.transaction().try_as_block_metadata_ext() {
self.latest_block_timestamp
.fetch_max(txn.timestamp_usecs(), Ordering::Relaxed);
} else if let Some(txn) = txn_to_commit.transaction().try_as_block_metadata() {
self.latest_block_timestamp
.fetch_max(txn.timestamp_usecs(), Ordering::Relaxed);
}
Expand Down

0 comments on commit bd1cc34

Please sign in to comment.