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 {