Skip to content

Commit

Permalink
add vec
Browse files Browse the repository at this point in the history
  • Loading branch information
guoxbin committed Jun 22, 2020
1 parent bcbe274 commit fd8bd73
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions merkle/Cargo.toml
Expand Up @@ -29,6 +29,7 @@ default = ["std"]
std = [
"parity-codec/std",
]
nightly = []
bitcoin = ["ring", "rust-crypto"]
chaincore = ["rust-crypto"]
crypto_bench = ["rust-crypto", "ring", "rand"]
Expand Down
13 changes: 7 additions & 6 deletions merkle/src/hash_impl.rs
Expand Up @@ -2,6 +2,7 @@ use crate::hash::Hashable;
use crate::mstd::hash::Hasher;
use crate::mstd::mem;
use crate::mstd::slice;
use crate::mstd::vec::Vec;

macro_rules! impl_write {
($(($ty:ident, $meth:ident),)*) => {$(
Expand Down Expand Up @@ -87,12 +88,12 @@ impl<H: Hasher> Hashable<H> for str {
}
}

impl<H: Hasher> Hashable<H> for String {
fn hash(&self, state: &mut H) {
state.write(self.as_bytes());
// empty str nope: state.write_u8(0xff)
}
}
// impl<H: Hasher> Hashable<H> for String {
// fn hash(&self, state: &mut H) {
// state.write(self.as_bytes());
// // empty str nope: state.write_u8(0xff)
// }
// }

macro_rules! impl_hash_tuple {
() => (
Expand Down
1 change: 0 additions & 1 deletion merkle/src/lib.rs
Expand Up @@ -156,7 +156,6 @@
#![cfg_attr(feature="nightly", allow(unstable_features))]

#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(alloc))]

/// Hash infrastructure for items in Merkle tree.
pub mod hash;
Expand Down
1 change: 1 addition & 0 deletions merkle/src/merkle.rs
Expand Up @@ -3,6 +3,7 @@ use crate::proof::Proof;
use crate::mstd::iter::FromIterator;
use crate::mstd::marker::PhantomData;
use crate::mstd::ops;
use crate::mstd::vec::Vec;
use parity_codec::{Encode, Decode};

/// Merkle Tree.
Expand Down
2 changes: 2 additions & 0 deletions merkle/src/mstd.rs
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

pub extern crate alloc;

#[cfg(feature = "std")]
pub use {
std::{hash, mem, slice, iter, marker, ops},
Expand Down
1 change: 1 addition & 0 deletions merkle/src/proof.rs
@@ -1,5 +1,6 @@
use crate::hash::Algorithm;
use parity_codec::{Encode, Decode};
use crate::mstd::vec::Vec;

/// Merkle tree inclusion proof for data element, for which item = Leaf(Hash(Data Item)).
///
Expand Down

0 comments on commit fd8bd73

Please sign in to comment.