FIX:
* Cleaned up some documentation
This commit is contained in:
brent saner
2024-07-10 00:40:12 -04:00
parent d4bb259b83
commit 9b39811206
8 changed files with 30 additions and 25 deletions

View File

@@ -34,7 +34,7 @@ func (r *Request) MarshalBinary() (data []byte, err error) {
msgSize += i.Size()
}
// The message "body" - we do this first so we can checksum (if not nil).
// The message "body" - this is done first so the body can be checksummed (if not nil).
if _, err = msgBuf.Write(hdrBODYSTART); err != nil {
return
}
@@ -307,14 +307,14 @@ func (r *Request) UnmarshalBinary(data []byte) (err error) {
}
r.Checksum = new(uint32)
*r.Checksum = byteOrder.Uint32(b)
// Since we've only read the checksum, we now also have to read in the MSGSTART...
// Since only the checksum has been read, now read the MSGSTART...
b = make([]byte, len(hdrMSGSTART))
if _, err = buf.Read(b); err != nil {
return
}
// But we don't need to do anything with it.
// But don't need to do anything with it.
} else {
// We've already read MSGSTART as part of the checksum check.
// MSGSTART has already been read as part of the checksum check.
r.Checksum = nil
}
@@ -362,7 +362,7 @@ func (r *Request) UnmarshalBinary(data []byte) (err error) {
}
}
// Now that we've validated the checksum (if provided), we trim the msgBuf to only RGs.
// Now that the checksum (if provided) has validated, trim the msgBuf to only RGs.
// Skip over the BODYSTART, record group count, and record group size.
if _, err = msgBuf.Read(make([]byte, len(hdrBODYSTART)+(PackedNumSize*2))); err != nil {
return
@@ -375,7 +375,7 @@ func (r *Request) UnmarshalBinary(data []byte) (err error) {
for idx := 0; idx < rgCnt; idx++ {
rgBuf = new(bytes.Buffer)
// The RG unmarshaler handles the record count, but we need to read it to discard it in msgBuf.
// The RG unmarshaler handles the record count, but it needs to be put in msgBuf to do that.
if _, err = io.CopyN(rgBuf, msgBuf, int64(PackedNumSize)); err != nil {
return
}