feat: enhance Packet struct with new fields and hash methods for improved functionality

This commit is contained in:
2025-11-20 21:31:24 -06:00
parent 9e7e9a71ca
commit ec8b843cd4

View File

@@ -67,6 +67,7 @@ type Packet struct {
DestinationType byte
DestinationHash []byte
Destination interface{}
TransportID []byte
Data []byte
@@ -85,6 +86,9 @@ type Packet struct {
Q *float64
Addresses []byte
Link interface{}
receipt *PacketReceipt
}
func NewPacket(destType byte, data []byte, packetType byte, context byte,
@@ -221,6 +225,18 @@ func (p *Packet) updateHash() {
p.PacketHash = p.GetHash()
}
func (p *Packet) Hash() []byte {
return p.GetHash()
}
func (p *Packet) TruncatedHash() []byte {
hash := p.GetHash()
if len(hash) >= 16 {
return hash[:16]
}
return hash
}
func (p *Packet) Serialize() ([]byte, error) {
if !p.Packed {
if err := p.Pack(); err != nil {