Skip to content

Commit

Permalink
feat: add wallet ffi backup peers (#6591)
Browse files Browse the repository at this point in the history
Description
---
Added wallet FFI backup peers (all seed peers) when the base node is
set.

Motivation and Context
---
This adds resilience to the base node connection.

How Has This Been Tested?
---
The scheme works for the console wallet, but must be tested with the FFI
in Aurora.

What process can a PR reviewer use to test or verify this change?
---
Code review.

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->
  • Loading branch information
hansieodendaal authored Oct 1, 2024
1 parent 6d998c7 commit 7e07972
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion base_layer/wallet_ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6906,10 +6906,20 @@ pub unsafe extern "C" fn wallet_set_base_node_peer(
}
};

let peer_manager = (*wallet).wallet.comms.peer_manager();
let query = PeerQuery::new().select_where(|p| p.is_seed());
let backup_peers = match (*wallet)
.runtime
.block_on(async move { Result::<_, WalletError>::Ok(peer_manager.perform_query(query).await?) })
{
Ok(peers) => Some(peers),
Err(_) => None,
};

if let Err(e) = (*wallet).runtime.block_on((*wallet).wallet.set_base_node_peer(
(*public_key).clone(),
parsed_addr,
None,
backup_peers,
)) {
error = LibWalletError::from(e).code;
ptr::swap(error_out, &mut error as *mut c_int);
Expand Down

0 comments on commit 7e07972

Please sign in to comment.