Skip to content

Commit

Permalink
db
Browse files Browse the repository at this point in the history
  • Loading branch information
vusirikala committed Dec 10, 2024
1 parent d30a81f commit 6a389ae
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions storage/aptosdb/src/transaction_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ impl TransactionStore {
db_batch.delete::<OrderlessTransactionByAccountSchema>(&(txn.sender(), nonce))?;
}
}
// Question: Should we obtain the version for the transaction and remove the transaction from `TransactionSummariesByAccountSchema`?
}
}
Ok(())
Expand Down
1 change: 1 addition & 0 deletions storage/indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rust-version = { workspace = true }
[dependencies]
anyhow = { workspace = true }
aptos-config = { workspace = true }
aptos-crypto = { workspace = true }
aptos-db-indexer-schemas = { workspace = true }
aptos-logger = { workspace = true }
aptos-metrics-core = { workspace = true }
Expand Down
23 changes: 18 additions & 5 deletions storage/indexer/src/db_indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use aptos_types::{
transaction::{AccountTransactionsWithProof, ReplayProtector, Transaction, Version},
write_set::{TransactionWrite, WriteSet},
};
use aptos_crypto::hash::CryptoHash;
use std::{
cmp::min,
collections::HashSet,
Expand Down Expand Up @@ -449,23 +450,35 @@ impl DBIndexer {
let mut event_keys: HashSet<EventKey> = HashSet::new();
db_iter.try_for_each(|res| {
let (txn, events, writeset) = res?;
if let Some(txn) = txn.try_as_signed_user_txn() {
if let Some(signed_txn) = txn.try_as_signed_user_txn() {
if self.indexer_db.transaction_enabled() {
match txn.replay_protector() {
match signed_txn.replay_protector() {
ReplayProtector::SequenceNumber(seq_num) => {
batch.put::<OrderedTransactionByAccountSchema>(
&(txn.sender(), seq_num),
&(signed_txn.sender(), seq_num),
&version,
)?;
},
ReplayProtector::Nonce(nonce) => {
batch.put::<OrderlessTransactionByAccountSchema>(
&(txn.sender(), nonce),
&(signed_txn.sender(), nonce),
&version,
)?;
},
}

}
if self.indexer_db.transaction_summaries_enabled() {
let txn_summary = IndexedTransactionSummary {
sender: signed_txn.sender(),
replay_protector: signed_txn.replay_protector(),
version,
// Question: Is there anyway to get the hash without recomputing it?
transaction_hash: txn.hash(),
};
batch.put::<TransactionSummariesByAccountSchema>(
&(signed_txn.sender(), version),
&txn_summary,
)?;
}
}

Expand Down

0 comments on commit 6a389ae

Please sign in to comment.