diff --git a/nip77/negentropy/negentropy.go b/nip77/negentropy/negentropy.go index 8de50a6..37d0de0 100644 --- a/nip77/negentropy/negentropy.go +++ b/nip77/negentropy/negentropy.go @@ -205,7 +205,7 @@ func (n *Negentropy) reconcileAux(reader *StringHexReader) (string, error) { endBound := currBound for index, item := range n.storage.Range(lower, upper) { - if n.frameSizeLimit-200 < fullOutput.Len()+1+8+responseIds.Len() { + if n.frameSizeLimit-200 < fullOutput.Len()/2+responseIds.Len()/2 { endBound = Bound{item} upper = index break @@ -227,7 +227,7 @@ func (n *Negentropy) reconcileAux(reader *StringHexReader) (string, error) { return "", fmt.Errorf("unexpected mode %d", mode) } - if n.frameSizeLimit-200 < fullOutput.Len()+partialOutput.Len() { + if n.frameSizeLimit-200 <= fullOutput.Len()/2+partialOutput.Len()/2 { // 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)