mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-27 12:05:23 +00:00
move wire_encode_locator logic into getBytesForSig, since that's the only place it's used
This commit is contained in:
parent
1e7d34492d
commit
5dc0cb5544
@ -347,11 +347,9 @@ func (p *peer) handleSwitchMsg(packet []byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getBytesForSig(next *sigPubKey, loc *switchLocator) []byte {
|
func getBytesForSig(next *sigPubKey, loc *switchLocator) []byte {
|
||||||
//bs, err := wire_encode_locator(loc)
|
|
||||||
//if err != nil { panic(err) }
|
|
||||||
bs := append([]byte(nil), next[:]...)
|
bs := append([]byte(nil), next[:]...)
|
||||||
bs = append(bs, wire_encode_locator(loc)...)
|
bs = append(bs, loc.root[:]...)
|
||||||
//bs := wire_encode_locator(loc)
|
bs = append(bs, wire_encode_uint64(wire_intToUint(loc.tstamp))...)
|
||||||
//bs = append(next[:], bs...)
|
bs = append(bs, wire_encode_coords(loc.getCoords())...)
|
||||||
return bs
|
return bs
|
||||||
}
|
}
|
||||||
|
@ -170,17 +170,6 @@ func (m *switchMsg) decode(bs []byte) bool {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Format used to check signatures only, so no need to also support decoding
|
|
||||||
// TODO something else for signatures
|
|
||||||
func wire_encode_locator(loc *switchLocator) []byte {
|
|
||||||
coords := wire_encode_coords(loc.getCoords())
|
|
||||||
var bs []byte
|
|
||||||
bs = append(bs, loc.root[:]...)
|
|
||||||
bs = append(bs, wire_encode_uint64(wire_intToUint(loc.tstamp))...)
|
|
||||||
bs = append(bs, coords...)
|
|
||||||
return bs
|
|
||||||
}
|
|
||||||
|
|
||||||
func wire_chop_slice(toSlice []byte, fromSlice *[]byte) bool {
|
func wire_chop_slice(toSlice []byte, fromSlice *[]byte) bool {
|
||||||
if len(*fromSlice) < len(toSlice) {
|
if len(*fromSlice) < len(toSlice) {
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user