From a759c245fbc8b89c3f6ae0d31189daaa9fb802fa Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Tue, 13 Feb 2024 15:21:03 -0500 Subject: [PATCH] Remove duplicate IP length constant (#2733) --- network/peer/ip.go | 2 +- utils/ips/ip_port.go | 2 +- utils/wrappers/packing.go | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/network/peer/ip.go b/network/peer/ip.go index 590003c850d8..11758c2f6073 100644 --- a/network/peer/ip.go +++ b/network/peer/ip.go @@ -44,7 +44,7 @@ func (ip *UnsignedIP) Sign(signer crypto.Signer) (*SignedIP, error) { func (ip *UnsignedIP) bytes() []byte { p := wrappers.Packer{ - Bytes: make([]byte, wrappers.IPLen+wrappers.LongLen), + Bytes: make([]byte, ips.IPPortLen+wrappers.LongLen), } ips.PackIP(&p, ip.IPPort) p.PackLong(ip.Timestamp) diff --git a/utils/ips/ip_port.go b/utils/ips/ip_port.go index a60e6300ed49..eea203525a87 100644 --- a/utils/ips/ip_port.go +++ b/utils/ips/ip_port.go @@ -13,7 +13,7 @@ import ( ) const ( - IPPortLen = 16 + wrappers.ShortLen + IPPortLen = net.IPv6len + wrappers.ShortLen nullStr = "null" ) diff --git a/utils/wrappers/packing.go b/utils/wrappers/packing.go index 96d6b9999c0c..8700ebe1c5ef 100644 --- a/utils/wrappers/packing.go +++ b/utils/wrappers/packing.go @@ -22,8 +22,6 @@ const ( LongLen = 8 // BoolLen is the number of bytes per bool BoolLen = 1 - // IPLen is the number of bytes per IP - IPLen = 16 + ShortLen ) func StringLen(str string) int {