Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Delayed transactions #3865

Merged
merged 10 commits into from
Dec 16, 2016
Merged

Delayed transactions #3865

merged 10 commits into from
Dec 16, 2016

Conversation

arkpar
Copy link
Collaborator

@arkpar arkpar commented Dec 15, 2016

Closes #3594

@arkpar arkpar added A0-pleasereview 🤓 Pull request needs code review. B7-releasenotes 📜 Changes should be mentioned in the release notes of the next minor version release. M4-core ⛓ Core client code / Rust. labels Dec 15, 2016
@arkpar arkpar requested a review from tomusdrw December 15, 2016 18:25
Copy link
Collaborator

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

Pretty neat! Couple of minor issues.

@@ -324,7 +329,8 @@ mod tests {
fn should_deserialize_modification() {
// given
let s1 = r#"{
"gasPrice":"0xba43b7400"
"gasPrice":"0xba43b7400",
"minBlock":42
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we encode block numbers as hex almost everywhere, would be good to keep consistency.

@@ -41,6 +41,9 @@ pub struct TransactionRequest {
pub data: Option<Bytes>,
/// Transaction's nonce
pub nonce: Option<U256>,
/// Delay until this block if specified.
#[serde(rename="minBlock")]
pub min_block: Option<u64>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consistency for QUANTITY encoding for block number.

let mut delayed = HashSet::new();
for t in self.current.by_priority.iter() {
let tx = self.by_hash.get(&t.hash).expect("All transactions in `current` and `future` are always included in `by_hash`");
let sender = tx.transaction.sender().expect("Queue only contains transactions with valid sender");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just use tx.sender() it doesn't require the proof.

/// Returns local transactions (some of them might not be part of the queue anymore).
pub fn local_transactions(&self) -> &LinkedHashMap<H256, LocalTransactionStatus> {
self.local_transactions.all_transactions()
fn collect_pending_transaction<F>(&self, best_block: BlockNumber, mut f: F)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't it be better to filter_pending_transactions?

@@ -390,6 +390,34 @@ impl Deref for LocalizedTransaction {
}
}

/// Queued information with additional information.
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Queued information" -> "Queued transaction"

@@ -390,6 +390,34 @@ impl Deref for LocalizedTransaction {
}
}

/// Queued information with additional information.
#[derive(Debug, Clone, PartialEq, Eq, Binary)]
pub struct PendingTransaction {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could implement Deref<Target=SignedTransaction> to get rid of some tx.transaction.<functioncall> statements.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd prefer it to be explicit. Makes the code easier to follow

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 060cc79 on tx-block into ** on master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 060cc79 on tx-block into ** on master**.

/// Signed transaction data.
pub transaction: SignedTransaction,
/// Gas price.
pub min_block: Option<BlockNumber>,
Copy link
Contributor

Choose a reason for hiding this comment

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

comment is wrong

@rphmeier rphmeier added A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Dec 15, 2016
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 060cc79 on tx-block into ** on master**.

@@ -1917,10 +1917,10 @@ impl ChainSync {
return 0;
}

let all_transactions_hashes = transactions.iter().map(|tx| tx.hash()).collect::<HashSet<H256>>();
let all_transactions_hashes = transactions.iter().map(|tx| tx.transaction.hash()).collect::<HashSet<H256>>();
Copy link
Contributor

Choose a reason for hiding this comment

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

does this send out pending transactions, too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

only those that can go into the next block

/// Get a list of all transactions.
fn all_transactions(&self) -> Vec<SignedTransaction>;
/// Get a list of all ready transactions in the queue.
fn all_transactions(&self) -> Vec<PendingTransaction>;
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to ready_transactions to make the intent clear?

@gavofyork
Copy link
Contributor

looks ok, assuming that the pending transactions are indeed not sent out onto the network. would be nice to have one or more test demonstrating the functionality though...

@arkpar arkpar added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. and removed A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. labels Dec 16, 2016
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 6c9de9e on tx-block into ** on master**.

@arkpar arkpar added A0-pleasereview 🤓 Pull request needs code review. and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Dec 16, 2016
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 65f07e5 on tx-block into ** on master**.

@gavofyork gavofyork added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Dec 16, 2016
@gavofyork gavofyork merged commit 83e6e03 into master Dec 16, 2016
@gavofyork gavofyork deleted the tx-block branch December 16, 2016 19:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. B7-releasenotes 📜 Changes should be mentioned in the release notes of the next minor version release. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants