-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[r2r] lightning ordermatching wip + library updates and more unit tests #1655
Changes from 1 commit
3965444
5c94a9f
12f265c
fe0189e
0a9e017
31737cf
65655c7
29536be
f07a9d1
dfa04f0
e64f422
8fdba01
155ff64
d7a0c34
268f2c6
a88e3ea
9f3803e
d37b6cc
9577efc
f7953a7
e683bea
da8d3ad
f92d69a
c5dd404
0daed47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -601,15 +601,40 @@ impl BroadcasterInterface for Platform { | |
let tx_hex = serialize_hex(tx); | ||
debug!("Trying to broadcast transaction: {}", tx_hex); | ||
|
||
let fut = self.coin.send_raw_tx(&tx_hex); | ||
let platform_coin = self.coin.clone(); | ||
let fut = async move { | ||
match fut.compat().await { | ||
Ok(id) => info!("Transaction broadcasted successfully: {:?} ", id), | ||
// TODO: broadcast transaction through p2p network in case of error | ||
Err(e) => error!("Broadcast transaction {} failed: {}", txid, e), | ||
loop { | ||
let bytes = match hex::decode(&tx_hex) { | ||
Ok(b) => b, | ||
Err(e) => { | ||
error!("Converting transaction to bytes error:{}", e); | ||
break; | ||
}, | ||
}; | ||
match platform_coin | ||
.as_ref() | ||
.rpc_client | ||
.send_raw_transaction(bytes.into()) | ||
.compat() | ||
.await | ||
{ | ||
Ok(id) => { | ||
info!("Transaction broadcasted successfully: {:?} ", id); | ||
break; | ||
}, | ||
// Todo: broadcast transaction through p2p network instead in case of error | ||
// Todo: I don't want to rely on p2p broadcasting for now since there is no way to know if there are nodes running bitcoin in native mode or not | ||
// Todo: Also we need to make sure that the transaction was broadcasted after relying on the p2p network | ||
Err(e) => { | ||
error!("Broadcast transaction {} failed: {}", txid, e); | ||
if !e.get_inner().is_network_error() { | ||
break; | ||
} | ||
Timer::sleep(TRY_LOOP_INTERVAL).await; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this loop repeat infinitely if the network error keeps coming? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes for now. When broadcasting transaction through p2p network is implemented, a loop to check if the transaction is on-chain or not can be added instead. |
||
}, | ||
} | ||
} | ||
}; | ||
|
||
self.spawner().spawn(fut); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can take this out of the loop, there's no need to repeat it in case of network failure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done