Skip to content

Commit

Permalink
[storage] rename get_txn_by_account -> get_account_transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
phlip9 authored and bors-libra committed Jun 30, 2021
1 parent 21ea569 commit 0572149
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 26 deletions.
20 changes: 10 additions & 10 deletions execution/executor-test-helpers/src/integration_test_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,45 +257,45 @@ pub fn test_execution_with_storage_impl() -> Arc<DiemDB> {

let t1 = db
.reader
.get_txn_by_account(genesis_account, 0, current_version, false)
.get_account_transaction(genesis_account, 0, current_version, false)
.unwrap();
verify_committed_txn_status(t1.as_ref(), &block1[3]).unwrap();

let t2 = db
.reader
.get_txn_by_account(genesis_account, 1, current_version, false)
.get_account_transaction(genesis_account, 1, current_version, false)
.unwrap();
verify_committed_txn_status(t2.as_ref(), &block1[4]).unwrap();

let t3 = db
.reader
.get_txn_by_account(genesis_account, 2, current_version, false)
.get_account_transaction(genesis_account, 2, current_version, false)
.unwrap();
verify_committed_txn_status(t3.as_ref(), &block1[5]).unwrap();

let tn = db
.reader
.get_txn_by_account(genesis_account, 3, current_version, false)
.get_account_transaction(genesis_account, 3, current_version, false)
.unwrap();
assert!(tn.is_none());

let t4 = db
.reader
.get_txn_by_account(account1, 0, current_version, true)
.get_account_transaction(account1, 0, current_version, true)
.unwrap();
verify_committed_txn_status(t4.as_ref(), &block1[6]).unwrap();
// We requested the events to come back from this one, so verify that they did
assert_eq!(t4.unwrap().events.unwrap().len(), 2);

let t5 = db
.reader
.get_txn_by_account(account2, 0, current_version, false)
.get_account_transaction(account2, 0, current_version, false)
.unwrap();
verify_committed_txn_status(t5.as_ref(), &block1[7]).unwrap();

let t6 = db
.reader
.get_txn_by_account(account1, 1, current_version, true)
.get_account_transaction(account1, 1, current_version, true)
.unwrap();
verify_committed_txn_status(t6.as_ref(), &block1[8]).unwrap();

Expand Down Expand Up @@ -397,7 +397,7 @@ pub fn test_execution_with_storage_impl() -> Arc<DiemDB> {

let account4_transaction = db
.reader
.get_txn_by_account(account4, 0, current_version, true)
.get_account_transaction(account4, 0, current_version, true)
.unwrap();
assert!(account4_transaction.is_none());

Expand Down Expand Up @@ -435,13 +435,13 @@ pub fn test_execution_with_storage_impl() -> Arc<DiemDB> {

let t7 = db
.reader
.get_txn_by_account(account1, 2, current_version, false)
.get_account_transaction(account1, 2, current_version, false)
.unwrap();
verify_committed_txn_status(t7.as_ref(), &block2[0]).unwrap();

let t20 = db
.reader
.get_txn_by_account(account1, 15, current_version, false)
.get_account_transaction(account1, 15, current_version, false)
.unwrap();
verify_committed_txn_status(t20.as_ref(), &block2[13]).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion execution/executor/src/fuzzing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl DbReader for FakeDb {
Ok(Some(StartupInfo::new_for_testing()))
}

fn get_txn_by_account(
fn get_account_transaction(
&self,
_address: AccountAddress,
_seq_num: u64,
Expand Down
10 changes: 5 additions & 5 deletions execution/executor/tests/storage_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn test_reconfiguration() {

let t3 = db
.reader
.get_txn_by_account(operator_account, 0, current_version, true)
.get_account_transaction(operator_account, 0, current_version, true)
.unwrap();
verify_committed_txn_status(t3.as_ref(), &txn_block[2]).unwrap();

Expand Down Expand Up @@ -357,13 +357,13 @@ fn test_change_publishing_option_to_custom() {
// Transaction 1 is committed as it's in the allowlist
let txn1 = db
.reader
.get_txn_by_account(treasury_compliance_account, 0, current_version, false)
.get_account_transaction(treasury_compliance_account, 0, current_version, false)
.unwrap();
verify_committed_txn_status(txn1.as_ref(), &block1[0]).unwrap();
// Transaction 2, 3 are rejected
assert!(db
.reader
.get_txn_by_account(validator_account, 0, current_version, false)
.get_account_transaction(validator_account, 0, current_version, false)
.unwrap()
.is_none());

Expand Down Expand Up @@ -407,13 +407,13 @@ fn test_change_publishing_option_to_custom() {
// Transaction 2 is committed.
let txn2 = db
.reader
.get_txn_by_account(validator_account, 0, current_version, false)
.get_account_transaction(validator_account, 0, current_version, false)
.unwrap();
verify_committed_txn_status(txn2.as_ref(), &block2[0]).unwrap();
// Transaction 3 is committed.
let txn3 = db
.reader
.get_txn_by_account(validator_account, 1, current_version, false)
.get_account_transaction(validator_account, 1, current_version, false)
.unwrap();
verify_committed_txn_status(txn3.as_ref(), &block2[1]).unwrap();
}
Expand Down
5 changes: 3 additions & 2 deletions json-rpc/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ pub fn get_account_transaction(
sequence_number: u64,
include_events: bool,
) -> Result<Option<TransactionView>, JsonRpcError> {
let tx = db.get_txn_by_account(account, sequence_number, ledger_version, include_events)?;
let tx =
db.get_account_transaction(account, sequence_number, ledger_version, include_events)?;

if let Some(tx) = tx {
Ok(Some(TransactionView::try_from_tx_and_events(
Expand Down Expand Up @@ -181,7 +182,7 @@ pub fn get_account_transactions(

for seq in start..end {
let tx = db
.get_txn_by_account(account, seq, ledger_version, include_events)?
.get_account_transaction(account, seq, ledger_version, include_events)?
.ok_or_else(|| format_err!("Can not find transaction for seq {}!", seq))?;

let tx_view = TransactionView::try_from_tx_and_events(
Expand Down
2 changes: 1 addition & 1 deletion json-rpc/src/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl DbReader for MockDiemDB {
))
}

fn get_txn_by_account(
fn get_account_transaction(
&self,
address: AccountAddress,
seq_num: u64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl DiemValidatorInterface for DBDebuggerInterface {
) -> Result<Option<Version>> {
Ok(self
.0
.get_txn_by_account(account, seq, self.get_latest_version()?, false)?
.get_account_transaction(account, seq, self.get_latest_version()?, false)?
.map(|info| info.version))
}
}
2 changes: 1 addition & 1 deletion storage/diemdb/src/diemdb_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ fn verify_committed_transactions(
.unwrap();

let txn_with_proof = db
.get_txn_by_account(txn.sender(), txn.sequence_number(), ledger_version, true)
.get_account_transaction(txn.sender(), txn.sequence_number(), ledger_version, true)
.unwrap()
.expect("Should exist.");
txn_with_proof
Expand Down
4 changes: 2 additions & 2 deletions storage/diemdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,14 @@ impl DbReader for DiemDB {

/// Returns a transaction that is the `seq_num`-th one associated with the given account. If
/// the transaction with given `seq_num` doesn't exist, returns `None`.
fn get_txn_by_account(
fn get_account_transaction(
&self,
address: AccountAddress,
seq_num: u64,
ledger_version: Version,
fetch_events: bool,
) -> Result<Option<TransactionWithProof>> {
gauged_api("get_txn_by_account", || {
gauged_api("get_account_transaction", || {
self.transaction_store
.lookup_transaction_by_account(address, seq_num, ledger_version)?
.map(|version| {
Expand Down
2 changes: 1 addition & 1 deletion storage/storage-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl DbReader for StorageClient {
unimplemented!()
}

fn get_txn_by_account(
fn get_account_transaction(
&self,
_address: AccountAddress,
_seq_num: u64,
Expand Down
2 changes: 1 addition & 1 deletion storage/storage-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub trait DbReader: Send + Sync {
/// ../diemdb/struct.DiemDB.html#method.get_startup_info
fn get_startup_info(&self) -> Result<Option<StartupInfo>>;

fn get_txn_by_account(
fn get_account_transaction(
&self,
address: AccountAddress,
seq_num: u64,
Expand Down
2 changes: 1 addition & 1 deletion storage/storage-interface/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl DbReader for MockDbReader {
unimplemented!()
}

fn get_txn_by_account(
fn get_account_transaction(
&self,
_address: AccountAddress,
_seq_num: u64,
Expand Down

0 comments on commit 0572149

Please sign in to comment.