Skip to content

Conversation

@pavel-mukhanov
Copy link
Contributor

Overview

Added tx_cache to store incoming transactions.


Definition of Done

  • There are no TODOs left in the merged code
  • Change is covered by automated tests
  • Benchmark results are attached (if applicable)
  • The coding guidelines are followed
  • Public API has proper documentation
  • Changelog is updated if needed (in case of notable or breaking changes)
  • The continuous integration build passes

ValidatorId::zero(),
Height(height),
txs,
&mut BTreeMap::new(),
Copy link
Contributor

@aleksuss aleksuss Jul 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
&mut BTreeMap::new(),
None,

I suppose BTreeMap::new is not free operation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@aleksuss aleksuss Jul 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, cheap but not like Option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code with BtreeMap::new is used only in benchmarks or tests. It doesn't affect the production code. But adding Option will result in unnecessary unwraps.

@codecov
Copy link

codecov bot commented Jul 30, 2019

Codecov Report

Merging #1398 into master will increase coverage by 0.04%.
The diff coverage is 96.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1398      +/-   ##
==========================================
+ Coverage   93.74%   93.79%   +0.04%     
==========================================
  Files         165      165              
  Lines       25653    25884     +231     
==========================================
+ Hits        24049    24277     +228     
- Misses       1604     1607       +3
Impacted Files Coverage Δ
testkit/tests/system_api.rs 100% <ø> (ø) ⬆️
exonum/src/events/mod.rs 88.23% <ø> (ø) ⬆️
exonum/src/node/mod.rs 92.78% <100%> (+0.02%) ⬆️
exonum/src/api/node/public/system.rs 83.78% <100%> (+0.68%) ⬆️
exonum/src/blockchain/transaction.rs 92.73% <100%> (+0.12%) ⬆️
exonum/src/node/consensus.rs 89.79% <100%> (+0.29%) ⬆️
exonum/src/blockchain/tests.rs 92.73% <100%> (+0.12%) ⬆️
exonum/src/messages/authorization.rs 98.71% <100%> (ø) ⬆️
exonum/src/node/state.rs 93.68% <100%> (+0.97%) ⬆️
exonum/src/sandbox/mod.rs 95.25% <100%> (+0.04%) ⬆️
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 10451e1...0f61ec7. Read the comment docs.

alekseysidorov
alekseysidorov previously approved these changes Jul 31, 2019
pub(crate) fn commit_transaction(&mut self, hash: &Hash) {
self.transactions_pool().remove(hash);
pub(crate) fn commit_transaction(&mut self, hash: &Hash, tx: Signed<RawTransaction>) {
if !self.transactions().contains(hash) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a very clear case, what means if we are trying to commit a transaction that is not in self.transactions()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because now we have transactions that stored only in cache during the round and added to storage after commit(or before the node is stopped).


/// Return transaction from persistent pool. If transaction is not present in pool, try
/// to return it from transactions cache.
pub fn get_tx<T: IndexAccess>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this helper function is public?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason, I will change this.

let db = create_database(path);
let service_keypair = gen_keypair();
let api_channel = mpsc::unbounded();
let api_channel = mpsc::channel(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

channel(0) is more useful, in my opinion.

blockchain.create_patch(
ValidatorId::zero(),
Height(height),
txs,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think that we have to unify this to arguments by the single trait TransactionsSource with the good interface in future.

aleksuss
aleksuss previously approved these changes Aug 5, 2019
@aleksuss aleksuss dismissed their stale review August 5, 2019 10:43

Need tiny change

@aleksuss aleksuss merged commit 219aa2c into exonum:master Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants