deriving ipc service compiling

This commit is contained in:
NikVolf 2016-06-30 01:09:35 +03:00
parent 3c061857c4
commit 8fc03e2dc2
3 changed files with 13 additions and 7 deletions

View File

@ -505,7 +505,7 @@ impl Client {
}
}
//#[derive(Ipc)]
#[derive(Ipc)]
impl BlockChainClient for Client {
fn call(&self, t: &SignedTransaction, analytics: CallAnalytics) -> Result<Executed, ExecutionError> {
let header = self.block_header(BlockID::Latest).unwrap();
@ -690,8 +690,9 @@ impl BlockChainClient for Client {
self.block_queue.queue_info()
}
fn clear_queue(&self) {
fn clear_queue(&self) -> bool {
self.block_queue.clear();
true
}
fn chain_info(&self) -> BlockChainInfo {
@ -808,17 +809,20 @@ impl BlockChainClient for Client {
.collect::<Vec<Result<TransactionImportResult, String>>>()
}
fn queue_transactions(&self, transactions: Vec<Bytes>) {
fn queue_transactions(&self, transactions: Vec<Bytes>) -> bool {
if self.queue_transactions.load(AtomicOrdering::Relaxed) > MAX_TX_QUEUE_SIZE {
debug!("Ignoring {} transactions: queue is full", transactions.len());
false
} else {
let len = transactions.len();
match self.io_channel.send(NetworkIoMessage::User(SyncMessage::NewTransactions(transactions))) {
Ok(_) => {
self.queue_transactions.fetch_add(len, AtomicOrdering::SeqCst);
true
}
Err(e) => {
debug!("Ignoring {} transactions: error queueing: {}", len, e);
false
}
}
}

View File

@ -142,7 +142,7 @@ pub trait BlockChainClient : Sync + Send {
fn queue_info(&self) -> BlockQueueInfo;
/// Clear block queue and abort all import activity.
fn clear_queue(&self);
fn clear_queue(&self) -> bool;
/// Get blockchain information.
fn chain_info(&self) -> BlockChainInfo;
@ -182,7 +182,7 @@ pub trait BlockChainClient : Sync + Send {
fn import_transactions(&self, transactions: Vec<SignedTransaction>) -> Vec<Result<TransactionImportResult, String>>;
/// Queue transactions for importing.
fn queue_transactions(&self, transactions: Vec<Bytes>);
fn queue_transactions(&self, transactions: Vec<Bytes>) -> bool;
/// list all transactions
fn pending_transactions(&self) -> Vec<SignedTransaction>;

View File

@ -455,7 +455,8 @@ impl BlockChainClient for TestBlockChainClient {
}
}
fn clear_queue(&self) {
fn clear_queue(&self) -> bool {
true
}
fn chain_info(&self) -> BlockChainInfo {
@ -498,10 +499,11 @@ impl BlockChainClient for TestBlockChainClient {
.collect::<Vec<Result<TransactionImportResult, String>>>()
}
fn queue_transactions(&self, transactions: Vec<Bytes>) {
fn queue_transactions(&self, transactions: Vec<Bytes>) -> bool {
// import right here
let tx = transactions.into_iter().filter_map(|bytes| UntrustedRlp::new(&bytes).as_val().ok()).collect();
self.import_transactions(tx);
true
}
fn pending_transactions(&self) -> Vec<SignedTransaction> {