Basic Dandelion transaction routing (#719)

* Initial Dandelion Commit
* Changed stem_tx_pool to tx_stempool
* Introduction of stem memory pool and stem pool config
* Pool push now send to stem memory pool
* Add stem transaction functions
* Add stem transaction pool
* Drastically simplified code structure
* Add monitor transactions
* Add Dandelion monitor and remove transactions from stempool
* Add peer relay monitor
* Reconcile block with stempool
* Fix total size bug
* Add fluff option for pool push
* Added details on dandelion monitor
* Fix issue with missing parent
* Child transaction with stempool parent are now forced stem
* Update Dandelion Relay from outgoing peers
* Fix missing pool reconciliation
* Add the ability to fluff a transaction directly
* Fix tests for Dandelion
* Missing send_stem_transaction method...
* Add fluff handler for wallet
* Add logger when successfully updated Dandelion relay
* Launch transaction monitor last
* Fix dandelion relay misplaced
* Add logging and updating for stempool
* Additionnal check for stem transaction
* Fix 2 Locks in a row
This commit is contained in:
Quentin Le Sceller
2018-03-19 22:18:54 -05:00
committed by Ignotus Peverell
parent 7816f35238
commit fcfe7bc6a4
24 changed files with 962 additions and 83 deletions
+24 -2
View File
@@ -516,9 +516,10 @@ struct TxWrapper {
tx_hex: String,
}
// Push new transactions to our transaction pool, that should broadcast it
// Push new transactions to our stem transaction pool, that should broadcast it
// to the network if valid.
struct PoolPushHandler<T> {
peers: Weak<p2p::Peers>,
tx_pool: Weak<RwLock<pool::TransactionPool<T>>>,
}
@@ -548,8 +549,28 @@ where
tx.outputs.len()
);
let mut fluff = false;
if let Ok(params) = req.get_ref::<UrlEncodedQuery>() {
if let Some(_) = params.get("fluff") {
fluff = true;
}
}
// Will not do a stem transaction if our dandelion peer relay is empty
if !fluff && w(&self.peers).get_dandelion_relay().is_empty() {
debug!(
LOGGER,
"Missing Dandelion relay: will push stem transaction normally"
);
fluff = true;
}
// Push into the pool or stempool
let pool_arc = w(&self.tx_pool);
let res = pool_arc.write().unwrap().add_to_memory_pool(source, tx);
let res = pool_arc
.write()
.unwrap()
.add_to_memory_pool(source, tx, !fluff);
match res {
Ok(()) => Ok(Response::with(status::Ok)),
@@ -626,6 +647,7 @@ pub fn start_rest_apis<T>(
tx_pool: tx_pool.clone(),
};
let pool_push_handler = PoolPushHandler {
peers: peers.clone(),
tx_pool: tx_pool.clone(),
};
let peers_all_handler = PeersAllHandler {