feat: live mesh peer gossip
When a peer's hello is verified, send a gossip burst of currently connected peers so the new peer can discover and connect to nodes it hasn't met yet — without relying on the anchor for a full peer-join notification for each one. - mesh: add PendingConnect chan for gossip-discovered peer IDs - peer: send gossip burst after hello; push unknown peers from incoming gossip onto PendingConnect (skip self + already-connected) - anchor: drain PendingConnect per runOnce, initiate startOffer for unknown peers using the same lexicographic tiebreak as anchor join; drain goroutine is scoped to the runOnce lifetime to avoid using stale sessions after a reconnect Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,10 @@ type Mesh struct {
|
||||
outbound map[string]*outboundTransfer // xid → pending outbound
|
||||
inbound map[string]*inboundTransfer // xid → pending inbound
|
||||
|
||||
// PendingConnect receives peer IDs discovered via gossip that we should
|
||||
// attempt to connect to. Drained by the anchor client's runOnce loop.
|
||||
PendingConnect chan proto.PeerID
|
||||
|
||||
// subscribers receive a copy of every event (fan-out to IPC clients)
|
||||
subMu sync.Mutex
|
||||
subs []chan proto.IpcMessage
|
||||
@@ -47,11 +51,12 @@ type Mesh struct {
|
||||
// Pass a non-nil store to enable message and peer persistence.
|
||||
func New(id *crypto.Identity, st *store.Store) *Mesh {
|
||||
return &Mesh{
|
||||
Identity: id,
|
||||
Store: st,
|
||||
peers: make(map[proto.PeerID]*PeerConn),
|
||||
outbound: make(map[string]*outboundTransfer),
|
||||
inbound: make(map[string]*inboundTransfer),
|
||||
Identity: id,
|
||||
Store: st,
|
||||
peers: make(map[proto.PeerID]*PeerConn),
|
||||
outbound: make(map[string]*outboundTransfer),
|
||||
inbound: make(map[string]*inboundTransfer),
|
||||
PendingConnect: make(chan proto.PeerID, 32),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user