-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Removing transactions that failed to be pushed to block. #752
Conversation
let gas_limit = *b.block().header().gas_limit(); | ||
let mut gas_left = gas_limit; | ||
let mut invalid_transactions = HashSet::new(); | ||
|
||
for tx in transactions { |
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.
Stop when gas_left < min transaction gas (21000). There should be a constant for it in the Schedule I believe
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.
Done.
@@ -132,7 +132,20 @@ impl MinerService for Miner { | |||
self.extra_data(), | |||
transactions, | |||
); | |||
*self.sealing_block.lock().unwrap() = b; | |||
|
|||
match b { |
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.
could be done more succinctly as:
*self.sealing_block.lock().unwrap() = b.map(|x| {
let (block, invalid_transactions) = x;
let mut queue ...
block
});
no?
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.
True - in this case it looks much better. However in general I'm trying to avoid side effects in map
.
|
||
// TODO [todr] It seems that calculating gas_left here doesn't look nice. After moving this function | ||
// to miner crate we should consider rewriting this logic in some better way. | ||
if tx.gas > gas_left { |
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.
any reason to duplicate this check here rather than just checking import
later?
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.
Right, I guess it would be possible to unwrap error, check if it's BlockGasLimitReached
, check minimal transaction gas.
Will refactor, because calculating gas here is not particularly appealing.
Removing transactions that failed to be pushed to block.
trace
message)