Fix dht find value and updates from latest protocol changes #90
1 changed files with 15 additions and 0 deletions
|
@ -2,6 +2,7 @@ package dht
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
@ -41,6 +42,20 @@ func (c Contact) String() string {
|
|||
return str
|
||||
}
|
||||
|
||||
func (c Contact) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(&struct {
|
||||
ID string
|
||||
IP string
|
||||
Port int
|
||||
PeerPort int
|
||||
}{
|
||||
ID: c.ID.Hex(),
|
||||
IP: c.IP.String(),
|
||||
Port: c.Port,
|
||||
PeerPort: c.PeerPort,
|
||||
})
|
||||
}
|
||||
|
||||
// MarshalCompact returns a compact byteslice representation of the contact
|
||||
// NOTE: The compact representation always uses the tcp PeerPort, not the udp Port. This is dumb, but that's how the python daemon does it
|
||||
func (c Contact) MarshalCompact() ([]byte, error) {
|
||||
|
|
Loading…
Reference in a new issue