Skip to content

Commit

Permalink
feat(serve): implement u5c chain-sync read-tip method (#391)
Browse files Browse the repository at this point in the history
Co-authored-by: gonzalezzfelipe <[email protected]>
  • Loading branch information
scarmuega and gonzalezzfelipe authored Dec 15, 2024
1 parent 74741c2 commit 813c47f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ authors = ["Santiago Carmuega <[email protected]>"]
[dependencies]
pallas = { git = "https://github.com/txpipe/pallas.git", features = ["hardano", "applying"] }
# pallas = { version = "^0.30.1", features = ["hardano", "applying"] }
#pallas = { path = "../pallas/pallas", features = ["hardano", "applying"] }
# pallas = { path = "../pallas/pallas", features = ["hardano", "applying"] }

gasket = { git = "https://github.com/construkts/gasket-rs.git", features = ["derive"] }
# gasket = { version = "^0.8", features = ["derive"] }
Expand Down
22 changes: 19 additions & 3 deletions src/serve/grpc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,24 @@ impl u5c::sync::sync_service_server::SyncService for SyncServiceImpl {

async fn read_tip(
&self,
_: Request<u5c::sync::ReadTipRequest>,
) -> Result<Response<u5c::sync::ReadTipResponse>, tonic::Status> {
todo!()
_request: tonic::Request<u5c::sync::ReadTipRequest>,
) -> std::result::Result<tonic::Response<u5c::sync::ReadTipResponse>, tonic::Status> {
let (_, point) = self
.wal
.find_tip()
.map_err(|_err| Status::internal("can't read WAL"))?
.ok_or(Status::internal("WAL has no data"))?;

let response = u5c::sync::ReadTipResponse {
tip: match point {
ChainPoint::Origin => None,
ChainPoint::Specific(slot, hash) => Some(BlockRef {
index: slot,
hash: hash.to_vec().into(),
}),
},
};

Ok(Response::new(response))
}
}

0 comments on commit 813c47f

Please sign in to comment.