Skip to content
Snippets Groups Projects
Unverified Commit 293044f9 authored by Levente Pap's avatar Levente Pap
Browse files

Add comments

parent da974700
No related branches found
No related tags found
No related merge requests found
...@@ -68,7 +68,7 @@ func init() { ...@@ -68,7 +68,7 @@ func init() {
} }
} }
// ParseHeartbeat parses a slice of bytes into a heartbeat. // ParseHeartbeat parses a slice of bytes (serialized packet) into a heartbeat.
func ParseHeartbeat(data []byte) (*Heartbeat, error) { func ParseHeartbeat(data []byte) (*Heartbeat, error) {
// check minimum size // check minimum size
if len(data) < HeartbeatPacketMinSize { if len(data) < HeartbeatPacketMinSize {
...@@ -129,6 +129,7 @@ func ParseHeartbeat(data []byte) (*Heartbeat, error) { ...@@ -129,6 +129,7 @@ func ParseHeartbeat(data []byte) (*Heartbeat, error) {
} }
// NewHeartbeatMessage serializes the given heartbeat into a byte slice and adds a tlv header to the packet. // NewHeartbeatMessage serializes the given heartbeat into a byte slice and adds a tlv header to the packet.
// message = tlv header + serialized packet
func NewHeartbeatMessage(hb *Heartbeat) ([]byte, error) { func NewHeartbeatMessage(hb *Heartbeat) ([]byte, error) {
if len(hb.InboundIDs) > HeartbeatMaxInboundPeersCount { if len(hb.InboundIDs) > HeartbeatMaxInboundPeersCount {
return nil, fmt.Errorf("%w: heartbeat exceeds maximum inbound IDs of %d", ErrInvalidHeartbeat, HeartbeatMaxInboundPeersCount) return nil, fmt.Errorf("%w: heartbeat exceeds maximum inbound IDs of %d", ErrInvalidHeartbeat, HeartbeatMaxInboundPeersCount)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment