Skip to content

Commit

Permalink
feat: extraction from faithful
Browse files Browse the repository at this point in the history
Signed-off-by: Wilfred Almeida <[email protected]>
  • Loading branch information
WilfredAlmeida committed Jun 4, 2024
0 parents commit 4afbc12
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "old-faithful-proto"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
prost = { workspace = true }
tonic = { workspace = true }

[build-dependencies]
anyhow = { workspace = true }
protobuf-src = { workspace = true }
tonic-build = { workspace = true }
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() -> anyhow::Result<()> {
std::env::set_var("PROTOC", protobuf_src::protoc());
tonic_build::compile_protos("proto/old-faithful.proto")?;
Ok(())
}
46 changes: 46 additions & 0 deletions proto/old-faithful.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
syntax = "proto3";

package OldFaithful;

service OldFaithful {
rpc GetVersion(VersionRequest) returns (VersionResponse);

rpc GetBlock(BlockRequest) returns (BlockResponse);
rpc GetTransaction(TransactionRequest) returns (TransactionResponse);
}

message VersionRequest {}

message VersionResponse {
string version = 1;
}

message BlockRequest {
uint64 slot = 1;
}

message BlockResponse {
bytes previous_blockhash = 1;
bytes blockhash = 2;
uint64 parent_slot = 3;
uint64 slot = 4;
int64 block_time = 5;
uint64 block_height = 6;
repeated Transaction transactions = 7;
repeated bytes rewards = 8;
}

message TransactionRequest {
bytes signature = 1;
}

message TransactionResponse {
Transaction transaction = 1;
uint64 slot = 2;
int64 block_time = 3;
}

message Transaction {
bytes transaction = 1;
bytes meta = 2; // bincode or protobuf
}
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub use {prost, tonic};

pub mod proto {
tonic::include_proto!("old_faithful");
}

0 comments on commit 4afbc12

Please sign in to comment.