2014-10-25 04:13:28 -07:00
|
|
|
package dht.pb;
|
2014-07-28 22:14:27 -07:00
|
|
|
|
|
|
|
//run `protoc --go_out=. *.proto` to generate
|
|
|
|
|
2014-09-16 00:52:57 -07:00
|
|
|
message Message {
|
2014-07-28 22:14:27 -07:00
|
|
|
enum MessageType {
|
|
|
|
PUT_VALUE = 0;
|
|
|
|
GET_VALUE = 1;
|
2014-07-29 14:50:33 -07:00
|
|
|
ADD_PROVIDER = 2;
|
|
|
|
GET_PROVIDERS = 3;
|
|
|
|
FIND_NODE = 4;
|
|
|
|
PING = 5;
|
2014-07-28 22:14:27 -07:00
|
|
|
}
|
|
|
|
|
2014-11-20 10:46:56 -08:00
|
|
|
enum ConnectionType {
|
|
|
|
// sender does not have a connection to peer, and no extra information (default)
|
|
|
|
NOT_CONNECTED = 0;
|
|
|
|
|
|
|
|
// sender has a live connection to peer
|
|
|
|
CONNECTED = 1;
|
|
|
|
|
|
|
|
// sender recently connected to peer
|
|
|
|
CAN_CONNECT = 2;
|
|
|
|
|
|
|
|
// sender recently tried to connect to peer repeatedly but failed to connect
|
|
|
|
// ("try" here is loose, but this should signal "made strong effort, failed")
|
|
|
|
CANNOT_CONNECT = 3;
|
|
|
|
}
|
|
|
|
|
2014-09-16 00:52:57 -07:00
|
|
|
message Peer {
|
2014-11-20 10:46:56 -08:00
|
|
|
// ID of a given peer.
|
2014-10-15 12:30:52 -07:00
|
|
|
optional string id = 1;
|
2014-11-20 10:46:56 -08:00
|
|
|
|
|
|
|
// multiaddrs for a given peer
|
2014-12-19 12:19:56 -08:00
|
|
|
repeated bytes addrs = 2;
|
2014-11-20 10:46:56 -08:00
|
|
|
|
|
|
|
// used to signal the sender's connection capabilities to the peer
|
|
|
|
optional ConnectionType connection = 3;
|
2014-08-08 18:09:21 -07:00
|
|
|
}
|
|
|
|
|
2014-09-16 00:52:57 -07:00
|
|
|
// defines what type of message it is.
|
2014-10-15 12:30:52 -07:00
|
|
|
optional MessageType type = 1;
|
2014-09-16 00:52:57 -07:00
|
|
|
|
|
|
|
// defines what coral cluster level this query/response belongs to.
|
|
|
|
optional int32 clusterLevelRaw = 10;
|
|
|
|
|
|
|
|
// Used to specify the key associated with this message.
|
|
|
|
// PUT_VALUE, GET_VALUE, ADD_PROVIDER, GET_PROVIDERS
|
2014-07-28 22:14:27 -07:00
|
|
|
optional string key = 2;
|
2014-07-30 17:46:56 -07:00
|
|
|
|
2014-09-16 00:52:57 -07:00
|
|
|
// Used to return a value
|
|
|
|
// PUT_VALUE, GET_VALUE
|
2014-11-09 23:45:16 -08:00
|
|
|
optional Record record = 3;
|
2014-07-30 17:46:56 -07:00
|
|
|
|
2014-09-16 00:52:57 -07:00
|
|
|
// Used to return peers closer to a key in a query
|
|
|
|
// GET_VALUE, GET_PROVIDERS, FIND_NODE
|
|
|
|
repeated Peer closerPeers = 8;
|
2014-08-08 18:09:21 -07:00
|
|
|
|
2014-09-16 00:52:57 -07:00
|
|
|
// Used to return Providers
|
|
|
|
// GET_VALUE, ADD_PROVIDER, GET_PROVIDERS
|
|
|
|
repeated Peer providerPeers = 9;
|
2014-07-28 22:14:27 -07:00
|
|
|
}
|
2014-11-09 23:45:16 -08:00
|
|
|
|
|
|
|
// Record represents a dht record that contains a value
|
|
|
|
// for a key value pair
|
|
|
|
message Record {
|
|
|
|
// The key that references this record
|
|
|
|
optional string key = 1;
|
|
|
|
|
|
|
|
// The actual value this record is storing
|
|
|
|
optional bytes value = 2;
|
|
|
|
|
|
|
|
// hash of the authors public key
|
|
|
|
optional string author = 3;
|
|
|
|
|
|
|
|
// A PKI signature for the key+value+author
|
|
|
|
optional bytes signature = 4;
|
2015-10-01 15:02:22 -07:00
|
|
|
|
|
|
|
// Time the record was received, set by receiver
|
|
|
|
optional string timeReceived = 5;
|
2014-11-09 23:45:16 -08:00
|
|
|
}
|