aboutsummaryrefslogtreecommitdiffstats
path: root/src/network_msgs.proto
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-10-26 21:10:19 -0700
committerBryan Newbold <bnewbold@robocracy.org>2017-10-26 21:10:22 -0700
commit177d639fab67b790f43bc0573d785271d8afb858 (patch)
tree7eaefcfc7bc508e00aa633c80983ed90179f84ec /src/network_msgs.proto
parent594807d6ef0954ff8ca0b99cf41329c0ad3252e7 (diff)
downloadgeniza-177d639fab67b790f43bc0573d785271d8afb858.tar.gz
geniza-177d639fab67b790f43bc0573d785271d8afb858.zip
refactor file/module names
I had some early confusion around whether SLEEP refered to individual files or the collection of files making a register (it seems to mean the whole register). Will probably need to refactor again.
Diffstat (limited to 'src/network_msgs.proto')
-rw-r--r--src/network_msgs.proto81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/network_msgs.proto b/src/network_msgs.proto
new file mode 100644
index 0000000..1b7bc2c
--- /dev/null
+++ b/src/network_msgs.proto
@@ -0,0 +1,81 @@
+// wire format is <len>(<header><message>)
+// header is a varint, channel << 4 | <4-bit-type>
+
+// type=0, should be the first message sent on a channel
+message Feed {
+ required bytes discoveryKey = 1;
+ optional bytes nonce = 2;
+}
+
+// type=1, overall connection handshake. should be send just after the feed message on the first channel only
+message Handshake {
+ optional bytes id = 1;
+ optional bool live = 2; // keep the connection open forever? both ends have to agree
+ optional bytes userData = 3;
+ repeated string extensions = 4;
+}
+
+// type=2, message indicating state changes etc.
+// initial state for uploading/downloading is true
+// if both ends are not downloading and not live it is safe to consider the stream ended
+message Info {
+ optional bool uploading = 1;
+ optional bool downloading = 2;
+}
+
+// type=3, what do we have?
+message Have {
+ required uint64 start = 1;
+ optional uint64 length = 2 [default = 1]; // defaults to 1
+ optional bytes bitfield = 3;
+}
+
+// type=4, what did we lose?
+message Unhave {
+ required uint64 start = 1;
+ optional uint64 length = 2 [default = 1]; // defaults to 1
+}
+
+// type=5, what do we want? remote should start sending have messages in this range
+message Want {
+ required uint64 start = 1;
+ optional uint64 length = 2; // defaults to Infinity or feed.length (if not live)
+}
+
+// type=6, what don't we want anymore?
+message Unwant {
+ required uint64 start = 1;
+ optional uint64 length = 2; // defaults to Infinity or feed.length (if not live)
+}
+
+// type=7, ask for data
+message Request {
+ required uint64 index = 1;
+ optional uint64 bytes = 2;
+ optional bool hash = 3;
+ optional uint64 nodes = 4;
+}
+
+// type=8, cancel a request
+message Cancel {
+ required uint64 index = 1;
+ optional uint64 bytes = 2;
+ optional bool hash = 3;
+}
+
+// type=9, get some data
+message Data {
+ message Node {
+ required uint64 index = 1;
+ required bytes hash = 2;
+ required uint64 size = 3;
+ }
+
+ required uint64 index = 1;
+ optional bytes value = 2;
+ repeated Node nodes = 3;
+ optional bytes signature = 4;
+}
+
+// type=15 (last massage) is an extension message
+// that is encoded like this <varint user-type><payload>