fix: dont send an empty buffer to bao

This commit is contained in:
Derrick Hammer 2024-03-01 06:23:31 -05:00
parent d5e2770135
commit b272e32185
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 5 deletions

View File

@ -67,12 +67,13 @@ func (v *Verifier) Read(p []byte) (int, error) {
timeStart := time.Now() timeStart := time.Now()
if bytesRead > 0 {
if status, err := bao.Verify(buf[:bytesRead], v.read, v.proof.Proof, v.proof.Hash); err != nil || !status { if status, err := bao.Verify(buf[:bytesRead], v.read, v.proof.Proof, v.proof.Hash); err != nil || !status {
return n, errors.Join(ErrVerifyFailed, err) return n, errors.Join(ErrVerifyFailed, err)
} }
v.read += uint64(bytesRead) v.read += uint64(bytesRead)
v.buffer.Write(buf[:bytesRead]) // Append new data to the buffer v.buffer.Write(buf[:bytesRead]) // Append new data to the buffer
}
timeEnd := time.Now() timeEnd := time.Now()
v.verifyTime += timeEnd.Sub(timeStart) v.verifyTime += timeEnd.Sub(timeStart)