dht.proto 2.2 KB
Newer Older
George Antoniadis's avatar
George Antoniadis committed
1 2 3 4 5 6 7
// In order to re-generate the golang packages for `Message` you will need...
// 1. Protobuf binary (tested with protoc 3.0.0). - https://github.com/gogo/protobuf/releases
// 2. Gogo Protobuf (tested with gogo 0.3). - https://github.com/gogo/protobuf
// 3. To have cloned `libp2p/go-libp2p-{record,kad-dht}` under the same directory.
// Now from `libp2p/go-libp2p-kad-dht/pb` you can run...
// `protoc --gogo_out=. --proto_path=../../go-libp2p-record/pb/ --proto_path=./ dht.proto`

8
syntax = "proto3";
9
package dht.pb;
10

11
import "github.com/libp2p/go-libp2p-record/pb/record.proto";
Steven Allen's avatar
Steven Allen committed
12
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
13

14
message Message {
15 16 17
	enum MessageType {
		PUT_VALUE = 0;
		GET_VALUE = 1;
18 19 20 21
		ADD_PROVIDER = 2;
		GET_PROVIDERS = 3;
		FIND_NODE = 4;
		PING = 5;
22 23
	}

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
	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;
	}

39
	message Peer {
40
		// ID of a given peer.
Steven Allen's avatar
Steven Allen committed
41
		bytes id = 1 [(gogoproto.customtype) = "byteString", (gogoproto.nullable) = false];
42 43

		// multiaddrs for a given peer
44
		repeated bytes addrs = 2;
45 46

		// used to signal the sender's connection capabilities to the peer
47
		ConnectionType connection = 3;
48 49
	}

50
	// defines what type of message it is.
51
	MessageType type = 1;
52 53

	// defines what coral cluster level this query/response belongs to.
54
	// in case we want to implement coral's cluster rings in the future.
55
	int32 clusterLevelRaw = 10;
56 57 58

	// Used to specify the key associated with this message.
	// PUT_VALUE, GET_VALUE, ADD_PROVIDER, GET_PROVIDERS
59
	bytes key = 2;
60

61 62
	// Used to return a value
	// PUT_VALUE, GET_VALUE
63
	record.pb.Record record = 3;
64

65 66
	// Used to return peers closer to a key in a query
	// GET_VALUE, GET_PROVIDERS, FIND_NODE
Steven Allen's avatar
Steven Allen committed
67
	repeated Peer closerPeers = 8 [(gogoproto.nullable) = false];
68

69 70
	// Used to return Providers
	// GET_VALUE, ADD_PROVIDER, GET_PROVIDERS
Steven Allen's avatar
Steven Allen committed
71
	repeated Peer providerPeers = 9 [(gogoproto.nullable) = false];
72
}