Browse Source
Sync before withdrawing from the wallet
Implying `Sync` as part of withdraw allows us to remove the `Sync`
from the startup of the application which avoids an error case in
case we cannot find a particular transaction.
chore/bump-maia
Thomas Eizinger
3 years ago
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96
3 changed files with
6 additions and
8 deletions
daemon/src/maker.rs
daemon/src/taker.rs
daemon/src/wallet.rs
@ -168,9 +168,6 @@ async fn main() -> Result<()> {
. run ( ) ;
let _wallet_handle = wallet_fut . spawn_with_handle ( ) ;
// do this before withdraw to ensure the wallet is synced
let wallet_info = wallet . send ( wallet ::Sync ) . await ? ? ;
if let Some ( Withdraw ::Withdraw {
amount ,
address ,
@ -204,7 +201,7 @@ async fn main() -> Result<()> {
"ddd4636845a90185991826be5a494cde9f4a6947b1727217afedc6292fa4caf7" ,
) ? ;
let ( wallet_feed_sender , wallet_feed_receiver ) = watch ::channel ( Some ( wallet_info ) ) ;
let ( wallet_feed_sender , wallet_feed_receiver ) = watch ::channel ( None ) ;
let figment = rocket ::Config ::figment ( )
. merge ( ( "address" , opts . http_address . ip ( ) ) )
@ -179,9 +179,6 @@ async fn main() -> Result<()> {
. run ( ) ;
let _wallet_handle = wallet_fut . spawn_with_handle ( ) ;
// do this before withdraw to ensure the wallet is synced
let wallet_info = wallet . send ( wallet ::Sync ) . await ? ? ;
if let Some ( Withdraw ::Withdraw {
amount ,
address ,
@ -204,7 +201,7 @@ async fn main() -> Result<()> {
"ddd4636845a90185991826be5a494cde9f4a6947b1727217afedc6292fa4caf7" ,
) ? ;
let ( wallet_feed_sender , wallet_feed_receiver ) = watch ::channel ( Some ( wallet_info ) ) ;
let ( wallet_feed_sender , wallet_feed_receiver ) = watch ::channel ( None ) ;
let mut tasks = Tasks ::default ( ) ;
@ -178,6 +178,10 @@ impl Actor {
}
pub fn handle_withdraw ( & mut self , msg : Withdraw ) -> Result < Txid > {
self . wallet
. sync ( NoopProgress , None )
. context ( "Failed to sync wallet" ) ? ;
if msg . address . network ! = self . wallet . network ( ) {
bail ! (
"Address has invalid network. It was {} but the wallet is connected to {}" ,