Skip to content

Commit

Permalink
setup basic PoC watch.proto
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed Sep 8, 2021
1 parent b0f70b8 commit c51fba7
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = [
"cardano-legacy-address",
"sparse-array",
"typed-bytes",
"chain-watch",
]

[profile.bench]
Expand Down
21 changes: 21 additions & 0 deletions chain-watch/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "chain-watch"
version = "0.1.0"
authors = ["Enzo Cioppettini <[email protected]>"]
edition = "2018"

[dependencies]
prost = "0.7"

[dependencies.tonic]
version = "0.4"
default-features = false
features = ["codegen", "prost"]

[build-dependencies.tonic-build]
version = "0.4"
default-features = false
features = ["prost"]

[features]
default = ["tonic/transport", "tonic-build/transport"]
3 changes: 3 additions & 0 deletions chain-watch/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
tonic_build::compile_protos("proto/watch.proto").unwrap();
}
60 changes: 60 additions & 0 deletions chain-watch/proto/watch.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
syntax = "proto3";

package iohk.chain.watch;


message Block {
bytes content = 1;
}

message BlockSubscriptionRequest {}

message TipSubscriptionRequest {}

message MempoolSubscriptionRequest {}

message SyncMultiverseRequest {
// send blocks with this chain_length or greater
uint32 from = 1;
}

message BlockId {
bytes content = 1;
}

message MempoolEvent {
bytes fragment_id = 1;
oneof event {
MempoolFragmentInserted inserted = 2;
MempoolFragmentRejected rejected = 3;
MempoolFragmentInABlock in_a_block = 4;
};
}


message MempoolFragmentInserted {}

message MempoolFragmentRejected {
string reason = 1;
}

message MempoolFragmentInABlock {
BlockId block = 1;
}


service SubscriptionService {
// get a stream of blocks succesfully processed by the node, this means they
// are already validated.
// the parent of a block will always be streamed before the block itself.
rpc BlockSubscription(BlockSubscriptionRequest) returns (stream Block);

// get tip updates
rpc TipSubscription(TipSubscriptionRequest) returns (stream BlockId);

rpc MempoolSubscription(MempoolSubscriptionRequest) returns (stream MempoolEvent);

// fetch all blocks from the given initial chainlength to the tip, from all
// possible branches and in increasing order
rpc SyncMultiverse(SyncMultiverseRequest) returns (stream Block);
}
1 change: 1 addition & 0 deletions chain-watch/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tonic::include_proto!("iohk.chain.watch");

0 comments on commit c51fba7

Please sign in to comment.