Skip to content

Instantly share code, notes, and snippets.

@whyrusleeping
Created July 29, 2014 18:12
Show Gist options
  • Save whyrusleeping/4717c758245df5bf8948 to your computer and use it in GitHub Desktop.
Save whyrusleeping/4717c758245df5bf8948 to your computer and use it in GitHub Desktop.
protobuf message type for dht messages
package dht;
//run `protoc --go_out=. *.proto` to generate
message DHTMessage {
enum MessageType {
PUT_VALUE = 0;
GET_VALUE = 1;
PING = 2;
FIND_NODE = 3;
}
required MessageType type = 1;
optional string key = 2;
optional bytes value = 3;
}
@jbenet
Copy link

jbenet commented Jul 29, 2014

We'll need more message types ( to do the Sloppy part (Coral), Provide/FindProviders in routing/routing.go )

e.g.

message DHTMessage {
  enum MessageType {
    PUT_VALUE = 0;
    GET_VALUE = 1;
    ADD_PROVIDER = 2;
    GET_PROVIDERS = 3;
    FIND_NODE = 4;
    PING = 5;
  }

  required MessageType type = 1;
  optional string key = 2;
  optional bytes value = 3;
}

or something. The PROVIDER stuff is the sloppy put/get, meaning, instead of storing ONE value in the entire DHT, we store a set of values, or rather, a set of peers who can return the value. (if interested, see coral, dhash, mainlineDHT for why this is a good idea). and each item in the set gets put/expires independently. (avoids multiple-writer races, which would be bad if you had to GET -> modify -> PUT the set as a regular, single value)

@jbenet
Copy link

jbenet commented Jul 29, 2014

(we implement both regular PUT/GET and the PROVIDER PUT/GET because some values are small enough to store in the DHT itself (i.e. IPNS mappings) while others are too large (regular objects)

@whyrusleeping
Copy link
Author

Ive updated my type to reflect this and will be pushing it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment