mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 11:28:59 +00:00
Humanize serialization of version vectors
This commit is contained in:
parent
aaa75a32a5
commit
6f95afdc59
@ -10,6 +10,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"encoding/base32"
|
||||||
|
"encoding/binary"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -1138,8 +1140,11 @@ type jsonVersionVector protocol.Vector
|
|||||||
|
|
||||||
func (v jsonVersionVector) MarshalJSON() ([]byte, error) {
|
func (v jsonVersionVector) MarshalJSON() ([]byte, error) {
|
||||||
res := make([]string, len(v))
|
res := make([]string, len(v))
|
||||||
|
bs := make([]byte, 8)
|
||||||
for i, c := range v {
|
for i, c := range v {
|
||||||
res[i] = fmt.Sprintf("%d:%d", c.ID, c.Value)
|
binary.BigEndian.PutUint64(bs, c.ID)
|
||||||
|
id := base32.StdEncoding.EncodeToString(bs)
|
||||||
|
res[i] = fmt.Sprintf("%s:%d", id[:7], c.Value)
|
||||||
}
|
}
|
||||||
return json.Marshal(res)
|
return json.Marshal(res)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user