Validating senders balance before importing transaction to queue
This commit is contained in:
@@ -19,7 +19,7 @@ use std::collections::HashSet;
|
||||
use std::sync::{Arc, Weak, Mutex};
|
||||
use std::ops::Deref;
|
||||
use ethsync::{SyncProvider, SyncState};
|
||||
use ethminer::{MinerService};
|
||||
use ethminer::{MinerService, AccountDetails};
|
||||
use jsonrpc_core::*;
|
||||
use util::numbers::*;
|
||||
use util::sha3::*;
|
||||
@@ -370,7 +370,10 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
|
||||
let signed_transaction = transaction.sign(&secret);
|
||||
let hash = signed_transaction.hash();
|
||||
|
||||
let import = miner.import_transactions(vec![signed_transaction], |a: &Address| client.nonce(a));
|
||||
let import = miner.import_transactions(vec![signed_transaction], |a: &Address| AccountDetails {
|
||||
nonce: client.nonce(a),
|
||||
balance: client.balance(a)
|
||||
});
|
||||
match import {
|
||||
Ok(_) => to_value(&hash),
|
||||
Err(e) => {
|
||||
|
||||
@@ -20,7 +20,7 @@ use ethcore::error::Error;
|
||||
use ethcore::client::BlockChainClient;
|
||||
use ethcore::block::ClosedBlock;
|
||||
use ethcore::transaction::SignedTransaction;
|
||||
use ethminer::{MinerService, MinerStatus};
|
||||
use ethminer::{MinerService, MinerStatus, AccountDetails};
|
||||
|
||||
pub struct TestMinerService;
|
||||
|
||||
@@ -30,7 +30,8 @@ impl MinerService for TestMinerService {
|
||||
fn status(&self) -> MinerStatus { unimplemented!(); }
|
||||
|
||||
/// Imports transactions to transaction queue.
|
||||
fn import_transactions<T>(&self, _transactions: Vec<SignedTransaction>, _fetch_nonce: T) -> Result<(), Error> where T: Fn(&Address) -> U256 { unimplemented!(); }
|
||||
fn import_transactions<T>(&self, _transactions: Vec<SignedTransaction>, _fetch_account: T) -> Result<(), Error>
|
||||
where T: Fn(&Address) -> AccountDetails { unimplemented!(); }
|
||||
|
||||
/// Returns hashes of transactions currently in pending
|
||||
fn pending_transactions_hashes(&self) -> Vec<H256> { unimplemented!(); }
|
||||
@@ -50,4 +51,4 @@ impl MinerService for TestMinerService {
|
||||
/// Submit `seal` as a valid solution for the header of `pow_hash`.
|
||||
/// Will check the seal, but not actually insert the block into the chain.
|
||||
fn submit_seal(&self, _chain: &BlockChainClient, _pow_hash: H256, _seal: Vec<Bytes>) -> Result<(), Error> { unimplemented!(); }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user