Skip to content

Commit

Permalink
small fixes and add the n2c to the workspace properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed Oct 2, 2024
1 parent 986ad84 commit c51600d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
"fraos",
"indexed-log-map",
"multiverse",
"cardano-cli-tools/oura-block-fetcher",
"cardano-cli-tools/n2c-fetcher",
"cardano-cli-tools/cardano-net-fetcher",
]
exclude = [
Expand Down
6 changes: 5 additions & 1 deletion blockchain-source/src/cardano/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,11 @@ async fn block_fetch(
},
}
} else {
todo!();
// this is probably impossible, but handle it as an error just in case
return Err(anyhow::anyhow!(
"Unexpected point in Rollbackward immediately after doing an intersect request"
)
.context(critical_error!()));
};

let (slot, hash) = match raw_header.variant {
Expand Down
1 change: 1 addition & 0 deletions cardano-cli-tools/n2c-fetcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ clap = { version = "4.3.0", features = ["derive"] }
tokio = { version = "1.25.0", features = ["full"] }
dcspark-core = { path = "../../core" }
dcspark-blockchain-source = { path = "../../blockchain-source" }
hex = { version = "0.4.3" }
15 changes: 2 additions & 13 deletions cardano-cli-tools/n2c-fetcher/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
# Oura block fetcher

The tool is needed to fetch Cardano blocks from oura with raw cbor. Example:
```shell
cargo run --bin oura-block-fetcher -- --bearer tcp --since 94542168,9a585e847251b8e1eb41130c53506f3a5ef60213478af4b42b4477f884f86a59 --socket relays-new.cardano-mainnet.iohk.io:3001
```
# Configuration
There are multiple parameters:
* `bearer -- either tcp or unix` - represents the connection type to the node (tcp web / unix socket)
* `since -- slot,block_hash` - starting point
* `socket -- relays-new.cardano-mainnet.iohk.io:3001` - url or path to cardano node unix socket
* `network -- mainnet / testnet / preview / preprod` - network of interest

# Example
`cargo run --bin n2c-fetcher -- --unix_socket socket_path --since 94542168,9a585e847251b8e1eb41130c53506f3a5ef60213478af4b42b4477f884f86a59`
16 changes: 15 additions & 1 deletion cardano-cli-tools/n2c-fetcher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,21 @@ async fn main() -> anyhow::Result<()> {
let mut source = N2CSource::connect(base_config, start_from).await?;

while let Ok(Some(block)) = source.pull(&()).await {
println!("{:?}", block);
match block {
dcspark_blockchain_source::cardano::N2CSourceEvent::RollBack {
block_slot,

Check warning on line 55 in cardano-cli-tools/n2c-fetcher/src/main.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused variable: `block_slot`

Check warning on line 55 in cardano-cli-tools/n2c-fetcher/src/main.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused variable: `block_slot`

Check warning on line 55 in cardano-cli-tools/n2c-fetcher/src/main.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused variable: `block_slot`
block_hash,

Check warning on line 56 in cardano-cli-tools/n2c-fetcher/src/main.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused variable: `block_hash`

Check warning on line 56 in cardano-cli-tools/n2c-fetcher/src/main.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused variable: `block_hash`

Check warning on line 56 in cardano-cli-tools/n2c-fetcher/src/main.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused variable: `block_hash`
} => {}
dcspark_blockchain_source::cardano::N2CSourceEvent::Block(block) => {
println!(
"Block #{}, point: {}@{}, raw cbor hex: {}",
block.block_number,
block.id,
block.slot_number,
hex::encode(block.raw_block),
);
}
}
}

Ok(())
Expand Down

0 comments on commit c51600d

Please sign in to comment.