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

Light client Provide default nonce in transactions when it´s missing #9370

Merged
merged 5 commits into from
Aug 17, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions rpc/src/v1/helpers/light_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use transaction::{Action, Transaction as EthTransaction, SignedTransaction, Loca
use v1::helpers::{CallRequest as CallRequestHelper, errors, dispatch};
use v1::types::{BlockNumber, CallRequest, Log, Transaction};

const NO_INVALID_BACK_REFS: &'static str = "Fails only on invalid back-references; back-references here known to be valid; qed";
const NO_INVALID_BACK_REFS: &str = "Fails only on invalid back-references; back-references here known to be valid; qed";

/// Helper for fetching blockchain data either from the light client or the network
/// as necessary.
Expand Down Expand Up @@ -235,25 +235,25 @@ impl LightFetch {
let action = req.to.map_or(Action::Create, Action::Call);
let value = req.value.unwrap_or_else(U256::zero);
let data = req.data.unwrap_or_default();
let nonce = nonce.unwrap_or_default();

future::done(match (nonce, req.gas) {
(Some(n), Some(gas)) => Ok((true, EthTransaction {
(n, Some(gas)) => Ok((true, EthTransaction {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we avoid the match altogether?

Ok((req.gas.is_some(), EthTransaction {
	gas: req.gas.unwrap_or_else(|| START_GAS.into()),
	...
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that is a good idea thanks!

Makes no sense to match on nonce anymore!

nonce: n,
action: action,
gas: gas,
gas_price: gas_price,
value: value,
data: data,
action,
gas,
gas_price,
value,
data,
})),
(Some(n), None) => Ok((false, EthTransaction {
(n, None) => Ok((false, EthTransaction {
nonce: n,
action: action,
action,
gas: START_GAS.into(),
gas_price: gas_price,
value: value,
data: data,
gas_price,
value,
data,
})),
(None, _) => Err(errors::unknown_block()),
})
}).join(header_fut).and_then(move |((gas_known, tx), hdr)| {
// then request proved execution.
Expand Down