fix: reconcile after a peer push, not only after a pull (#8)

A push-only node — a replica with no peers of its own, which is exactly the
dhg.lol deployment — received observations but never rebuilt entries, so search
returned nothing while the log filled up. The batch handler now signals the
sweep, and reconcile runs when either direction changed the log.
This commit is contained in:
2026-11-04 17:09:04 -08:00
parent cbe42b7900
commit 7b92b411a5
2 changed files with 16 additions and 1 deletions
+8
View File
@@ -31,6 +31,11 @@ type Node struct {
Name string
Addr string // advertised base URL, e.g. http://192.168.1.20:8931
Metrics *metrics.Metrics
// OnIngest runs when a peer's push added observations. Receiving a push
// changes the log just like pulling does, so the caller needs to rebuild
// derived state — otherwise a push-only node (a replica with no peers of
// its own) keeps an empty entries cache.
OnIngest func(inserted int)
}
// pingResponse is the anti-entropy summary returned by /v1/ping.
@@ -126,6 +131,9 @@ func (n *Node) handleBatch(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if inserted > 0 && n.OnIngest != nil {
n.OnIngest(inserted)
}
writeJSON(w, map[string]any{
"accepted": inserted,
"conflict": len(rows) - inserted,