Browse Source
Use TryInto to convert slices into array
Remove dependency on `arrayref`.
fees
Roman Zeyde
6 years ago
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB
5 changed files with
6 additions and
13 deletions
-
Cargo.lock
-
Cargo.toml
-
doc/usage.md
-
src/lib.rs
-
src/util.rs
|
|
@ -25,11 +25,6 @@ dependencies = [ |
|
|
|
"scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", |
|
|
|
] |
|
|
|
|
|
|
|
[[package]] |
|
|
|
name = "arrayref" |
|
|
|
version = "0.3.5" |
|
|
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
|
|
|
|
|
|
|
[[package]] |
|
|
|
name = "arrayvec" |
|
|
|
version = "0.4.10" |
|
|
@ -327,7 +322,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" |
|
|
|
name = "electrs" |
|
|
|
version = "0.5.0" |
|
|
|
dependencies = [ |
|
|
|
"arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", |
|
|
|
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", |
|
|
|
"bincode 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", |
|
|
|
"bitcoin 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", |
|
|
@ -1097,7 +1091,6 @@ dependencies = [ |
|
|
|
"checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" |
|
|
|
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" |
|
|
|
"checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" |
|
|
|
"checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" |
|
|
|
"checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" |
|
|
|
"checksum ascii 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "97be891acc47ca214468e09425d02cef3af2c94d0d82081cd02061f996802f14" |
|
|
|
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" |
|
|
|
|
|
@ -12,7 +12,6 @@ readme = "README.md" |
|
|
|
edition = "2018" |
|
|
|
|
|
|
|
[dependencies] |
|
|
|
arrayref = "0.3" |
|
|
|
base64 = "0.10" |
|
|
|
bincode = "1.0" |
|
|
|
bitcoin = "0.18" |
|
|
|
|
|
@ -1,6 +1,6 @@ |
|
|
|
## Installation |
|
|
|
|
|
|
|
Install [latest Rust](https://rustup.rs/) (1.33+), |
|
|
|
Install [latest Rust](https://rustup.rs/) (1.34+), |
|
|
|
[latest Bitcoin Core](https://bitcoincore.org/en/download/) (0.16+) |
|
|
|
and [latest Electrum wallet](https://electrum.org/#download) (3.3+). |
|
|
|
|
|
|
|
|
|
@ -5,8 +5,6 @@ extern crate chan; |
|
|
|
#[macro_use] |
|
|
|
extern crate clap; |
|
|
|
#[macro_use] |
|
|
|
extern crate arrayref; |
|
|
|
#[macro_use] |
|
|
|
extern crate error_chain; |
|
|
|
#[macro_use] |
|
|
|
extern crate log; |
|
|
|
|
|
@ -2,6 +2,7 @@ use bitcoin::blockdata::block::BlockHeader; |
|
|
|
use bitcoin::util::hash::BitcoinHash; |
|
|
|
use bitcoin_hashes::sha256d::Hash as Sha256dHash; |
|
|
|
use std::collections::HashMap; |
|
|
|
use std::convert::TryInto; |
|
|
|
use std::fmt; |
|
|
|
use std::iter::FromIterator; |
|
|
|
use std::slice; |
|
|
@ -20,11 +21,13 @@ pub type FullHash = [u8; HASH_LEN]; |
|
|
|
pub type HashPrefix = [u8; HASH_PREFIX_LEN]; |
|
|
|
|
|
|
|
pub fn hash_prefix(hash: &[u8]) -> HashPrefix { |
|
|
|
*array_ref![hash, 0, HASH_PREFIX_LEN] |
|
|
|
hash[..HASH_PREFIX_LEN] |
|
|
|
.try_into() |
|
|
|
.expect("failed to convert into HashPrefix") |
|
|
|
} |
|
|
|
|
|
|
|
pub fn full_hash(hash: &[u8]) -> FullHash { |
|
|
|
*array_ref![hash, 0, HASH_LEN] |
|
|
|
hash.try_into().expect("failed to convert into FullHash") |
|
|
|
} |
|
|
|
|
|
|
|
#[derive(Eq, PartialEq, Clone)] |
|
|
|