Merge branch 'master' into lightsync

This commit is contained in:
Robert Habermeier
2016-12-19 13:15:37 +01:00
53 changed files with 576 additions and 338 deletions

View File

@@ -21,7 +21,7 @@ use ethcore::block_status::BlockStatus;
use ethcore::ids::BlockId;
use ethcore::header::Header;
use ethcore::verification::queue::{self, HeaderQueue};
use ethcore::transaction::SignedTransaction;
use ethcore::transaction::PendingTransaction;
use ethcore::blockchain_info::BlockChainInfo;
use ethcore::spec::Spec;
use ethcore::service::ClientIoMessage;
@@ -75,7 +75,7 @@ pub trait LightChainClient: Send + Sync {
pub struct Client {
queue: HeaderQueue,
chain: HeaderChain,
tx_pool: Mutex<H256FastMap<SignedTransaction>>,
tx_pool: Mutex<H256FastMap<PendingTransaction>>,
import_lock: Mutex<()>,
}
@@ -96,13 +96,18 @@ impl Client {
}
/// Import a local transaction.
pub fn import_own_transaction(&self, tx: SignedTransaction) {
self.tx_pool.lock().insert(tx.hash(), tx);
pub fn import_own_transaction(&self, tx: PendingTransaction) {
self.tx_pool.lock().insert(tx.transaction.hash(), tx);
}
/// Fetch a vector of all pending transactions.
pub fn pending_transactions(&self) -> Vec<SignedTransaction> {
self.tx_pool.lock().values().cloned().collect()
pub fn ready_transactions(&self) -> Vec<PendingTransaction> {
let best_num = self.chain.best_block().number;
self.tx_pool.lock()
.values()
.filter(|t| t.min_block.as_ref().map_or(true, |x| x <= &best_num))
.cloned()
.collect()
}
/// Inquire about the status of a given header.
@@ -234,7 +239,7 @@ impl Provider for Client {
Vec::new()
}
fn pending_transactions(&self) -> Vec<SignedTransaction> {
Client::pending_transactions(self)
fn ready_transactions(&self) -> Vec<PendingTransaction> {
Client::ready_transactions(self)
}
}

View File

@@ -20,7 +20,7 @@
use ethcore::blockchain_info::BlockChainInfo;
use ethcore::client::{BlockChainClient, EachBlockWith, TestBlockChainClient};
use ethcore::ids::BlockId;
use ethcore::transaction::SignedTransaction;
use ethcore::transaction::PendingTransaction;
use network::{PeerId, NodeId};
use net::buffer_flow::FlowParams;
@@ -169,8 +169,8 @@ impl Provider for TestProvider {
req.requests.into_iter().map(|_| ::rlp::EMPTY_LIST_RLP.to_vec()).collect()
}
fn pending_transactions(&self) -> Vec<SignedTransaction> {
self.0.client.pending_transactions()
fn ready_transactions(&self) -> Vec<PendingTransaction> {
self.0.client.ready_transactions()
}
}

View File

@@ -19,7 +19,7 @@
use ethcore::blockchain_info::BlockChainInfo;
use ethcore::client::{BlockChainClient, ProvingBlockChainClient};
use ethcore::transaction::SignedTransaction;
use ethcore::transaction::PendingTransaction;
use ethcore::ids::BlockId;
use util::{Bytes, H256};
@@ -79,7 +79,7 @@ pub trait Provider: Send + Sync {
fn header_proofs(&self, req: request::HeaderProofs) -> Vec<Bytes>;
/// Provide pending transactions.
fn pending_transactions(&self) -> Vec<SignedTransaction>;
fn ready_transactions(&self) -> Vec<PendingTransaction>;
}
// Implementation of a light client data provider for a client.
@@ -178,7 +178,7 @@ impl<T: ProvingBlockChainClient + ?Sized> Provider for T {
req.requests.into_iter().map(|_| ::rlp::EMPTY_LIST_RLP.to_vec()).collect()
}
fn pending_transactions(&self) -> Vec<SignedTransaction> {
BlockChainClient::pending_transactions(self)
fn ready_transactions(&self) -> Vec<PendingTransaction> {
BlockChainClient::ready_transactions(self)
}
}
}