Skip to content

Commit 2d69683

Browse files
committed
joinstr: initiator role must also send a join request
1 parent 674c69d commit 2d69683

File tree

1 file changed

+7
-2
lines changed
  • rust/joinstr/src/joinstr

1 file changed

+7
-2
lines changed

rust/joinstr/src/joinstr/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct Joinstr<'a> {
3636
pub inner: Arc<Mutex<JoinstrInner<'a>>>,
3737
}
3838

39-
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize)]
39+
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
4040
pub enum Role {
4141
#[default]
4242
Unknown,
@@ -523,15 +523,20 @@ impl Joinstr<'_> {
523523
} else {
524524
return Err(Error::NotYetImplemented);
525525
};
526+
let role = inner.role;
526527
drop(inner);
527528

528529
let mut peers = HashSet::<PublicKey>::new();
529530
let mut coinjoin = CoinJoin::<crate::electrum::Client>::new(payload.denomination, None)
530531
.min_peer(payload.peers)
531532
.fee(fee as usize);
532533

533-
let mut backoff = Backoff::new_us(WAIT);
534+
// FIXME: we should randomize when the initiator send it's join request
535+
if role == Role::Initiator {
536+
self.join_pool()?
537+
}
534538

539+
let mut backoff = Backoff::new_us(WAIT);
535540
// register peers
536541
while (now() < expired) && !(start_early && peers.len() >= payload.peers) {
537542
let mut inner = self.inner.lock().expect("poisoned");

0 commit comments

Comments
 (0)