Add runnable node, HTTP API, all-devices revocation and reconnect sync
- cmd/node: init (recovery phrase onboarding), run, recover - api: public reads of canonical signed records, token-protected writes - identity: RevokeAll voids every device certified before a cutoff, so recovery works with only the phrase; store purges by certificate age - p2p: redial bootstrap peers, sync on every new connection (in-flight guard only), validate bootstrap addresses up front - docs: API, recovery semantics, peer-ID change on recovery Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+11
-3
@@ -105,19 +105,27 @@ func (n *Node) handleSync(s network.Stream) {
|
||||
|
||||
// --- client ---------------------------------------------------------------
|
||||
|
||||
// syncSoon schedules a catch-up with p, at most once per resyncInterval.
|
||||
// syncSoon starts a catch-up with p for a new connection. Every genuinely new
|
||||
// connection syncs, so a peer that reconnects after a restart or outage gets
|
||||
// everything it missed. Connections that arrive while a sync with the same
|
||||
// peer is still running (e.g. TCP and QUIC opened together) are collapsed.
|
||||
func (n *Node) syncSoon(p peer.ID) {
|
||||
n.mu.Lock()
|
||||
if last, ok := n.synced[p]; ok && n.clock().Sub(last) < resyncInterval {
|
||||
if n.syncing[p] {
|
||||
n.mu.Unlock()
|
||||
return
|
||||
}
|
||||
n.synced[p] = n.clock()
|
||||
n.syncing[p] = true
|
||||
n.mu.Unlock()
|
||||
|
||||
n.wg.Add(1)
|
||||
go func() {
|
||||
defer n.wg.Done()
|
||||
defer func() {
|
||||
n.mu.Lock()
|
||||
delete(n.syncing, p)
|
||||
n.mu.Unlock()
|
||||
}()
|
||||
ctx, cancel := context.WithTimeout(n.ctx, syncTimeout)
|
||||
defer cancel()
|
||||
if err := n.SyncFrom(ctx, p); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user