From f70da4ba3968574ca9c6ef8a5b33ae6260bb4ae7 Mon Sep 17 00:00:00 2001 From: Bastien Laguionie <bastien@localhost.localdomain> Date: Fri, 27 Mar 2020 22:59:56 +0100 Subject: [PATCH] [opt] Replaced vec usage with SmallVec for Issuers, Signatures, Inputs, Unlocks and outputs fields in user documents --- Cargo.lock | 8 ++++ lib/dubp/block-doc/Cargo.toml | 3 +- lib/dubp/block-doc/src/block.rs | 5 ++- lib/dubp/block-doc/src/block/v10.rs | 23 ++++++------ lib/dubp/block-doc/src/parser.rs | 13 ++++--- lib/dubp/common-doc/Cargo.toml | 1 + lib/dubp/common-doc/src/traits.rs | 5 ++- lib/dubp/user-docs/Cargo.toml | 1 + .../user-docs/src/documents/certification.rs | 5 ++- .../src/documents/certification/v10.rs | 17 +++++---- lib/dubp/user-docs/src/documents/identity.rs | 5 ++- .../user-docs/src/documents/identity/v10.rs | 17 +++++---- .../user-docs/src/documents/membership.rs | 5 ++- .../user-docs/src/documents/membership/v10.rs | 17 +++++---- lib/dubp/user-docs/src/documents/mod.rs | 37 ++++++++++--------- .../user-docs/src/documents/revocation.rs | 5 ++- .../user-docs/src/documents/revocation/v10.rs | 18 +++++---- .../user-docs/src/documents/transaction.rs | 5 ++- .../src/documents/transaction/v10.rs | 35 +++++++++--------- lib/modules/gva/Cargo.toml | 1 + lib/modules/gva/src/schema/queries/block.rs | 3 +- lib/modules/gva/src/schema/queries/blocks.rs | 11 +++--- lib/modules/gva/src/schema/queries/current.rs | 3 +- lib/tests-tools/blocks-tests-tools/Cargo.toml | 1 + .../blocks-tests-tools/src/mocks.rs | 17 +++++---- 25 files changed, 147 insertions(+), 114 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 17699ad0..108ac19c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -788,6 +788,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "smallvec", "unwrap", ] @@ -805,6 +806,7 @@ dependencies = [ "durs-common-tools", "failure", "json-pest-parser", + "smallvec", ] [[package]] @@ -822,6 +824,7 @@ dependencies = [ "serde", "serde_json", "shrinkwraprs", + "smallvec", "unwrap", ] @@ -869,6 +872,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "smallvec", "unwrap", ] @@ -1130,6 +1134,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "smallvec", "structopt", ] @@ -2791,6 +2796,9 @@ name = "smallvec" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" +dependencies = [ + "serde", +] [[package]] name = "socket2" diff --git a/lib/dubp/block-doc/Cargo.toml b/lib/dubp/block-doc/Cargo.toml index d7754fc6..7fcdce07 100644 --- a/lib/dubp/block-doc/Cargo.toml +++ b/lib/dubp/block-doc/Cargo.toml @@ -16,7 +16,7 @@ path = "src/lib.rs" dubp-common-doc = { path = "../common-doc"} #, version = "0.1.0" } dubp-currency-params = { path = "../currency-params", version = "0.2.0" } dubp-user-docs = { path = "../user-docs", version = "0.14.0" } -dup-crypto = "0.8.4" +dup-crypto = {version = "0.8.4"} durs-common-tools = { path = "../../tools/common-tools", version = "0.2.0" } failure = "0.1.5" json-pest-parser = { path = "../../tools/json-pest-parser", version = "0.2.0" } @@ -27,6 +27,7 @@ serde_derive = "1.0.*" serde_json = "1.0.*" log = "0.4.*" unwrap = "1.2.1" +smallvec = {version = "1.0.0", features = ["serde"]} [dev-dependencies] pretty_assertions = "0.6.1" diff --git a/lib/dubp/block-doc/src/block.rs b/lib/dubp/block-doc/src/block.rs index 136f8ada..af17fde6 100644 --- a/lib/dubp/block-doc/src/block.rs +++ b/lib/dubp/block-doc/src/block.rs @@ -23,6 +23,7 @@ use dubp_common_doc::{BlockHash, BlockNumber}; use dup_crypto::hashs::Hash; use dup_crypto::keys::{PubKey, PublicKey, SignatorEnum}; use durs_common_tools::UsizeSer32; +use smallvec::SmallVec; pub use v10::{BlockDocumentV10, BlockDocumentV10Stringified}; @@ -246,13 +247,13 @@ impl Document for BlockDocument { } } - fn issuers(&self) -> &Vec<Self::PublicKey> { + fn issuers(&self) -> &SmallVec<[Self::PublicKey; 4]> { match self { BlockDocument::V10(block) => block.issuers(), } } - fn signatures(&self) -> &Vec<<Self::PublicKey as PublicKey>::Signature> { + fn signatures(&self) -> &SmallVec<[<Self::PublicKey as PublicKey>::Signature; 4]> { match self { BlockDocument::V10(block) => block.signatures(), } diff --git a/lib/dubp/block-doc/src/block/v10.rs b/lib/dubp/block-doc/src/block/v10.rs index 024f1df2..c3434130 100644 --- a/lib/dubp/block-doc/src/block/v10.rs +++ b/lib/dubp/block-doc/src/block/v10.rs @@ -37,6 +37,7 @@ use dubp_user_docs::documents::transaction::v10::{ use dup_crypto::hashs::Hash; use dup_crypto::keys::*; use durs_common_tools::{fatal_error, UsizeSer32}; +use smallvec::{smallvec, SmallVec}; use unwrap::unwrap; /// Wrap a Block document. @@ -71,10 +72,10 @@ pub struct BlockDocumentV10 { /// Currency. pub currency: CurrencyName, /// Document issuer (there should be only one). - pub issuers: Vec<PubKey>, + pub issuers: SmallVec<[PubKey; 4]>, /// Document signature (there should be only one). /// This vector is empty, when the block is generated but the proof of work has not yet started - pub signatures: Vec<Sig>, + pub signatures: SmallVec<[Sig; 4]>, /// The hash is None, when the block is generated but the proof of work has not yet started pub hash: Option<BlockHash>, /// Currency parameters (only in genesis block) @@ -317,7 +318,7 @@ Transactions:{transactions} } } fn sign(&mut self, signator: &SignatorEnum) { - self.signatures = vec![signator.sign(self.compute_will_signed_string().as_bytes())]; + self.signatures = smallvec![signator.sign(self.compute_will_signed_string().as_bytes())]; } fn verify_inner_hash(&self) -> Result<(), VerifyBlockHashError> { match self.inner_hash { @@ -390,12 +391,12 @@ impl Document for BlockDocumentV10 { } #[inline] - fn issuers(&self) -> &Vec<PubKey> { + fn issuers(&self) -> &SmallVec<[Self::PublicKey; 4]> { &self.issuers } #[inline] - fn signatures(&self) -> &Vec<Sig> { + fn signatures(&self) -> &SmallVec<[Sig; 4]> { &self.signatures } @@ -615,8 +616,8 @@ mod tests { issuers_frame: UsizeSer32(41), issuers_frame_var: 0, currency: CurrencyName(String::from("g1-test")), - issuers: vec![PubKey::Ed25519(unwrap!(ed25519::PublicKey::from_base58("39Fnossy1GrndwCnAXGDw3K5UYXhNXAFQe7yhYZp8ELP"), "Fail to build PublicKey from base58"))], - signatures: vec![Sig::Ed25519(unwrap!(ed25519::Signature::from_base64("lqXrNOopjM39oM7hgB7Vq13uIohdCuLlhh/q8RVVEZ5UVASphow/GXikCdhbWID19Bn0XrXzTbt/R7akbE9xAg=="), "Fail to build Signature from base64"))], + issuers: smallvec![PubKey::Ed25519(unwrap!(ed25519::PublicKey::from_base58("39Fnossy1GrndwCnAXGDw3K5UYXhNXAFQe7yhYZp8ELP"), "Fail to build PublicKey from base58"))], + signatures: smallvec![Sig::Ed25519(unwrap!(ed25519::Signature::from_base64("lqXrNOopjM39oM7hgB7Vq13uIohdCuLlhh/q8RVVEZ5UVASphow/GXikCdhbWID19Bn0XrXzTbt/R7akbE9xAg=="), "Fail to build Signature from base64"))], hash: None, parameters: None, previous_hash: Some(Hash::from_hex("0000A7D4361B9EBF4CE974A521149A73E8A5DE9B73907AB3BC918726AED7D40A").expect("fail to parse previous_hash")), @@ -716,8 +717,8 @@ a9PHPuSfw7jW8FRQHXFsGi/bnLjbtDnTYvEVgUC9u0WlR7GVofa+Xb+l5iy6NwuEXiwvueAkf08wPVY8 issuers_frame: UsizeSer32(211), issuers_frame_var: 0, currency: CurrencyName(String::from("g1")), - issuers: vec![PubKey::Ed25519(unwrap!(ed25519::PublicKey::from_base58("DA4PYtXdvQqk1nCaprXH52iMsK5Ahxs1nRWbWKLhpVkQ"), "Fail to build PublicKey from base58"))], - signatures: vec![Sig::Ed25519(unwrap!(ed25519::Signature::from_base64("92id58VmkhgVNee4LDqBGSm8u/ooHzAD67JM6fhAE/CV8LCz7XrMF1DvRl+eRpmlaVkp6I+Iy8gmZ1WUM5C8BA=="), "Fail to build Signature from base64"))], + issuers: smallvec![PubKey::Ed25519(unwrap!(ed25519::PublicKey::from_base58("DA4PYtXdvQqk1nCaprXH52iMsK5Ahxs1nRWbWKLhpVkQ"), "Fail to build PublicKey from base58"))], + signatures: smallvec![Sig::Ed25519(unwrap!(ed25519::Signature::from_base64("92id58VmkhgVNee4LDqBGSm8u/ooHzAD67JM6fhAE/CV8LCz7XrMF1DvRl+eRpmlaVkp6I+Iy8gmZ1WUM5C8BA=="), "Fail to build Signature from base64"))], hash: None, parameters: None, previous_hash: Some(Hash::from_hex("000001144968D0C3516BE6225E4662F182E28956AF46DD7FB228E3D0F9413FEB").expect("fail to parse previous_hash")), @@ -896,8 +897,8 @@ nxr4exGrt16jteN9ZX3XZPP9l+X0OUbZ1o/QjE1hbWQNtVU3HhH9SJoEvNj2iVl3gCRr9u2OA9uj9vCy issuers_frame: UsizeSer32(186), issuers_frame_var: 0, currency: CurrencyName(String::from("g1")), - issuers: vec![PubKey::Ed25519(unwrap!(ed25519::PublicKey::from_base58("A4pc9Uuk4NXkWG8CibicjjPpEPdiup1mhjMoRWUZsonq"), "Fail to build PublicKey from base58"))], - signatures: vec![Sig::Ed25519(unwrap!(ed25519::Signature::from_base64("2Z/+9ADdZvHXs19YR8+qDzgfl8WJlBG5PcbFvBG9TOuUJbjAdxhcgxrFrSRIABGWcCrIgLkB805fZVLP8jOjBA=="), "Fail to build Signature from base64"))], + issuers: smallvec![PubKey::Ed25519(unwrap!(ed25519::PublicKey::from_base58("A4pc9Uuk4NXkWG8CibicjjPpEPdiup1mhjMoRWUZsonq"), "Fail to build PublicKey from base58"))], + signatures: smallvec![Sig::Ed25519(unwrap!(ed25519::Signature::from_base64("2Z/+9ADdZvHXs19YR8+qDzgfl8WJlBG5PcbFvBG9TOuUJbjAdxhcgxrFrSRIABGWcCrIgLkB805fZVLP8jOjBA=="), "Fail to build Signature from base64"))], hash: None, parameters: None, previous_hash: Some(Hash::from_hex("000003E78FA4133F2C13B416F330C8DFB5A41EB87E37190615DB334F2C914A51").expect("fail to parse previous_hash")), diff --git a/lib/dubp/block-doc/src/parser.rs b/lib/dubp/block-doc/src/parser.rs index 7fb52d9a..eace6341 100644 --- a/lib/dubp/block-doc/src/parser.rs +++ b/lib/dubp/block-doc/src/parser.rs @@ -27,6 +27,7 @@ use dup_crypto::keys::*; use durs_common_tools::UsizeSer32; use failure::Error; use json_pest_parser::*; +use smallvec::smallvec; use std::convert::TryFrom; use std::str::FromStr; @@ -64,10 +65,10 @@ pub fn parse_json_block(json_block: &JSONValue<DefaultHasher>) -> Result<BlockDo issuers_frame: UsizeSer32(get_u64(json_block, "issuersFrame")? as usize), issuers_frame_var: get_number(json_block, "issuersFrameVar")?.trunc() as isize, currency: CurrencyName(currency.to_owned()), - issuers: vec![PubKey::Ed25519(ed25519::PublicKey::from_base58(get_str( + issuers: smallvec![PubKey::Ed25519(ed25519::PublicKey::from_base58(get_str( json_block, "issuer", )?)?)], - signatures: vec![Sig::Ed25519(ed25519::Signature::from_base64(get_str( + signatures: smallvec![Sig::Ed25519(ed25519::Signature::from_base64(get_str( json_block, "signature", )?)?)], @@ -185,11 +186,11 @@ mod tests { issuers_frame: UsizeSer32(6), issuers_frame_var: 0, currency: CurrencyName("g1".to_owned()), - issuers: vec![PubKey::Ed25519( + issuers: smallvec![PubKey::Ed25519( ed25519::PublicKey::from_base58("2ny7YAdmzReQxAayyJZsyVYwYhVyax2thKcGknmQy5nQ") .expect("Fail to parse issuer !") )], - signatures: vec![Sig::Ed25519( + signatures: smallvec![Sig::Ed25519( ed25519::Signature::from_base64("xaWNjdFeE4yr9+AKckgR6QuAvMzmKUWfY+uIlC3HKjn2apJqG70Gf59A71W+Ucz6E9WPXRzDDF/xOrf6GCGHCA==").expect("Fail to parse sig !") )], hash: Some(BlockHash( @@ -306,11 +307,11 @@ mod tests { issuers_frame: UsizeSer32(6), issuers_frame_var: 0, currency: CurrencyName("g1".to_owned()), - issuers: vec![PubKey::Ed25519( + issuers: smallvec![PubKey::Ed25519( ed25519::PublicKey::from_base58("2ny7YAdmzReQxAayyJZsyVYwYhVyax2thKcGknmQy5nQ") .expect("Fail to parse issuer !") )], - signatures: vec![Sig::Ed25519( + signatures: smallvec![Sig::Ed25519( ed25519::Signature::from_base64("4/UIwXzWQekbYw7fpD8ueMH4GnDEwCM+DvDaTfquBXOvFXLRYo/S+Vrk5u7so/98gYaZ2O7Myh20xgQvhh5FDQ==").expect("Fail to parse sig !") )], hash: Some(BlockHash( diff --git a/lib/dubp/common-doc/Cargo.toml b/lib/dubp/common-doc/Cargo.toml index 8a20f8fc..39729b86 100644 --- a/lib/dubp/common-doc/Cargo.toml +++ b/lib/dubp/common-doc/Cargo.toml @@ -24,6 +24,7 @@ serde_json = "1.0.*" shrinkwraprs = "0.3.*" log = "0.4.*" unwrap = "1.2.1" +smallvec = "1.0.0" [dev-dependencies] pretty_assertions = "0.6.1" diff --git a/lib/dubp/common-doc/src/traits.rs b/lib/dubp/common-doc/src/traits.rs index 9bbfee58..1b4074f6 100644 --- a/lib/dubp/common-doc/src/traits.rs +++ b/lib/dubp/common-doc/src/traits.rs @@ -22,6 +22,7 @@ use crate::errors::DocumentSigsErr; use dup_crypto::keys::*; use durs_common_tools::UsizeSer32; use serde::Serialize; +use smallvec::SmallVec; use std::collections::HashMap; use std::fmt::Debug; @@ -45,7 +46,7 @@ pub trait Document: Debug + Clone + PartialEq + Eq { fn currency(&self) -> &str; /// Iterate over document issuers. - fn issuers(&self) -> &Vec<Self::PublicKey>; + fn issuers(&self) -> &SmallVec<[Self::PublicKey; 4]>; /// Some documents do not directly store the sequence of bytes that will be signed but generate // it on request, so these types of documents cannot provide a reference to the signed bytes. @@ -59,7 +60,7 @@ pub trait Document: Debug + Clone + PartialEq + Eq { } /// Iterate over document signatures. - fn signatures(&self) -> &Vec<<Self::PublicKey as PublicKey>::Signature>; + fn signatures(&self) -> &SmallVec<[<Self::PublicKey as PublicKey>::Signature; 4]>; /// Verify one signature #[inline] diff --git a/lib/dubp/user-docs/Cargo.toml b/lib/dubp/user-docs/Cargo.toml index d89db022..e8441e45 100644 --- a/lib/dubp/user-docs/Cargo.toml +++ b/lib/dubp/user-docs/Cargo.toml @@ -25,6 +25,7 @@ serde_derive = "1.0.*" serde_json = "1.0.*" log = "0.4.*" unwrap = "1.2.1" +smallvec = {version = "1.*", features = ["serde"]} [dev-dependencies] pretty_assertions = "0.6.1" diff --git a/lib/dubp/user-docs/src/documents/certification.rs b/lib/dubp/user-docs/src/documents/certification.rs index 64ce3f86..73f11586 100644 --- a/lib/dubp/user-docs/src/documents/certification.rs +++ b/lib/dubp/user-docs/src/documents/certification.rs @@ -24,6 +24,7 @@ use dubp_common_doc::traits::{Document, ToStringObject}; use dup_crypto::keys::*; use durs_common_tools::{fatal_error, UsizeSer32}; use pest::Parser; +use smallvec::SmallVec; pub use v10::{ CertificationDocumentV10, CertificationDocumentV10Stringified, CompactCertificationDocumentV10, @@ -63,14 +64,14 @@ impl Document for CertificationDocument { } #[inline] - fn issuers(&self) -> &Vec<PubKey> { + fn issuers(&self) -> &SmallVec<[PubKey; 4]> { match self { CertificationDocument::V10(cert_v10) => cert_v10.issuers(), } } #[inline] - fn signatures(&self) -> &Vec<Sig> { + fn signatures(&self) -> &SmallVec<[Sig; 4]> { match self { CertificationDocument::V10(cert_v10) => cert_v10.signatures(), } diff --git a/lib/dubp/user-docs/src/documents/certification/v10.rs b/lib/dubp/user-docs/src/documents/certification/v10.rs index 35c964a8..9e546841 100644 --- a/lib/dubp/user-docs/src/documents/certification/v10.rs +++ b/lib/dubp/user-docs/src/documents/certification/v10.rs @@ -24,6 +24,7 @@ use dubp_common_doc::{BlockHash, BlockNumber}; use dup_crypto::hashs::Hash; use dup_crypto::keys::*; use durs_common_tools::{fatal_error, UsizeSer32}; +use smallvec::{smallvec, SmallVec}; #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] /// Wrap an Compact Revocation document (in block content) @@ -89,7 +90,7 @@ pub struct CertificationDocumentV10 { /// Name of the currency. currency: String, /// Document issuer (there should be only one). - issuers: Vec<PubKey>, + issuers: SmallVec<[PubKey; 4]>, /// issuer of target identity. target: PubKey, /// Username of target identity @@ -101,7 +102,7 @@ pub struct CertificationDocumentV10 { /// Blockstamp blockstamp: Blockstamp, /// Document signature (there should be only one). - signatures: Vec<Sig>, + signatures: SmallVec<[Sig; 4]>, } #[derive(Clone, Debug, Deserialize, Hash, Serialize, PartialEq, Eq)] @@ -198,14 +199,14 @@ impl CertificationDocumentV10 { Ok(CertificationDocumentV10 { text: doc.to_owned(), - issuers: vec![pubkeys[0]], + issuers: smallvec![pubkeys[0]], currency: currency.to_owned(), target: pubkeys[1], identity_username: uid.to_owned(), identity_blockstamp: blockstamps[0], identity_sig: sigs[0], blockstamp: blockstamps[1], - signatures: vec![sigs[1]], + signatures: smallvec![sigs[1]], }) } } @@ -225,11 +226,11 @@ impl Document for CertificationDocumentV10 { self.blockstamp } - fn issuers(&self) -> &Vec<PubKey> { + fn issuers(&self) -> &SmallVec<[PubKey; 4]> { &self.issuers } - fn signatures(&self) -> &Vec<Sig> { + fn signatures(&self) -> &SmallVec<[Sig; 4]> { &self.signatures } @@ -283,13 +284,13 @@ impl<'a> CertificationDocumentV10Builder<'a> { CertificationDocumentV10 { text, currency: self.currency.to_string(), - issuers: vec![*self.issuer], + issuers: smallvec![*self.issuer], blockstamp: *self.blockstamp, target: *self.target, identity_username: self.identity_username.to_string(), identity_blockstamp: *self.identity_blockstamp, identity_sig: *self.identity_sig, - signatures, + signatures: SmallVec::from_vec(signatures), } } } diff --git a/lib/dubp/user-docs/src/documents/identity.rs b/lib/dubp/user-docs/src/documents/identity.rs index c4f4403a..54e9c68e 100644 --- a/lib/dubp/user-docs/src/documents/identity.rs +++ b/lib/dubp/user-docs/src/documents/identity.rs @@ -23,6 +23,7 @@ use dubp_common_doc::parser::{DocumentsParser, TextDocumentParseError, TextDocum use dubp_common_doc::traits::{Document, ToStringObject}; use dup_crypto::keys::*; use durs_common_tools::UsizeSer32; +use smallvec::SmallVec; pub use v10::{IdentityDocumentV10, IdentityDocumentV10Stringified}; @@ -58,14 +59,14 @@ impl Document for IdentityDocument { } #[inline] - fn issuers(&self) -> &Vec<PubKey> { + fn issuers(&self) -> &SmallVec<[PubKey; 4]> { match self { IdentityDocument::V10(idty_v10) => idty_v10.issuers(), } } #[inline] - fn signatures(&self) -> &Vec<Sig> { + fn signatures(&self) -> &SmallVec<[Sig; 4]> { match self { IdentityDocument::V10(idty_v10) => idty_v10.signatures(), } diff --git a/lib/dubp/user-docs/src/documents/identity/v10.rs b/lib/dubp/user-docs/src/documents/identity/v10.rs index 762ed89c..ca93f1b5 100644 --- a/lib/dubp/user-docs/src/documents/identity/v10.rs +++ b/lib/dubp/user-docs/src/documents/identity/v10.rs @@ -16,6 +16,7 @@ //! Wrappers around Identity documents V10. use durs_common_tools::fatal_error; +use smallvec::{smallvec, SmallVec}; use crate::documents::*; use dubp_common_doc::blockstamp::Blockstamp; @@ -45,9 +46,9 @@ pub struct IdentityDocumentV10 { /// Blockstamp blockstamp: Blockstamp, /// Document issuer (there should be only one). - issuers: Vec<PubKey>, + issuers: SmallVec<[PubKey; 4]>, /// Document signature (there should be only one). - signatures: Vec<Sig>, + signatures: SmallVec<[Sig; 4]>, } #[derive(Clone, Debug, Deserialize, Hash, Serialize, PartialEq, Eq)] @@ -123,10 +124,10 @@ impl IdentityDocumentV10 { currency: currency.to_owned(), username: uid.to_owned(), blockstamp, - issuers: vec![PubKey::Ed25519(unwrap!(ed25519::PublicKey::from_base58( + issuers: smallvec![PubKey::Ed25519(unwrap!(ed25519::PublicKey::from_base58( pubkey_str )))], // Grammar ensures that we have a base58 string. - signatures: vec![Sig::Ed25519(unwrap!(ed25519::Signature::from_base64( + signatures: smallvec![Sig::Ed25519(unwrap!(ed25519::Signature::from_base64( sig_str )))], // Grammar ensures that we have a base64 string. }) @@ -148,11 +149,11 @@ impl Document for IdentityDocumentV10 { self.blockstamp } - fn issuers(&self) -> &Vec<PubKey> { + fn issuers(&self) -> &SmallVec<[PubKey; 4]> { &self.issuers } - fn signatures(&self) -> &Vec<Sig> { + fn signatures(&self) -> &SmallVec<[Sig; 4]> { &self.signatures } @@ -227,8 +228,8 @@ impl<'a> IdentityDocumentV10Builder<'a> { currency: self.currency.to_string(), username: self.username.to_string(), blockstamp: *self.blockstamp, - issuers: vec![*self.issuer], - signatures, + issuers: smallvec![*self.issuer], + signatures: SmallVec::from_vec(signatures), } } } diff --git a/lib/dubp/user-docs/src/documents/membership.rs b/lib/dubp/user-docs/src/documents/membership.rs index 3f559342..43f7525a 100644 --- a/lib/dubp/user-docs/src/documents/membership.rs +++ b/lib/dubp/user-docs/src/documents/membership.rs @@ -24,6 +24,7 @@ use dubp_common_doc::traits::text::*; use dubp_common_doc::traits::{Document, ToStringObject}; use dup_crypto::keys::*; use durs_common_tools::UsizeSer32; +use smallvec::SmallVec; pub use v10::{MembershipDocumentV10, MembershipDocumentV10Stringified}; @@ -60,14 +61,14 @@ impl Document for MembershipDocument { } #[inline] - fn issuers(&self) -> &Vec<PubKey> { + fn issuers(&self) -> &SmallVec<[PubKey; 4]> { match self { MembershipDocument::V10(ms_v10) => ms_v10.issuers(), } } #[inline] - fn signatures(&self) -> &Vec<Sig> { + fn signatures(&self) -> &SmallVec<[Sig; 4]> { match self { MembershipDocument::V10(ms_v10) => ms_v10.signatures(), } diff --git a/lib/dubp/user-docs/src/documents/membership/v10.rs b/lib/dubp/user-docs/src/documents/membership/v10.rs index 75356f46..7ac5cdd9 100644 --- a/lib/dubp/user-docs/src/documents/membership/v10.rs +++ b/lib/dubp/user-docs/src/documents/membership/v10.rs @@ -24,6 +24,7 @@ use dubp_common_doc::{BlockHash, BlockNumber}; use dup_crypto::hashs::Hash; use dup_crypto::keys::*; use durs_common_tools::{fatal_error, UsizeSer32}; +use smallvec::{smallvec, SmallVec}; /// Type of a Membership. #[derive(Debug, Deserialize, Clone, Copy, Hash, Serialize, PartialEq, Eq)] @@ -47,7 +48,7 @@ pub struct MembershipDocumentV10 { /// Name of the currency. currency: String, /// Document issuer (there should be only one). - issuers: Vec<PubKey>, + issuers: SmallVec<[PubKey; 4]>, /// Blockstamp blockstamp: Blockstamp, /// Membership message. @@ -57,7 +58,7 @@ pub struct MembershipDocumentV10 { /// Identity document blockstamp. identity_blockstamp: Blockstamp, /// Document signature (there should be only one). - signatures: Vec<Sig>, + signatures: SmallVec<[Sig; 4]>, } #[derive(Clone, Debug, Deserialize, Hash, Serialize, PartialEq, Eq)] @@ -176,7 +177,7 @@ impl MembershipDocumentV10 { Ok(MembershipDocumentV10 { text: Some(doc.to_owned()), - issuers: vec![PubKey::Ed25519(unwrap!(ed25519::PublicKey::from_base58( + issuers: smallvec![PubKey::Ed25519(unwrap!(ed25519::PublicKey::from_base58( pubkey_str )))], // Grammar ensures that we have a base58 string. currency: currency.to_owned(), @@ -184,7 +185,7 @@ impl MembershipDocumentV10 { membership, identity_username: uid.to_owned(), identity_blockstamp: blockstamps[1], - signatures: vec![Sig::Ed25519(unwrap!(ed25519::Signature::from_base64( + signatures: smallvec![Sig::Ed25519(unwrap!(ed25519::Signature::from_base64( sig_str )))], // Grammar ensures that we have a base64 string. }) @@ -206,11 +207,11 @@ impl Document for MembershipDocumentV10 { self.blockstamp } - fn issuers(&self) -> &Vec<PubKey> { + fn issuers(&self) -> &SmallVec<[PubKey; 4]> { &self.issuers } - fn signatures(&self) -> &Vec<Sig> { + fn signatures(&self) -> &SmallVec<[Sig; 4]> { &self.signatures } @@ -279,12 +280,12 @@ impl<'a> MembershipDocumentV10Builder<'a> { MembershipDocumentV10 { text: Some(text), currency: self.currency.to_string(), - issuers: vec![*self.issuer], + issuers: smallvec![*self.issuer], blockstamp: *self.blockstamp, membership: self.membership, identity_username: self.identity_username.to_string(), identity_blockstamp: *self.identity_blockstamp, - signatures, + signatures: SmallVec::from_vec(signatures), } } } diff --git a/lib/dubp/user-docs/src/documents/mod.rs b/lib/dubp/user-docs/src/documents/mod.rs index 576a36ec..f5b91e29 100644 --- a/lib/dubp/user-docs/src/documents/mod.rs +++ b/lib/dubp/user-docs/src/documents/mod.rs @@ -40,10 +40,10 @@ pub enum UserDocumentDUBP { Transaction(Box<TransactionDocument>), /// Identity document. - Identity(IdentityDocument), + Identity(Box<IdentityDocument>), /// Membership document. - Membership(MembershipDocument), + Membership(Box<MembershipDocument>), /// Certification document. Certification(Box<CertificationDocument>), @@ -135,11 +135,11 @@ impl UserDocumentDUBP { let doc_type_v10_pair = unwrap!(pair.into_inner().next()); // get and unwrap the `{DOC_TYPE}_v10` rule; never fails match doc_type_v10_pair.as_rule() { - Rule::idty_v10 => Ok(UserDocumentDUBP::Identity(IdentityDocument::V10( + Rule::idty_v10 => Ok(UserDocumentDUBP::Identity(Box::new(IdentityDocument::V10( IdentityDocumentV10::from_pest_pair(doc_type_v10_pair)?, - ))), - Rule::membership_v10 => Ok(UserDocumentDUBP::Membership(MembershipDocument::V10( - MembershipDocumentV10::from_pest_pair(doc_type_v10_pair)?, + )))), + Rule::membership_v10 => Ok(UserDocumentDUBP::Membership(Box::new( + MembershipDocument::V10(MembershipDocumentV10::from_pest_pair(doc_type_v10_pair)?), ))), Rule::cert_v10 => Ok(UserDocumentDUBP::Certification(Box::new( CertificationDocument::V10(CertificationDocumentV10::from_pest_pair( @@ -163,6 +163,7 @@ mod tests { use dubp_common_doc::parser::TextDocumentParser; use dubp_common_doc::traits::Document; use dubp_common_doc::Blockstamp; + use smallvec::{smallvec, SmallVec}; use dup_crypto::keys::*; use durs_common_tools::UsizeSer32; @@ -171,8 +172,8 @@ mod tests { #[derive(Debug, Clone, PartialEq, Eq)] struct PlainTextDocument { pub text: &'static str, - pub issuers: Vec<PubKey>, - pub signatures: Vec<Sig>, + pub issuers: SmallVec<[PubKey; 4]>, + pub signatures: SmallVec<[Sig; 4]>, } impl Document for PlainTextDocument { @@ -190,11 +191,11 @@ mod tests { unimplemented!() } - fn issuers(&self) -> &Vec<PubKey> { + fn issuers(&self) -> &SmallVec<[PubKey; 4]> { &self.issuers } - fn signatures(&self) -> &Vec<Sig> { + fn signatures(&self) -> &SmallVec<[Sig; 4]> { &self.signatures } @@ -244,8 +245,8 @@ Timestamp: 0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855 { let doc = PlainTextDocument { text, - issuers: vec![issuer1], - signatures: vec![sig1], + issuers: smallvec![issuer1], + signatures: smallvec![sig1], }; if let Err(e) = doc.verify_signatures() { @@ -256,8 +257,8 @@ Timestamp: 0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855 { let doc = PlainTextDocument { text, - issuers: vec![issuer1], - signatures: vec![sig2], + issuers: smallvec![issuer1], + signatures: smallvec![sig2], }; // todo: gérer l'erreur avec PartialEq /* @@ -272,8 +273,8 @@ Timestamp: 0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855 { let doc = PlainTextDocument { text, - issuers: vec![issuer1, issuer2], - signatures: vec![sig1], + issuers: smallvec![issuer1, issuer2], + signatures: smallvec![sig1], }; // todo: gérer l'erreur avec PartialEq @@ -289,8 +290,8 @@ Timestamp: 0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855 { let doc = PlainTextDocument { text, - issuers: vec![issuer1], - signatures: vec![sig1, sig2], + issuers: smallvec![issuer1], + signatures: smallvec![sig1, sig2], }; // todo: gérer l'erreur avec PartialEq diff --git a/lib/dubp/user-docs/src/documents/revocation.rs b/lib/dubp/user-docs/src/documents/revocation.rs index 8bb88af2..a45cb268 100644 --- a/lib/dubp/user-docs/src/documents/revocation.rs +++ b/lib/dubp/user-docs/src/documents/revocation.rs @@ -24,6 +24,7 @@ use dubp_common_doc::traits::{Document, ToStringObject}; use dup_crypto::keys::*; use durs_common_tools::UsizeSer32; use pest::Parser; +use smallvec::SmallVec; pub use v10::{ CompactRevocationDocumentV10, CompactRevocationDocumentV10Stringified, RevocationDocumentV10, @@ -73,14 +74,14 @@ impl Document for RevocationDocument { } #[inline] - fn issuers(&self) -> &Vec<PubKey> { + fn issuers(&self) -> &SmallVec<[PubKey; 4]> { match self { RevocationDocument::V10(revoc_v10) => revoc_v10.issuers(), } } #[inline] - fn signatures(&self) -> &Vec<Sig> { + fn signatures(&self) -> &SmallVec<[Sig; 4]> { match self { RevocationDocument::V10(revoc_v10) => revoc_v10.signatures(), } diff --git a/lib/dubp/user-docs/src/documents/revocation/v10.rs b/lib/dubp/user-docs/src/documents/revocation/v10.rs index 47ca62d9..33dba996 100644 --- a/lib/dubp/user-docs/src/documents/revocation/v10.rs +++ b/lib/dubp/user-docs/src/documents/revocation/v10.rs @@ -31,6 +31,7 @@ //! Wrappers around Revocation documents V10. use dup_crypto::keys::*; +use smallvec::{smallvec, SmallVec}; use crate::documents::*; use dubp_common_doc::blockstamp::Blockstamp; @@ -93,7 +94,7 @@ pub struct RevocationDocumentV10 { /// Name of the currency. currency: String, /// Document issuer (there should be only one). - issuers: Vec<PubKey>, + issuers: SmallVec<[PubKey; 4]>, /// Username of target identity identity_username: String, /// Target Identity document blockstamp. @@ -101,7 +102,7 @@ pub struct RevocationDocumentV10 { /// Target Identity document signature. identity_sig: Sig, /// Document signature (there should be only one). - signatures: Vec<Sig>, + signatures: SmallVec<[Sig; 4]>, } #[derive(Clone, Debug, Deserialize, Hash, Serialize, PartialEq, Eq)] @@ -181,12 +182,12 @@ impl RevocationDocumentV10 { } Ok(RevocationDocumentV10 { text: doc.to_owned(), - issuers: vec![pubkeys[0]], + issuers: smallvec![pubkeys[0]], currency: currency.to_owned(), identity_username: uid.to_owned(), identity_blockstamp: blockstamps[0], identity_sig: sigs[0], - signatures: vec![sigs[1]], + signatures: smallvec![sigs[1]], }) } } @@ -206,11 +207,11 @@ impl Document for RevocationDocumentV10 { unimplemented!() } - fn issuers(&self) -> &Vec<PubKey> { + fn issuers(&self) -> &SmallVec<[PubKey; 4]> { &self.issuers } - fn signatures(&self) -> &Vec<Sig> { + fn signatures(&self) -> &SmallVec<[Sig; 4]> { &self.signatures } @@ -251,14 +252,15 @@ pub struct RevocationDocumentV10Builder<'a> { impl<'a> RevocationDocumentV10Builder<'a> { fn build_with_text_and_sigs(self, text: String, signatures: Vec<Sig>) -> RevocationDocumentV10 { + //let sig_array_temp.from_vec(signatures); RevocationDocumentV10 { text, currency: self.currency.to_string(), - issuers: vec![*self.issuer], + issuers: smallvec![*self.issuer], identity_username: self.identity_username.to_string(), identity_blockstamp: *self.identity_blockstamp, identity_sig: *self.identity_sig, - signatures, + signatures: SmallVec::from_vec(signatures), } } } diff --git a/lib/dubp/user-docs/src/documents/transaction.rs b/lib/dubp/user-docs/src/documents/transaction.rs index 0606529c..ed794407 100644 --- a/lib/dubp/user-docs/src/documents/transaction.rs +++ b/lib/dubp/user-docs/src/documents/transaction.rs @@ -25,6 +25,7 @@ use dubp_common_doc::traits::{Document, DocumentBuilder, ToStringObject}; use dup_crypto::hashs::*; use dup_crypto::keys::*; use durs_common_tools::{fatal_error, UsizeSer32}; +use smallvec::SmallVec; use std::ops::{Add, Deref, Sub}; use unwrap::unwrap; @@ -330,13 +331,13 @@ impl Document for TransactionDocument { } } - fn issuers(&self) -> &Vec<PubKey> { + fn issuers(&self) -> &SmallVec<[PubKey; 4]> { match self { TransactionDocument::V10(tx_v10) => tx_v10.issuers(), } } - fn signatures(&self) -> &Vec<Sig> { + fn signatures(&self) -> &SmallVec<[Sig; 4]> { match self { TransactionDocument::V10(tx_v10) => tx_v10.signatures(), } diff --git a/lib/dubp/user-docs/src/documents/transaction/v10.rs b/lib/dubp/user-docs/src/documents/transaction/v10.rs index 5c9081a1..5c9f4124 100644 --- a/lib/dubp/user-docs/src/documents/transaction/v10.rs +++ b/lib/dubp/user-docs/src/documents/transaction/v10.rs @@ -27,6 +27,7 @@ use durs_common_tools::{fatal_error, UsizeSer32}; use pest::iterators::Pair; use pest::iterators::Pairs; use pest::Parser; +use smallvec::SmallVec; use std::str::FromStr; use unwrap::unwrap; @@ -288,17 +289,17 @@ pub struct TransactionDocumentV10 { /// Locktime locktime: u64, /// Document issuers. - issuers: Vec<PubKey>, + issuers: SmallVec<[PubKey; 4]>, /// Transaction inputs. - inputs: Vec<TransactionInputV10>, + inputs: SmallVec<[TransactionInputV10; 32]>, /// Inputs unlocks. - unlocks: Vec<TransactionInputUnlocksV10>, + unlocks: SmallVec<[TransactionInputUnlocksV10; 32]>, /// Transaction outputs. - outputs: Vec<TransactionOutputV10>, + outputs: SmallVec<[TransactionOutputV10; 8]>, /// Transaction comment comment: String, /// Document signatures. - signatures: Vec<Sig>, + signatures: SmallVec<[Sig; 4]>, /// Transaction hash hash: Option<Hash>, } @@ -407,12 +408,12 @@ impl TransactionDocumentV10 { let mut currency = ""; let mut blockstamp = Blockstamp::default(); let mut locktime = 0; - let mut issuers = Vec::new(); - let mut inputs = Vec::new(); - let mut unlocks = Vec::new(); - let mut outputs = Vec::new(); + let mut issuers = SmallVec::<[PubKey; 4]>::new(); + let mut inputs = SmallVec::new(); + let mut unlocks = SmallVec::new(); + let mut outputs = SmallVec::new(); let mut comment = ""; - let mut sigs = Vec::new(); + let mut sigs = SmallVec::<[Sig; 4]>::new(); for field in pair.into_inner() { match field.as_rule() { @@ -482,11 +483,11 @@ impl Document for TransactionDocumentV10 { self.blockstamp } - fn issuers(&self) -> &Vec<PubKey> { + fn issuers(&self) -> &SmallVec<[PubKey; 4]> { &self.issuers } - fn signatures(&self) -> &Vec<Sig> { + fn signatures(&self) -> &SmallVec<[Sig; 4]> { &self.signatures } @@ -598,12 +599,12 @@ impl<'a> TransactionDocumentV10Builder<'a> { currency: self.currency.to_string(), blockstamp: *self.blockstamp, locktime: *self.locktime, - issuers: self.issuers.to_vec(), - inputs: self.inputs.to_vec(), - unlocks: self.unlocks.to_vec(), - outputs: self.outputs.to_vec(), + issuers: SmallVec::from_slice(self.issuers), + inputs: SmallVec::from_slice(self.inputs), + unlocks: SmallVec::from(self.unlocks), + outputs: SmallVec::from(self.outputs), comment: String::from(self.comment), - signatures, + signatures: SmallVec::from_vec(signatures), hash: self.hash, } } diff --git a/lib/modules/gva/Cargo.toml b/lib/modules/gva/Cargo.toml index 79501caa..1e73625d 100644 --- a/lib/modules/gva/Cargo.toml +++ b/lib/modules/gva/Cargo.toml @@ -40,5 +40,6 @@ durs-bc-db-reader = { path = "../../modules-lib/bc-db-reader", features = ["clie dubp-blocks-tests-tools = { path = "../../tests-tools/blocks-tests-tools" } dup-crypto-tests-tools = { path = "../../tests-tools/crypto-tests-tools" } mockall = "0.6.0" +smallvec = "1.*" [features] diff --git a/lib/modules/gva/src/schema/queries/block.rs b/lib/modules/gva/src/schema/queries/block.rs index 3a85d335..1de08d31 100644 --- a/lib/modules/gva/src/schema/queries/block.rs +++ b/lib/modules/gva/src/schema/queries/block.rs @@ -50,6 +50,7 @@ mod tests { use durs_common_tools::UsizeSer32; use mockall::predicate::eq; use serde_json::json; + use smallvec::smallvec; static mut DB_BLOCK_1: Option<BcDbRo> = None; @@ -69,7 +70,7 @@ mod tests { 1_488_987_127, Hash::default(), ); - block.issuers = vec![pubkey('B')]; + block.issuers = smallvec![pubkey('B')]; block.issuers_count = UsizeSer32(3); block.pow_min = UsizeSer32(70); Ok(Some(BlockDb { diff --git a/lib/modules/gva/src/schema/queries/blocks.rs b/lib/modules/gva/src/schema/queries/blocks.rs index 467a027f..949780d2 100644 --- a/lib/modules/gva/src/schema/queries/blocks.rs +++ b/lib/modules/gva/src/schema/queries/blocks.rs @@ -109,6 +109,7 @@ mod tests { use durs_bc_db_reader::blocks::BlockDb; use mockall::predicate::eq; use serde_json::json; + use smallvec::smallvec; fn block_0() -> BlockDocumentV10 { let mut block_0 = gen_empty_timed_block_v10( @@ -119,7 +120,7 @@ mod tests { 1_488_987_127, Hash::default(), ); - block_0.issuers = vec![pubkey('A')]; + block_0.issuers = smallvec![pubkey('A')]; block_0 } fn block_0_json() -> serde_json::Value { @@ -142,7 +143,7 @@ mod tests { 1_488_987_128, Hash::default(), ); - block_1.issuers = vec![pubkey('B')]; + block_1.issuers = smallvec![pubkey('B')]; block_1 } fn block_1_json() -> serde_json::Value { @@ -165,7 +166,7 @@ mod tests { 1_488_987_129, Hash::default(), ); - block_2.issuers = vec![pubkey('C')]; + block_2.issuers = smallvec![pubkey('C')]; block_2 } fn block_2_json() -> serde_json::Value { @@ -188,7 +189,7 @@ mod tests { 1_488_987_130, Hash::default(), ); - block_3.issuers = vec![pubkey('D')]; + block_3.issuers = smallvec![pubkey('D')]; block_3 } fn block_3_json() -> serde_json::Value { @@ -211,7 +212,7 @@ mod tests { 1_488_987_131, Hash::default(), ); - block_4.issuers = vec![pubkey('E')]; + block_4.issuers = smallvec![pubkey('E')]; block_4 } fn block_4_json() -> serde_json::Value { diff --git a/lib/modules/gva/src/schema/queries/current.rs b/lib/modules/gva/src/schema/queries/current.rs index c14f06a3..36aebb49 100644 --- a/lib/modules/gva/src/schema/queries/current.rs +++ b/lib/modules/gva/src/schema/queries/current.rs @@ -42,6 +42,7 @@ mod tests { use durs_common_tools::UsizeSer32; use mockall::predicate::eq; use serde_json::json; + use smallvec::smallvec; static mut DB_TEST_CURRENT_1: Option<BcDbRo> = None; @@ -57,7 +58,7 @@ mod tests { 1_488_987_127, Hash::default(), ); - current_block.issuers = vec![pubkey('B')]; + current_block.issuers = smallvec![pubkey('B')]; current_block.pow_min = UsizeSer32(70); current_block.members_count = UsizeSer32(59); Ok(Some(BlockDb { diff --git a/lib/tests-tools/blocks-tests-tools/Cargo.toml b/lib/tests-tools/blocks-tests-tools/Cargo.toml index 9ff64e0c..ac5c0121 100644 --- a/lib/tests-tools/blocks-tests-tools/Cargo.toml +++ b/lib/tests-tools/blocks-tests-tools/Cargo.toml @@ -23,5 +23,6 @@ dubp-user-docs-tests-tools = { path = "../user-docs-tests-tools" } durs-common-tools = { path = "../../tools/common-tools" } json-pest-parser = { path = "../../tools/json-pest-parser" } failure = "0.1.5" +smallvec = "1.*" [dev-dependencies] diff --git a/lib/tests-tools/blocks-tests-tools/src/mocks.rs b/lib/tests-tools/blocks-tests-tools/src/mocks.rs index 58955ae9..07239dd0 100644 --- a/lib/tests-tools/blocks-tests-tools/src/mocks.rs +++ b/lib/tests-tools/blocks-tests-tools/src/mocks.rs @@ -31,6 +31,7 @@ use dup_crypto::bases::b16::str_hex_to_32bytes; use dup_crypto::hashs::Hash; use dup_crypto::keys::{ed25519, PubKey, PublicKey, Sig, Signator, Signature}; use durs_common_tools::UsizeSer32; +use smallvec::smallvec; /// Generate n mock blockstamps pub fn generate_blockstamps(n: usize) -> Vec<Blockstamp> { @@ -78,7 +79,7 @@ pub fn gen_empty_timed_issued_hashed_block_v10( let mut block = gen_empty_block_v10(block_number); block.time = time; block.median_time = time; - block.issuers = vec![signator.public_key()]; + block.issuers = smallvec![signator.public_key()]; block.previous_issuer = Some(previous_issuer); block.previous_hash = Some(previous_hash); block.inner_hash = Some(block.compute_inner_hash()); @@ -105,7 +106,7 @@ pub fn gen_empty_timed_block_v10( /// (usefull for tests that only need issuer field) pub fn gen_empty_issued_block_v10(issuer: PubKey) -> BlockDocumentV10 { let mut block = gen_empty_block_v10(BlockNumber(0)); - block.issuers = vec![issuer]; + block.issuers = smallvec![issuer]; block } @@ -124,8 +125,8 @@ fn gen_empty_block_v10(block_number: BlockNumber) -> BlockDocumentV10 { issuers_frame: UsizeSer32(0), issuers_frame_var: 0, currency: CurrencyName("test_currency".to_owned()), - issuers: vec![], - signatures: vec![], + issuers: smallvec![], + signatures: smallvec![], hash: None, parameters: None, previous_hash: None, @@ -188,8 +189,8 @@ a9PHPuSfw7jW8FRQHXFsGi/bnLjbtDnTYvEVgUC9u0WlR7GVofa+Xb+l5iy6NwuEXiwvueAkf08wPVY8 issuers_frame: UsizeSer32(211), issuers_frame_var: 0, currency: CurrencyName(String::from("g1")), - issuers: vec![PubKey::Ed25519(ed25519::PublicKey::from_base58("DA4PYtXdvQqk1nCaprXH52iMsK5Ahxs1nRWbWKLhpVkQ").expect("fail to parse issuers"))], - signatures: vec![Sig::Ed25519(ed25519::Signature::from_base64("92id58VmkhgVNee4LDqBGSm8u/ooHzAD67JM6fhAE/CV8LCz7XrMF1DvRl+eRpmlaVkp6I+Iy8gmZ1WUM5C8BA==").expect("fail to parse signatures"))], + issuers: smallvec![PubKey::Ed25519(ed25519::PublicKey::from_base58("DA4PYtXdvQqk1nCaprXH52iMsK5Ahxs1nRWbWKLhpVkQ").expect("fail to parse issuers"))], + signatures: smallvec![Sig::Ed25519(ed25519::Signature::from_base64("92id58VmkhgVNee4LDqBGSm8u/ooHzAD67JM6fhAE/CV8LCz7XrMF1DvRl+eRpmlaVkp6I+Iy8gmZ1WUM5C8BA==").expect("fail to parse signatures"))], hash: None, parameters: None, previous_hash: Some(Hash::from_hex("000001144968D0C3516BE6225E4662F182E28956AF46DD7FB228E3D0F9413FEB").expect("fail to parse previous_hash")), @@ -226,8 +227,8 @@ pub fn gen_mock_genesis_block_v10() -> BlockDocumentV10 { issuers_frame: UsizeSer32(0), issuers_frame_var: 0, currency: CurrencyName(String::from("g1")), - issuers: vec![PubKey::Ed25519(ed25519::PublicKey::from_base58("DA4PYtXdvQqk1nCaprXH52iMsK5Ahxs1nRWbWKLhpVkQ").expect("fail to parse issuers"))], - signatures: vec![Sig::Ed25519(ed25519::Signature::from_base64("92id58VmkhgVNee4LDqBGSm8u/ooHzAD67JM6fhAE/CV8LCz7XrMF1DvRl+eRpmlaVkp6I+Iy8gmZ1WUM5C8BA==").expect("fail to parse signatures"))], + issuers: smallvec![PubKey::Ed25519(ed25519::PublicKey::from_base58("DA4PYtXdvQqk1nCaprXH52iMsK5Ahxs1nRWbWKLhpVkQ").expect("fail to parse issuers"))], + signatures: smallvec![Sig::Ed25519(ed25519::Signature::from_base64("92id58VmkhgVNee4LDqBGSm8u/ooHzAD67JM6fhAE/CV8LCz7XrMF1DvRl+eRpmlaVkp6I+Iy8gmZ1WUM5C8BA==").expect("fail to parse signatures"))], hash: None, parameters: Some(BlockV10Parameters::default()), previous_hash: None, -- GitLab