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