Publish locally-made transactions to peers.

This commit is contained in:
Gav Wood
2016-03-28 18:11:00 +02:00
parent f60d74b231
commit 3023d76a46
4 changed files with 100 additions and 47 deletions

View File

@@ -66,7 +66,7 @@ use std::ops::*;
use std::sync::*;
use util::network::{NetworkProtocolHandler, NetworkService, NetworkContext, PeerId};
use util::TimerToken;
use util::{U256, ONE_U256};
use util::{U256, Bytes, ONE_U256};
use ethcore::client::Client;
use ethcore::service::SyncMessage;
use ethminer::Miner;
@@ -101,6 +101,9 @@ impl Default for SyncConfig {
pub trait SyncProvider: Send + Sync {
/// Get sync status
fn status(&self) -> SyncStatus;
/// Note that a user has submitted a new transaction.
fn new_transaction(&self, raw_transaction: Bytes);
}
/// Ethereum network protocol handler
@@ -140,6 +143,11 @@ impl SyncProvider for EthSync {
fn status(&self) -> SyncStatus {
self.sync.read().unwrap().status()
}
/// Note that a user has submitted a new transaction.
fn new_transaction(&self, raw_transaction: Bytes) {
self.sync.write().unwrap().new_transaction(raw_transaction);
}
}
impl NetworkProtocolHandler<SyncMessage> for EthSync {