From dfd4bea78cf392eb939cca0c966fb629d3807712 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 11 Nov 2025 23:28:56 -0300 Subject: [PATCH] nip77: fix two negentropy bugs reminiscent of the binary conversation from nostrlib. --- nip77/negentropy/negentropy.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nip77/negentropy/negentropy.go b/nip77/negentropy/negentropy.go index 16cd37d..31966da 100644 --- a/nip77/negentropy/negentropy.go +++ b/nip77/negentropy/negentropy.go @@ -210,7 +210,7 @@ func (n *Negentropy) reconcileAux(reader *bytes.Reader) ([]byte, error) { endBound := currBound for index, item := range n.storage.Range(lower, upper) { - if n.frameSizeLimit-200 < fullOutput.Len()/2+len(responseIds)/2 { + if n.frameSizeLimit-200 < fullOutput.Len()+len(responseIds) { endBound = Bound{item.Timestamp, item.ID[:]} upper = index break @@ -232,7 +232,7 @@ func (n *Negentropy) reconcileAux(reader *bytes.Reader) ([]byte, error) { return nil, fmt.Errorf("unexpected mode %d", mode) } - if n.frameSizeLimit-200 < fullOutput.Len()/2+partialOutput.Len()/2 { + if n.frameSizeLimit-200 < fullOutput.Len()+partialOutput.Len() { // frame size limit exceeded, handle by encoding a boundary and fingerprint for the remaining range remainingFingerprint := n.storage.Fingerprint(upper, n.storage.Size()) n.writeBound(fullOutput, InfiniteBound)