Skip to content

Commit

Permalink
add get dns seeds call
Browse files Browse the repository at this point in the history
  • Loading branch information
SWvheerden committed Feb 27, 2024
1 parent 7eec724 commit ce2a6d7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 29 additions & 1 deletion base_layer/wallet_ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ use tari_common_types::{
};
use tari_comms::{
multiaddr::Multiaddr,
peer_manager::NodeIdentity,
peer_manager::{NodeIdentity, PeerQuery},
transports::MemoryTransport,
types::CommsPublicKey,
};
Expand Down Expand Up @@ -6380,6 +6380,34 @@ pub unsafe extern "C" fn wallet_set_base_node_peer(
true
}

#[no_mangle]
pub unsafe extern "C" fn wallet_get_seed_peers(wallet: *mut TariWallet, error_out: *mut c_int) -> *mut TariPublicKeys {
let mut error = 0;
ptr::swap(error_out, &mut error as *mut c_int);
if wallet.is_null() {
error = LibWalletError::from(InterfaceError::NullError("wallet".to_string())).code;
ptr::swap(error_out, &mut error as *mut c_int);
return ptr::null_mut();
}
let peer_manager = (*wallet).wallet.comms.peer_manager();
let query = PeerQuery::new().select_where(|p| p.is_seed());
match (*wallet).runtime.block_on(async move {
let peers = peer_manager.perform_query(query).await?;
let mut public_keys = Vec::with_capacity(peers.len());
for peer in peers {
public_keys.push(peer.public_key);
}
Result::<_, WalletError>::Ok(public_keys)
}) {
Ok(public_keys) => Box::into_raw(Box::new(TariPublicKeys(public_keys))),
Err(e) => {
error = LibWalletError::from(e).code;
ptr::swap(error_out, &mut error as *mut c_int);
ptr::null_mut()
},
}
}

/// Upserts a TariContact to the TariWallet. If the contact does not exist it will be Inserted. If it does exist the
/// Alias will be updated.
///
Expand Down
2 changes: 2 additions & 0 deletions base_layer/wallet_ffi/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -3000,6 +3000,8 @@ bool wallet_set_base_node_peer(struct TariWallet *wallet,
const char *address,
int *error_out);

struct TariPublicKeys *wallet_get_seed_peers(struct TariWallet *wallet, int *error_out);

/**
* Upserts a TariContact to the TariWallet. If the contact does not exist it will be Inserted. If it does exist the
* Alias will be updated.
Expand Down

0 comments on commit ce2a6d7

Please sign in to comment.