Merge pull request #746 from ethcore/tx_queue
Verify sender's 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::*;
|
||||
@@ -381,7 +381,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) => {
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use util::{Address, H256, U256, Bytes};
|
||||
use util::{Address, H256, Bytes};
|
||||
use util::standard::*;
|
||||
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 {
|
||||
pub imported_transactions: RwLock<Vec<H256>>,
|
||||
@@ -48,7 +48,8 @@ impl MinerService for TestMinerService {
|
||||
}
|
||||
|
||||
/// 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!(); }
|
||||
|
||||
Reference in New Issue
Block a user