Skip to content

Commit

Permalink
feat(u5c): allow arbitrary request metadata (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega authored Dec 17, 2024
1 parent 6d27528 commit 96c0865
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/sources/u5c.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::HashMap;

use gasket::framework::*;
use pallas::interop::utxorpc::spec::sync::BlockRef;
use pallas::network::miniprotocols::Point;
Expand Down Expand Up @@ -86,11 +88,17 @@ impl gasket::framework::Worker<Stage> for Worker {
async fn bootstrap(stage: &Stage) -> Result<Self, WorkerError> {
debug!("connecting");

let mut client = ClientBuilder::new()
let mut builder = ClientBuilder::new()
.uri(stage.config.url.as_str())
.or_panic()?
.build::<CardanoSyncClient>()
.await;
.or_panic()?;

for (key, value) in stage.config.metadata.iter() {
builder = builder
.metadata(key.to_string(), value.to_string())
.or_panic()?;
}

let mut client = builder.build::<CardanoSyncClient>().await;

let intersect: Vec<_> = if stage.breadcrumbs.is_empty() {
stage.intersect.points().unwrap_or_default()
Expand Down Expand Up @@ -158,6 +166,8 @@ pub struct Stage {
#[derive(Deserialize)]
pub struct Config {
url: String,
metadata: HashMap<String, String>,
#[serde(default)]
use_parsed_blocks: bool,
}

Expand Down

0 comments on commit 96c0865

Please sign in to comment.