(n uint64)
| 20 | } |
| 21 | |
| 22 | func VariableNatEncode(n uint64) []byte { |
| 23 | o := []byte{byte(n) & 0x7f} |
| 24 | n /= 128 |
| 25 | for n > 0 { |
| 26 | o = append(o, byte(n&0x7f)|0x80) |
| 27 | n /= 128 |
| 28 | } |
| 29 | for i, j := 0, len(o)-1; i < j; i, j = i+1, j-1 { |
| 30 | o[i], o[j] = o[j], o[i] |
| 31 | } |
| 32 | return o |
| 33 | } |
| 34 | |
| 35 | func VariableNatDecode(bytes []byte) (uint64, int, bool) { |
| 36 | var output uint64 |
no outgoing calls