Move decoding code next to encoding code
This commit is contained in:
1 parent
ed9ade05ea
commit
35f57b3ed2
2 files changed
+10
-7
No files matched your search
@@ -241,6 +241,15 @@ func (g *GossipData) Merge(o router.GossipData) {
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GossipData) Decode(msg []byte) error {
|
||||
if err := gob.NewDecoder(bytes.NewReader(msg)).Decode(g); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sort.Sort(CaseInsensitive(g.Entries))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *GossipData) Encode() [][]byte {
|
||||
// Make a copy so we can sort: all outgoing data is sent in case-sensitive order
|
||||
g2 := GossipData{Timestamp: g.Timestamp, Entries: make(Entries, len(g.Entries))}
|
||||
|
||||
Reference in new issue
Block a user