Skip to content

Commit

Permalink
Fix unexpected error with wallet power updates
Browse files Browse the repository at this point in the history
If the power state is updated in the wallet before any Transaction activity occurs there are no subscribers to the broadcast channel which produced an incorrect error.

This PR logs the event but does not send it back across the FFI as an error.
  • Loading branch information
philipr-za committed Jun 15, 2020
1 parent 946068a commit b244b81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 7 additions & 3 deletions base_layer/wallet/src/transaction_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,9 +1228,13 @@ where
PowerMode::Low => self.config.low_power_polling_timeout,
PowerMode::Normal => self.config.base_node_monitoring_timeout,
};
self.timeout_update_publisher
.send(timeout)
.map_err(|_| TransactionServiceError::ProtocolChannelError)?;
if let Err(e) = self.timeout_update_publisher.send(timeout) {
trace!(
target: LOG_TARGET,
"Could not send Timeout update, no subscribers to receive. (Err {:?})",
e
);
}

Ok(())
}
Expand Down
3 changes: 3 additions & 0 deletions base_layer/wallet/tests/transaction_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,9 @@ fn transaction_base_node_monitoring() {
let (_, _, bob_outbound_service, mut bob_tx_sender, _, _, _, _) =
setup_transaction_service_no_comms(&mut runtime, factories.clone(), TransactionMemoryDatabase::new(), None);

runtime.block_on(alice_ts.set_low_power_mode()).unwrap();
runtime.block_on(alice_ts.set_normal_power_mode()).unwrap();

let mut alice_total_available = 250000 * uT;
let (_utxo, uo) = make_input(&mut OsRng, alice_total_available, &factories.commitment);
runtime.block_on(alice_output_manager.add_output(uo)).unwrap();
Expand Down

0 comments on commit b244b81

Please sign in to comment.