mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-07-05 21:12:10 +02:00
negentropy: fix frameSizeLimit check (was checking against the hex).
This commit is contained in:
@ -205,7 +205,7 @@ func (n *Negentropy) reconcileAux(reader *StringHexReader) (string, error) {
|
|||||||
endBound := currBound
|
endBound := currBound
|
||||||
|
|
||||||
for index, item := range n.storage.Range(lower, upper) {
|
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}
|
endBound = Bound{item}
|
||||||
upper = index
|
upper = index
|
||||||
break
|
break
|
||||||
@ -227,7 +227,7 @@ func (n *Negentropy) reconcileAux(reader *StringHexReader) (string, error) {
|
|||||||
return "", fmt.Errorf("unexpected mode %d", mode)
|
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
|
// frame size limit exceeded, handle by encoding a boundary and fingerprint for the remaining range
|
||||||
remainingFingerprint := n.storage.Fingerprint(upper, n.storage.Size())
|
remainingFingerprint := n.storage.Fingerprint(upper, n.storage.Size())
|
||||||
n.writeBound(fullOutput, InfiniteBound)
|
n.writeBound(fullOutput, InfiniteBound)
|
||||||
|
Reference in New Issue
Block a user