Skip to content

Commit

Permalink
[refactor] #3887 Hide an internal structure of the versioned structs …
Browse files Browse the repository at this point in the history
…from the public API.

Signed-off-by: Stukalov-A-M <[email protected]>
  • Loading branch information
Stukalov-A-M committed Feb 13, 2024
1 parent 39fb088 commit 7501abe
Show file tree
Hide file tree
Showing 25 changed files with 345 additions and 341 deletions.
14 changes: 2 additions & 12 deletions client/benches/tps/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,8 @@ impl Config {
.next()
.expect("The block is not yet in WSV. Need more sleep?");
(
block
.payload()
.transactions
.iter()
.filter(|tx| tx.error.is_none())
.count(),
block
.payload()
.transactions
.iter()
.filter(|tx| tx.error.is_some())
.count(),
block.transactions().filter(|tx| tx.error.is_none()).count(),
block.transactions().filter(|tx| tx.error.is_some()).count(),
)
})
.fold((0, 0), |acc, pair| (acc.0 + pair.0, acc.1 + pair.1));
Expand Down
16 changes: 8 additions & 8 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ impl Client {
transaction: &SignedTransaction,
) -> Result<HashOf<TransactionPayload>> {
let (init_sender, init_receiver) = tokio::sync::oneshot::channel();
let hash = transaction.payload().hash();
let hash = transaction.hash_of_payload();

thread::scope(|spawner| {
let submitter_handle = spawner.spawn(move || -> Result<()> {
Expand Down Expand Up @@ -673,7 +673,7 @@ impl Client {
)
.headers(self.headers.clone())
.body(transaction_bytes),
transaction.payload().hash(),
transaction.hash_of_payload(),
)
}

Expand Down Expand Up @@ -1627,16 +1627,16 @@ mod tests {
|| client.build_transaction(Vec::<InstructionBox>::new(), UnlimitedMetadata::new());
let tx1 = build_transaction();
let tx2 = build_transaction();
assert_ne!(tx1.payload().hash(), tx2.payload().hash());
assert_ne!(tx1.hash_of_payload(), tx2.hash_of_payload());

let tx2 = {
let mut tx =
TransactionBuilder::new(client.chain_id.clone(), client.account_id.clone())
.with_executable(tx1.payload().instructions.clone())
.with_metadata(tx1.payload().metadata.clone());
.with_executable(tx1.instructions().clone())
.with_metadata(tx1.metadata().clone());

tx.set_creation_time(tx1.payload().creation_time_ms);
if let Some(nonce) = tx1.payload().nonce {
tx.set_creation_time(tx1.creation_time().as_millis().try_into().unwrap());
if let Some(nonce) = tx1.nonce() {
tx.set_nonce(nonce);
}
if let Some(transaction_ttl) = client.transaction_ttl {
Expand All @@ -1645,7 +1645,7 @@ mod tests {

client.sign_transaction(tx)
};
assert_eq!(tx1.payload().hash(), tx2.payload().hash());
assert_eq!(tx1.hash_of_payload(), tx2.hash_of_payload());
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion client/tests/integration/events/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn test_with_instruction_and_status_and_port(
// Given
let submitter = client;
let transaction = submitter.build_transaction(instruction, UnlimitedMetadata::new());
let hash = transaction.payload().hash();
let hash = transaction.hash_of_payload();
let mut handles = Vec::new();
for listener in clients {
let checker = Checker { listener, hash };
Expand Down
6 changes: 3 additions & 3 deletions client/tests/integration/tx_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ fn client_has_rejected_and_acepted_txs_should_return_tx_history() -> Result<()>

let mut prev_creation_time = core::time::Duration::from_millis(0);
for tx in &transactions {
assert_eq!(tx.payload().authority(), &account_id);
assert_eq!(tx.as_ref().authority(), &account_id);
//check sorted
assert!(tx.payload().creation_time() >= prev_creation_time);
prev_creation_time = tx.payload().creation_time();
assert!(tx.as_ref().creation_time() >= prev_creation_time);
prev_creation_time = tx.as_ref().creation_time();
}
Ok(())
}
2 changes: 1 addition & 1 deletion core/benches/blocks/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn create_block(
.unwrap();

// Verify that transactions are valid
for tx in &block.payload().transactions {
for tx in block.as_ref().transactions() {
assert_eq!(tx.error, None);
}

Expand Down
Loading

0 comments on commit 7501abe

Please sign in to comment.