Push generated transactions together in a batch.

This commit is contained in:
c0gent 2018-11-01 07:16:08 -07:00
parent e358806491
commit 41298be329
No known key found for this signature in database
GPG Key ID: 9CC25E71A743E892
1 changed files with 8 additions and 10 deletions

View File

@ -396,7 +396,7 @@ impl<T: Contribution> Hydrabadger<T> {
/// messages. /// messages.
fn generate_txns_status( fn generate_txns_status(
self, self,
gen_txns: Option<fn(usize, usize) -> Vec<T>>, gen_txns: Option<fn(usize, usize) -> T>,
) -> impl Future<Item = (), Error = ()> { ) -> impl Future<Item = (), Error = ()> {
Interval::new( Interval::new(
Instant::now(), Instant::now(),
@ -443,14 +443,12 @@ impl<T: Contribution> Hydrabadger<T> {
self.inner.config.txn_gen_bytes, self.inner.config.txn_gen_bytes,
); );
for txn in txns {
hdb.send_internal(InternalMessage::hb_input( hdb.send_internal(InternalMessage::hb_input(
hdb.inner.uid, hdb.inner.uid,
OutAddr(*hdb.inner.addr), OutAddr(*hdb.inner.addr),
DhbInput::User(txn), DhbInput::User(txns),
)); ));
} }
}
_ => {} _ => {}
} }
} }
@ -464,7 +462,7 @@ impl<T: Contribution> Hydrabadger<T> {
pub fn node( pub fn node(
self, self,
remotes: Option<HashSet<SocketAddr>>, remotes: Option<HashSet<SocketAddr>>,
gen_txns: Option<fn(usize, usize) -> Vec<T>>, gen_txns: Option<fn(usize, usize) -> T>,
) -> impl Future<Item = (), Error = ()> { ) -> impl Future<Item = (), Error = ()> {
let socket = TcpListener::bind(&self.inner.addr).unwrap(); let socket = TcpListener::bind(&self.inner.addr).unwrap();
info!("Listening on: {}", self.inner.addr); info!("Listening on: {}", self.inner.addr);
@ -507,7 +505,7 @@ impl<T: Contribution> Hydrabadger<T> {
pub fn run_node( pub fn run_node(
self, self,
remotes: Option<HashSet<SocketAddr>>, remotes: Option<HashSet<SocketAddr>>,
gen_txns: Option<fn(usize, usize) -> Vec<T>>, gen_txns: Option<fn(usize, usize) -> T>,
) { ) {
tokio::run(self.node(remotes, gen_txns)); tokio::run(self.node(remotes, gen_txns));
} }