pDHTMessage.go 408 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
package dht

// A helper struct to make working with protbuf types easier
type pDHTMessage struct {
	Type DHTMessage_MessageType
	Key string
	Value []byte
	Response bool
	Id uint64
}

func (m *pDHTMessage) ToProtobuf() *DHTMessage {
	pmes := new(DHTMessage)
	if m.Value != nil {
		pmes.Value = m.Value
	}

	pmes.Type = &m.Type
	pmes.Key = &m.Key
	pmes.Response = &m.Response
	pmes.Id = &m.Id

	return pmes
}