mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
add metric to metadata exchange, but currently left at default 0 value
This commit is contained in:
parent
6bc2044ced
commit
58af92812e
2 changed files with 9 additions and 1 deletions
|
@ -14,6 +14,7 @@ type version_metadata struct {
|
|||
ver uint8 // 1 byte in this version
|
||||
// Everything after this point potentially depends on the version number, and is subject to change in future versions
|
||||
minorVer uint8 // 1 byte in this version
|
||||
metric uint8 // 1 byte in this version
|
||||
key ed25519.PublicKey
|
||||
}
|
||||
|
||||
|
@ -31,6 +32,7 @@ func version_getMetaLength() (mlen int) {
|
|||
mlen += 4 // meta
|
||||
mlen++ // ver, as long as it's < 127, which it is in this version
|
||||
mlen++ // minorVer, as long as it's < 127, which it is in this version
|
||||
mlen++ // metric
|
||||
mlen += ed25519.PublicKeySize // key
|
||||
return
|
||||
}
|
||||
|
@ -41,6 +43,7 @@ func (m *version_metadata) encode() []byte {
|
|||
bs = append(bs, m.meta[:]...)
|
||||
bs = append(bs, m.ver)
|
||||
bs = append(bs, m.minorVer)
|
||||
bs = append(bs, m.metric)
|
||||
bs = append(bs, m.key[:]...)
|
||||
if len(bs) != version_getMetaLength() {
|
||||
panic("Inconsistent metadata length")
|
||||
|
@ -57,6 +60,7 @@ func (m *version_metadata) decode(bs []byte) bool {
|
|||
offset += copy(m.meta[:], bs[offset:])
|
||||
m.ver, offset = bs[offset], offset+1
|
||||
m.minorVer, offset = bs[offset], offset+1
|
||||
m.metric, offset = bs[offset], offset+1
|
||||
m.key = append([]byte(nil), bs[offset:]...)
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue