mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 06:35:07 +03:00
Update API to represent coords as []uint64
This commit is contained in:
parent
37533f157d
commit
3a2ae9d902
6 changed files with 45 additions and 39 deletions
|
@ -115,6 +115,29 @@ func wire_decode_coords(packet []byte) ([]byte, int) {
|
|||
return packet[coordBegin:coordEnd], coordEnd
|
||||
}
|
||||
|
||||
// Converts a []uint64 set of coords to a []byte set of coords.
|
||||
func wire_coordsUint64stoBytes(in []uint64) (out []byte) {
|
||||
for _, coord := range in {
|
||||
c := wire_encode_uint64(coord)
|
||||
out = append(out, c...)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Converts a []byte set of coords to a []uint64 set of coords.
|
||||
func wire_coordsBytestoUint64s(in []byte) (out []uint64) {
|
||||
offset := 0
|
||||
for {
|
||||
coord, length := wire_decode_uint64(in[offset:])
|
||||
if length == 0 {
|
||||
break
|
||||
}
|
||||
out = append(out, coord)
|
||||
offset += length
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Encodes a swtichMsg into its wire format.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue