Skip to content

Commit 202007d

Browse files
committed
smoke test writes data
1 parent c4e9a1a commit 202007d

File tree

11 files changed

+370
-126
lines changed

11 files changed

+370
-126
lines changed

Cargo.lock

+71-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ serde = "1.0.217"
2525
postcard = { version = "1.1.1", features = ["experimental-derive", "use-std"] }
2626
data-encoding = "2.8.0"
2727
chrono = "0.4.39"
28+
nested_enum_utils = "0.1.0"
2829

2930
[dev-dependencies]
3031
hex = "0.4.3"

src/api.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use iroh_io::{AsyncStreamReader, TokioStreamReader};
2323
use n0_future::{Stream, StreamExt};
2424
use tokio::io::AsyncWriteExt;
2525

26-
use crate::{proto::*, Store, IROH_BLOCK_SIZE};
26+
use crate::{proto::*, util::Tag, HashAndFormat, Store, IROH_BLOCK_SIZE};
2727

2828
impl Store {
2929
pub fn import_bytes(&self, data: bytes::Bytes) -> ImportResult {
@@ -135,6 +135,24 @@ impl Store {
135135
) -> anyhow::Result<()> {
136136
self.import_bao_reader(hash, ranges, data).await
137137
}
138+
139+
pub async fn set_tag(&self, tag: Tag, value: HashAndFormat) -> anyhow::Result<()> {
140+
self.set_tag_impl(tag, Some(value)).await
141+
}
142+
143+
async fn set_tag_impl(&self, tag: Tag, value: Option<HashAndFormat>) -> anyhow::Result<()> {
144+
let (tx, rx) = tokio::sync::oneshot::channel();
145+
self.sender.send(SetTag { tag, value, tx }.into()).await?;
146+
rx.await??;
147+
Ok(())
148+
}
149+
150+
pub async fn sync_db(&self) -> anyhow::Result<()> {
151+
let (tx, rx) = tokio::sync::oneshot::channel();
152+
self.sender.send(SyncDb { tx }.into()).await?;
153+
rx.await??;
154+
Ok(())
155+
}
138156
}
139157

140158
pub struct ImportResult {

0 commit comments

Comments
 (0)