dht.proto 2.01 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";
12

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

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

38
	message Peer {
39
		// ID of a given peer.
40
		bytes id = 1;
41 42

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

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

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

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

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

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

64 65 66
	// Used to return peers closer to a key in a query
	// GET_VALUE, GET_PROVIDERS, FIND_NODE
	repeated Peer closerPeers = 8;
67

68 69 70
	// Used to return Providers
	// GET_VALUE, ADD_PROVIDER, GET_PROVIDERS
	repeated Peer providerPeers = 9;
71
}