Skip to content

Commit 96c0865

Browse files
authored
feat(u5c): allow arbitrary request metadata (#833)
1 parent 6d27528 commit 96c0865

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/sources/u5c.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::collections::HashMap;
2+
13
use gasket::framework::*;
24
use pallas::interop::utxorpc::spec::sync::BlockRef;
35
use pallas::network::miniprotocols::Point;
@@ -86,11 +88,17 @@ impl gasket::framework::Worker<Stage> for Worker {
8688
async fn bootstrap(stage: &Stage) -> Result<Self, WorkerError> {
8789
debug!("connecting");
8890

89-
let mut client = ClientBuilder::new()
91+
let mut builder = ClientBuilder::new()
9092
.uri(stage.config.url.as_str())
91-
.or_panic()?
92-
.build::<CardanoSyncClient>()
93-
.await;
93+
.or_panic()?;
94+
95+
for (key, value) in stage.config.metadata.iter() {
96+
builder = builder
97+
.metadata(key.to_string(), value.to_string())
98+
.or_panic()?;
99+
}
100+
101+
let mut client = builder.build::<CardanoSyncClient>().await;
94102

95103
let intersect: Vec<_> = if stage.breadcrumbs.is_empty() {
96104
stage.intersect.points().unwrap_or_default()
@@ -158,6 +166,8 @@ pub struct Stage {
158166
#[derive(Deserialize)]
159167
pub struct Config {
160168
url: String,
169+
metadata: HashMap<String, String>,
170+
#[serde(default)]
161171
use_parsed_blocks: bool,
162172
}
163173

0 commit comments

Comments
 (0)