2014-08-01 13:21:51 -07:00
|
|
|
package dht
|
|
|
|
|
|
|
|
// A helper struct to make working with protbuf types easier
|
2014-08-08 18:09:21 -07:00
|
|
|
type DHTMessage struct {
|
|
|
|
Type PBDHTMessage_MessageType
|
|
|
|
Key string
|
|
|
|
Value []byte
|
2014-08-01 13:21:51 -07:00
|
|
|
Response bool
|
2014-08-08 18:09:21 -07:00
|
|
|
Id uint64
|
|
|
|
Success bool
|
2014-08-01 13:21:51 -07:00
|
|
|
}
|
|
|
|
|
2014-08-08 18:09:21 -07:00
|
|
|
func (m *DHTMessage) ToProtobuf() *PBDHTMessage {
|
|
|
|
pmes := new(PBDHTMessage)
|
2014-08-01 13:21:51 -07:00
|
|
|
if m.Value != nil {
|
|
|
|
pmes.Value = m.Value
|
|
|
|
}
|
|
|
|
|
|
|
|
pmes.Type = &m.Type
|
|
|
|
pmes.Key = &m.Key
|
|
|
|
pmes.Response = &m.Response
|
|
|
|
pmes.Id = &m.Id
|
2014-08-06 18:37:45 -07:00
|
|
|
pmes.Success = &m.Success
|
2014-08-01 13:21:51 -07:00
|
|
|
|
|
|
|
return pmes
|
|
|
|
}
|