Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor sign_transaction for multiple threads context, #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ test_data_item*
node_modules
dist
/res/gen_bundles/bundle*
bundles.js
bundles.js
.idea
4 changes: 2 additions & 2 deletions src/deep_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use futures::{Stream, TryStream, TryStreamExt};

pub enum DeepHashChunk<'a> {
Chunk(Bytes),
Stream(&'a mut Pin<Box<dyn Stream<Item = anyhow::Result<Bytes>>>>),
Stream(&'a mut Pin<Box<dyn Stream<Item = anyhow::Result<Bytes>> + Send>>),
Chunks(Vec<DeepHashChunk<'a>>),
}

Expand Down Expand Up @@ -60,7 +60,7 @@ pub async fn deep_hash(chunk: DeepHashChunk<'_>) -> Result<Bytes, BundlrError> {
}
}

#[async_recursion(?Send)]
#[async_recursion]
pub async fn deep_hash_chunks(
chunks: &mut Vec<DeepHashChunk<'_>>,
acc: Bytes,
Expand Down
6 changes: 2 additions & 4 deletions src/transaction/bundlr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::utils::read_offset;
enum Data {
None,
Bytes(Vec<u8>),
Stream(Pin<Box<dyn Stream<Item = anyhow::Result<Bytes>>>>),
Stream(Pin<Box<dyn Stream<Item = anyhow::Result<Bytes>> + Send>>),
}

pub struct BundlrTx {
Expand Down Expand Up @@ -281,12 +281,9 @@ impl BundlrTx {
pub async fn sign(&mut self, signer: &dyn Signer) -> Result<(), BundlrError> {
self.signature_type = signer.sig_type();
self.owner = signer.pub_key().to_vec();

let message = self.get_message().await?;

let sig = signer.sign(message)?;
self.signature = sig.to_vec();

Ok(())
}

Expand Down Expand Up @@ -321,6 +318,7 @@ mod tests {
tokio_test::block_on($e)
};
}

#[tokio::test]
async fn test_create_sign_verify_load_ed25519() {
let path = "./res/test_bundles/test_data_item_ed25519";
Expand Down