Skip to content

Commit

Permalink
Merge pull request #9 from bltavares/update-schema
Browse files Browse the repository at this point in the history
Update schema
  • Loading branch information
bltavares authored Feb 19, 2020
2 parents ed9b1df + 4186bb6 commit 68addf1
Show file tree
Hide file tree
Showing 24 changed files with 3,219 additions and 3,352 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Dat Network Protocol protobuf definitions.

Includes a Noise handshake, and is not backwards compatible with Hypercore <= 7

## Installation
```sh
$ cargo add dat-network-protocol
Expand Down
28 changes: 8 additions & 20 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
// Uncomment method below for like local builds.
fn main() -> Result<(), Box<dyn std::error::Error>> {
// protobuf_codegen_pure::run(protobuf_codegen_pure::Args {
// out_dir: "src",
// input: &[
// "protos/cancel.proto",
// "protos/data.proto",
// "protos/data.proto",
// "protos/feed.proto",
// "protos/handshake.proto",
// "protos/have.proto",
// "protos/info.proto",
// "protos/request.proto",
// "protos/unhave.proto",
// "protos/unwant.proto",
// "protos/want.proto",
// ],
// customize: protobuf_codegen_pure::Customize {
// ..Default::default()
// },
// includes: &["protos"],
// })?;
// protobuf_codegen_pure::run(protobuf_codegen_pure::Args {
// out_dir: "src",
// input: &["protos/lib.proto"],
// customize: protobuf_codegen_pure::Customize {
// ..Default::default()
// },
// includes: &["protos"],
// })?;
Ok(())
}
5 changes: 0 additions & 5 deletions protos/cancel.proto

This file was deleted.

12 changes: 0 additions & 12 deletions protos/data.proto

This file was deleted.

4 changes: 0 additions & 4 deletions protos/feed.proto

This file was deleted.

8 changes: 0 additions & 8 deletions protos/handshake.proto

This file was deleted.

5 changes: 0 additions & 5 deletions protos/have.proto

This file was deleted.

4 changes: 0 additions & 4 deletions protos/info.proto

This file was deleted.

87 changes: 87 additions & 0 deletions protos/lib.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
syntax = "proto2";

// Sent as part of the noise protocol.
message NoisePayload {
required bytes nonce = 1;
}

// type=0
message Open {
required bytes discoveryKey = 1;
optional bytes capability = 2;
}

// type=1, overall feed options. can be sent multiple times
message Options {
repeated string extensions = 1; // Should be sorted lexicographically
optional bool ack = 2; // Should all blocks be explicitly acknowledged?
}

// type=2, message indicating state changes etc.
// initial state for uploading/downloading is true
message Status {
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;
optional bool ack = 4; // when true, this Have message is an acknowledgement
}

// 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=10, explicitly close a channel.
message Close {
optional bytes discoveryKey = 1; // only send this if you did not do an open
}

// type=15, extension message
6 changes: 0 additions & 6 deletions protos/request.proto

This file was deleted.

4 changes: 0 additions & 4 deletions protos/unhave.proto

This file was deleted.

4 changes: 0 additions & 4 deletions protos/unwant.proto

This file was deleted.

4 changes: 0 additions & 4 deletions protos/want.proto

This file was deleted.

Loading

0 comments on commit 68addf1

Please sign in to comment.