-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Transaction timestamp condition #4419
Conversation
ethcore/src/types/transaction.rs
Outdated
#[derive(Debug, Clone, PartialEq, Eq)] | ||
#[cfg_attr(feature = "ipc", binary)] | ||
/// Transaction activation condition. | ||
pub enum Condition { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: doc over attrs
use ethcore; | ||
|
||
/// Represents rpc api block number param. | ||
#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doc seems outdated
pub min_block: Option<BlockNumber>, | ||
/// Delay until this block condition. | ||
#[serde(rename="condition")] | ||
pub condition: Option<TransactionCondition>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename no longer necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks, good tiny documentation issues.
@@ -277,16 +278,16 @@ struct VerifiedTransaction { | |||
/// Insertion time | |||
insertion_time: QueuingInstant, | |||
/// Delay until specifid block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment not updated
rpc/src/v1/types/confirmations.rs
Outdated
@@ -197,8 +197,8 @@ pub struct TransactionModification { | |||
/// Modified gas | |||
pub gas: Option<U256>, | |||
/// Modified min block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment & rename not needed.
if tx.min_block.unwrap_or(0) > best_block { | ||
let delay = match tx.condition { | ||
Some(Condition::Number(n)) => n > best_block, | ||
Some(Condition::Timestamp(t)) => t > time::get_time().sec as u64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be based off of the best block's timestamp rather than current time, since that's all that contracts can inspect. It's additionally often set into the future and not consistent with "real" time, but can be agreed upon unanimously just like block numbers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for the block timestamp would result in transactions included no in the first available block, but in the next one. But at least the transaction is guaranteed not to fail, so I guess that's reasonable
.filter(|t| t.min_block.as_ref().map_or(true, |x| x <= &best_num)) | ||
.filter(|t| match t.condition { | ||
Some(TransactionCondition::Number(ref x)) => x <= &best_num, | ||
Some(TransactionCondition::Timestamp(ref x)) => *x <= time::get_time().sec as u64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this condition check needs updating as well. probably would be best done after changing HeaderChain
to use ethcore::encoded
(done locally).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given that it's "dead" code I don't mind merging this PR without it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll leave it to you then :)
No description provided.