Prefix workspace crates with zebra- (#70)

* Update license and author metadata in workspace crates.

- ensure that the license field is set to GPL-3 for all GPL-3 licensed crates;
- ensure that the author field is set to "Zcash Foundation", responsible for maintenance;
- preserve the original authorship info in AUTHORS.md for human-readable history.

Updating the author field ensures that all of the machine systems that read
crate metadata list the ZF organization, not any single individual, as the
maintainer of the crate.

* Prefix all internal crate names with zebra-.

This does not move the directories containing these crates to also have zebra-
prefixes (for instance, zebra-chain instead of chain).  I think that this would
be preferable, but because it's a `git mv`, it will be simple to do later and
leaving it out of this change makes it easier to see the renaming of all of the
internal modules.

* Remove git dependency from eth-secp256k1

* Avoid an error seemingly related to Deref coercions.

This code caused an overflow while evaluating type constraints.  As best as I
can determine, the cause of the problem was something like so: the Rust
implementation of the Bitcoin-specific hash function used in the Bloom filter
doesn't operate on byte slices, but only on a `&mut R where R: Read`, so to
hash a byte slice, you need to create a mutable copy of the input slice which
can be consumed as a `Read` implementation by the hash function; the previous
version of this code created a slice copy using a `Deref` coercion instead of
`.clone()`, and when a tokio update added new trait impls, the type inference
for the `Deref` coercion exploded (somehow -- I'm not sure about the last
part?).

This commit avoids the problem by manually cloning the input slice.
This commit is contained in:
Henry de Valence 2019-07-02 12:07:06 -07:00 committed by Deirdre Connolly
parent 1d82b3d55e
commit 22c3bdeb61
177 changed files with 2255 additions and 2151 deletions

7
AUTHORS.md Normal file
View File

@ -0,0 +1,7 @@
Zebra is developed and maintained by the Zcash Foundation.
The codebase began as `parity-zcash`, authored by:
- Svyatoslav Nikolsky
- Marek Kotewicz
- Nikolay Volf

1462
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -2,30 +2,30 @@
name = "zebra"
version = "0.1.0"
license = "GPL-3.0"
authors = ["Zcash Foundation"]
authors = ["Zcash Foundation <zebra@zfnd.org>"]
description = "A consensus-compatible Zcash node client written in Rust."
[dependencies]
app_dirs = { git = "https://github.com/paritytech/app-dirs-rs" }
chain = { path = "chain" }
clap = { version = "2", features = ["yaml"] }
db = { path = "db" }
env_logger = "0.5"
import = { path = "import" }
keys = { path = "keys" }
libc = "0.2"
log = "0.4"
logs = { path = "logs" }
message = { path = "message" }
network = { path = "network" }
miner = { path = "miner" }
p2p = { path = "p2p" }
primitives = { path = "primitives" }
rpc = { path = "rpc" }
script = { path = "script" }
storage = { path = "storage" }
sync = { path = "sync" }
verification = { path = "verification" }
zebra-db = { path = "db" }
zebra-chain = { path = "chain" }
zebra-import = { path = "import" }
zebra-keys = { path = "keys" }
zebra-logs = { path = "logs" }
zebra-message = { path = "message" }
zebra-network = { path = "network" }
zebra-miner = { path = "miner" }
zebra-p2p = { path = "p2p" }
zebra-primitives = { path = "primitives" }
zebra-rpc = { path = "rpc" }
zebra-script = { path = "script" }
zebra-storage = { path = "storage" }
zebra-sync = { path = "sync" }
zebra-verification = { path = "verification" }
[profile.dev]
debug = true
@ -45,7 +45,7 @@ name = "zebra"
[workspace]
members = [
"bencher",
"./crypto",
"crypto",
"chain",
"db",
"import",

View File

@ -1,18 +1,17 @@
[package]
name = "bencher"
name = "zebra-bencher"
version = "0.1.0"
license = "GPL-3.0"
authors = ["Ethcore <admin@ethcore.io>"]
description = "Parity bitcoin client."
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies]
storage = { path = "../storage" }
db = { path = "../db" }
verification = { path = "../verification" }
network = { path = "../network" }
chain = { path = "../chain", features = ["test-helpers"] }
primitives = { path = "../primitives" }
test-data = { path = "../test-data" }
zebra-storage = { path = "../storage" }
zebra-db = { path = "../db" }
zebra-verification = { path = "../verification" }
zebra-network = { path = "../network" }
zebra-chain = { path = "../chain", features = ["test-helpers"] }
zebra-primitives = { path = "../primitives" }
zebra-test-data = { path = "../test-data" }
time = "*"
byteorder = "1.0"

View File

@ -1,7 +1,7 @@
use chain::IndexedBlock;
use db::BlockChainDatabase;
use storage::{BlockOrigin, BlockProvider, BlockRef, ForkChain};
use test_data;
use zebra_chain::IndexedBlock;
use zebra_db::BlockChainDatabase;
use zebra_storage::{BlockOrigin, BlockProvider, BlockRef, ForkChain};
use zebra_test_data;
use super::Benchmark;
@ -12,7 +12,7 @@ pub fn fetch(benchmark: &mut Benchmark) {
benchmark.samples(BLOCKS);
// test setup
let genesis: IndexedBlock = test_data::genesis().into();
let genesis: IndexedBlock = zebra_test_data::genesis().into();
let store = BlockChainDatabase::init_test_chain(vec![genesis.clone()]);
let mut rolling_hash = genesis.hash().clone();
@ -20,7 +20,7 @@ pub fn fetch(benchmark: &mut Benchmark) {
let mut hashes = Vec::new();
for x in 0..BLOCKS {
let next_block = test_data::block_builder()
let next_block = zebra_test_data::block_builder()
.transaction()
.coinbase()
.lock_time(x as u32)
@ -60,7 +60,7 @@ pub fn write(benchmark: &mut Benchmark) {
benchmark.samples(BLOCKS);
// setup
let genesis: IndexedBlock = test_data::genesis().into();
let genesis: IndexedBlock = zebra_test_data::genesis().into();
let store = BlockChainDatabase::init_test_chain(vec![genesis.clone()]);
let mut rolling_hash = genesis.hash().clone();
@ -68,7 +68,7 @@ pub fn write(benchmark: &mut Benchmark) {
let mut blocks: Vec<IndexedBlock> = Vec::new();
for x in 0..BLOCKS {
let next_block = test_data::block_builder()
let next_block = zebra_test_data::block_builder()
.transaction()
.coinbase()
.lock_time(x as u32)
@ -101,7 +101,7 @@ pub fn reorg_short(benchmark: &mut Benchmark) {
benchmark.samples(BLOCKS);
// setup
let genesis: IndexedBlock = test_data::genesis().into();
let genesis: IndexedBlock = zebra_test_data::genesis().into();
let store = BlockChainDatabase::init_test_chain(vec![genesis.clone()]);
let mut rolling_hash = genesis.hash().clone();
@ -111,7 +111,7 @@ pub fn reorg_short(benchmark: &mut Benchmark) {
for x in 0..BLOCKS {
let base = rolling_hash.clone();
let next_block = test_data::block_builder()
let next_block = zebra_test_data::block_builder()
.transaction()
.coinbase()
.lock_time(x as u32)
@ -127,7 +127,7 @@ pub fn reorg_short(benchmark: &mut Benchmark) {
rolling_hash = next_block.hash();
blocks.push(next_block);
let next_block_side = test_data::block_builder()
let next_block_side = zebra_test_data::block_builder()
.transaction()
.coinbase()
.lock_time(x as u32)
@ -143,7 +143,7 @@ pub fn reorg_short(benchmark: &mut Benchmark) {
let next_base = next_block_side.hash();
blocks.push(next_block_side);
let next_block_side_continue = test_data::block_builder()
let next_block_side_continue = zebra_test_data::block_builder()
.transaction()
.coinbase()
.lock_time(x as u32)
@ -158,7 +158,7 @@ pub fn reorg_short(benchmark: &mut Benchmark) {
.build();
blocks.push(next_block_side_continue);
let next_block_continue = test_data::block_builder()
let next_block_continue = zebra_test_data::block_builder()
.transaction()
.coinbase()
.lock_time(x as u32)
@ -224,7 +224,7 @@ pub fn write_heavy(benchmark: &mut Benchmark) {
benchmark.samples(BLOCKS);
// test setup
let genesis: IndexedBlock = test_data::genesis().into();
let genesis: IndexedBlock = zebra_test_data::genesis().into();
let store = BlockChainDatabase::init_test_chain(vec![genesis.clone()]);
let mut rolling_hash = genesis.hash().clone();
@ -232,7 +232,7 @@ pub fn write_heavy(benchmark: &mut Benchmark) {
let mut hashes = Vec::new();
for x in 0..BLOCKS_INITIAL {
let next_block = test_data::block_builder()
let next_block = zebra_test_data::block_builder()
.transaction()
.coinbase()
.lock_time(x as u32)
@ -251,7 +251,10 @@ pub fn write_heavy(benchmark: &mut Benchmark) {
}
for b in 0..BLOCKS {
let mut builder = test_data::block_builder().transaction().coinbase().build();
let mut builder = zebra_test_data::block_builder()
.transaction()
.coinbase()
.build();
for t in 0..TRANSACTIONS {
builder = builder

View File

@ -1,12 +1,12 @@
extern crate byteorder;
extern crate chain;
extern crate db;
extern crate network;
extern crate primitives;
extern crate storage;
extern crate test_data;
extern crate time;
extern crate verification;
extern crate zebra_chain;
extern crate zebra_db;
extern crate zebra_network;
extern crate zebra_primitives;
extern crate zebra_storage;
extern crate zebra_test_data;
extern crate zebra_verification;
mod database;
mod verifier;

View File

@ -1,10 +1,12 @@
use byteorder::{ByteOrder, LittleEndian};
use chain::IndexedBlock;
use db::BlockChainDatabase;
use network::{ConsensusParams, Network};
use std::sync::Arc;
use test_data;
use verification::{BackwardsCompatibleChainVerifier as ChainVerifier, VerificationLevel, Verify};
use zebra_chain::IndexedBlock;
use zebra_db::BlockChainDatabase;
use zebra_network::{ConsensusParams, Network};
use zebra_test_data;
use zebra_verification::{
BackwardsCompatibleChainVerifier as ChainVerifier, VerificationLevel, Verify,
};
use super::Benchmark;
@ -26,7 +28,7 @@ pub fn main(benchmark: &mut Benchmark) {
);
// test setup
let genesis = test_data::genesis();
let genesis = zebra_test_data::genesis();
let consensus = ConsensusParams::new(Network::Unitest);
let mut rolling_hash = genesis.hash();
@ -35,7 +37,7 @@ pub fn main(benchmark: &mut Benchmark) {
for x in 0..BLOCKS_INITIAL {
let mut coinbase_nonce = [0u8; 8];
LittleEndian::write_u64(&mut coinbase_nonce[..], x as u64);
let next_block = test_data::block_builder()
let next_block = zebra_test_data::block_builder()
.transaction()
.lock_time(x as u32)
.input()
@ -69,7 +71,7 @@ pub fn main(benchmark: &mut Benchmark) {
for b in 0..BLOCKS {
let mut coinbase_nonce = [0u8; 8];
LittleEndian::write_u64(&mut coinbase_nonce[..], (b + BLOCKS_INITIAL) as u64);
let mut builder = test_data::block_builder()
let mut builder = zebra_test_data::block_builder()
.transaction()
.lock_time(b as u32)
.input()

View File

@ -1,15 +1,16 @@
[package]
name = "chain"
name = "zebra-chain"
version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies]
rustc-hex = "2"
heapsize = "0.4"
bitcrypto = { path = "../crypto" }
primitives = { path = "../primitives" }
serialization = { path = "../serialization" }
serialization_derive = { path = "../serialization_derive" }
zebra-crypto = { path = "../crypto" }
zebra-primitives = { path = "../primitives" }
zebra-serialization = { path = "../serialization" }
zebra-serialization_derive = { path = "../serialization_derive" }
[features]
default = []

View File

@ -1,12 +1,12 @@
use compact::Compact;
use crypto::dhash256;
use hash::H256;
use hex::FromHex;
use primitives::bytes::Bytes;
use ser::Stream;
use ser::{deserialize, serialize};
use solution::EquihashSolution;
use std::fmt;
use zebra_crypto::dhash256;
use zebra_primitives::bytes::Bytes;
#[derive(PartialEq, Clone, Serializable, Deserializable)]
pub struct BlockHeader {

View File

@ -1,8 +1,8 @@
use crypto::Groth16Proof;
use hash::{H256, H512};
use hex::ToHex;
use ser::{CompactInteger, Error, Reader, Serializable, Stream};
use std::{fmt, io};
use zebra_crypto::Groth16Proof;
#[derive(Clone)]
pub enum JoinSplitProof {

View File

@ -1,10 +1,10 @@
extern crate bitcrypto as crypto;
extern crate heapsize;
extern crate primitives;
extern crate rustc_hex as hex;
extern crate serialization as ser;
extern crate zebra_crypto;
extern crate zebra_primitives;
extern crate zebra_serialization as ser;
#[macro_use]
extern crate serialization_derive;
extern crate zebra_serialization_derive;
pub mod constants;
@ -22,7 +22,7 @@ mod indexed_transaction;
/// `IndexedBlock` extension
mod read_and_hash;
pub use primitives::{bigint, bytes, compact, hash};
pub use zebra_primitives::{bigint, bytes, compact, hash};
pub use transaction::{
BTC_TX_VERSION, OVERWINTER_TX_VERSION, SAPLING_TX_VERSION, SPROUT_TX_VERSION,

View File

@ -1,5 +1,5 @@
use crypto::dhash256;
use hash::{H256, H512};
use zebra_crypto::dhash256;
#[inline]
fn concat<T>(a: T, b: T) -> H512

View File

@ -1,7 +1,7 @@
use crypto::{DHash256, Digest};
use hash::H256;
use ser::{Deserializable, Error as ReaderError, Reader};
use std::io;
use zebra_crypto::{DHash256, Digest};
pub struct HashedData<T> {
pub size: usize,

View File

@ -3,7 +3,6 @@
use bytes::Bytes;
use constants::{LOCKTIME_THRESHOLD, SEQUENCE_FINAL};
use crypto::dhash256;
use hash::H256;
use heapsize::HeapSizeOf;
use hex::FromHex;
@ -12,6 +11,7 @@ use sapling::Sapling;
use ser::{deserialize, serialize};
use ser::{Deserializable, Error, Reader, Serializable, Stream};
use std::io;
use zebra_crypto::dhash256;
/// Original bitcoin transaction version.
pub const BTC_TX_VERSION: i32 = 1;

View File

@ -1,7 +1,8 @@
[package]
name = "bitcrypto"
name = "zebra-crypto"
version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies]
bellman = "0.1"
@ -11,7 +12,6 @@ bn = { git = "https://github.com/paritytech/bn" }
ed25519-dalek = "1.0.0-pre.1"
lazy_static = "1.3.0"
pairing = "0.14.2"
primitives = { path = "../primitives" }
rust-crypto = { git = "https://github.com/nikvolf/rust-crypto", branch = "no-pad" }
rustc-hex = "2"
sapling-crypto = { git = "https://github.com/zcash-hackworks/sapling-crypto.git", rev = "21084bde2019c04bd34208e63c3560fe2c02fb0e" }
@ -19,3 +19,4 @@ serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
siphasher = "0.3.0"
zebra-primitives = { path = "../primitives" }

View File

@ -2,11 +2,11 @@ extern crate blake2_rfc;
extern crate bn;
extern crate crypto as rcrypto;
extern crate ed25519_dalek as ed25519;
extern crate primitives;
extern crate rustc_hex as hex;
extern crate serde;
extern crate serde_json;
extern crate siphasher;
extern crate zebra_primitives;
pub extern crate bellman;
pub extern crate blake2b_simd as blake2;
@ -30,12 +30,12 @@ lazy_static! {
{ sapling_crypto::jubjub::JubjubBls12::new() };
}
use primitives::hash::{H160, H256, H32};
use rcrypto::ripemd160::Ripemd160;
use rcrypto::sha1::Sha1;
use rcrypto::sha2::Sha256;
use siphasher::sip::SipHasher24;
use std::hash::Hasher;
use zebra_primitives::hash::{H160, H256, H32};
pub use json::groth16::{
load_joinsplit_groth16_verifying_key, load_sapling_output_verifying_key,
@ -344,8 +344,8 @@ mod tests {
checksum, dhash160, dhash256, pedersen_hash, ripemd160, sha1, sha256, sha256_compress,
siphash24,
};
use primitives::bytes::Bytes;
use primitives::hash::H256;
use zebra_primitives::bytes::Bytes;
use zebra_primitives::hash::H256;
#[test]
fn test_ripemd160() {

View File

@ -1,7 +1,8 @@
[package]
name = "db"
name = "zebra-db"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies]
parity-rocksdb = { git = "https://github.com/paritytech/rust-rocksdb" }
@ -10,11 +11,11 @@ parking_lot = "0.8"
log = "0.4"
bit-vec = "0.4"
lru-cache = "0.1"
primitives = { path = "../primitives" }
serialization = { path = "../serialization" }
chain = { path = "../chain" }
storage = { path = "../storage" }
zebra-primitives = { path = "../primitives" }
zebra-serialization = { path = "../serialization" }
zebra-chain = { path = "../chain" }
zebra-storage = { path = "../storage" }
[dev-dependencies]
tempdir = "0.3"
test-data = { path = "../test-data" }
zebra-test-data = { path = "../test-data" }

View File

@ -1,5 +1,4 @@
use bytes::Bytes;
use chain::{IndexedBlock, IndexedBlockHeader, IndexedTransaction, OutPoint, TransactionOutput};
use hash::H256;
use kv::{
AutoFlushingOverlayDatabase, CacheDatabase, DatabaseConfig, DiskDatabase, Key, KeyState,
@ -16,7 +15,10 @@ use ser::{deserialize, serialize, List};
use std::collections::HashMap;
use std::fs;
use std::path::Path;
use storage::{
use zebra_chain::{
IndexedBlock, IndexedBlockHeader, IndexedTransaction, OutPoint, TransactionOutput,
};
use zebra_storage::{
BestBlock, BlockChain, BlockHeaderProvider, BlockOrigin, BlockProvider, BlockRef, CanonStore,
EpochRef, EpochTag, Error, ForkChain, Forkable, NullifierTracker, SaplingTreeState,
SideChainOrigin, SproutTreeState, Store, TransactionMeta, TransactionMetaProvider,

View File

@ -1,8 +1,8 @@
use chain::BlockHeader;
use hash::H256;
use kv::{Key, KeyState, KeyValue, KeyValueDatabase, Operation, Transaction, Value};
use lru_cache::LruCache;
use parking_lot::Mutex;
use zebra_chain::BlockHeader;
pub struct CacheDatabase<T>
where

View File

@ -1,5 +1,4 @@
use bytes::Bytes;
use chain::{BlockHeader, Transaction as ChainTransaction};
use hash::H256;
use kv::{Key, KeyState, KeyValue, KeyValueDatabase, Operation, Transaction, Value};
use parking_lot::RwLock;
@ -7,7 +6,8 @@ use ser::List;
use std::collections::HashMap;
use std::mem::replace;
use std::sync::Arc;
use storage::{EpochRef, EpochTag, SaplingTreeState, SproutTreeState, TransactionMeta};
use zebra_chain::{BlockHeader, Transaction as ChainTransaction};
use zebra_storage::{EpochRef, EpochTag, SaplingTreeState, SproutTreeState, TransactionMeta};
#[derive(Default, Debug)]
struct InnerDatabase {

View File

@ -1,8 +1,8 @@
use bytes::Bytes;
use chain::{BlockHeader, Transaction as ChainTransaction};
use hash::H256;
use ser::{deserialize, serialize, List};
use storage::{EpochRef, EpochTag, SaplingTreeState, SproutTreeState, TransactionMeta};
use zebra_chain::{BlockHeader, Transaction as ChainTransaction};
use zebra_storage::{EpochRef, EpochTag, SaplingTreeState, SproutTreeState, TransactionMeta};
pub const COL_COUNT: u32 = 16;
pub const COL_META: u32 = 0;

View File

@ -6,13 +6,13 @@ extern crate log;
extern crate bit_vec;
extern crate lru_cache;
extern crate chain;
extern crate primitives;
extern crate serialization as ser;
extern crate storage;
extern crate zebra_chain;
extern crate zebra_primitives;
extern crate zebra_serialization as ser;
extern crate zebra_storage;
mod block_chain_db;
pub mod kv;
pub use block_chain_db::{BlockChainDatabase, ForkChainDatabase};
pub use primitives::{bytes, hash};
pub use zebra_primitives::{bytes, hash};

View File

@ -1,19 +1,19 @@
extern crate chain;
extern crate db;
extern crate storage;
extern crate test_data;
extern crate zebra_chain;
extern crate zebra_db;
extern crate zebra_storage;
extern crate zebra_test_data;
use chain::IndexedBlock;
use db::kv::{MemoryDatabase, SharedMemoryDatabase};
use db::BlockChainDatabase;
use storage::{BlockProvider, ForkChain, SideChainOrigin};
use zebra_chain::IndexedBlock;
use zebra_db::kv::{MemoryDatabase, SharedMemoryDatabase};
use zebra_db::BlockChainDatabase;
use zebra_storage::{BlockProvider, ForkChain, SideChainOrigin};
#[test]
fn insert_block() {
let store = BlockChainDatabase::open(MemoryDatabase::default());
let b0: IndexedBlock = test_data::block_h0().into();
let b1: IndexedBlock = test_data::block_h1().into();
let b2: IndexedBlock = test_data::block_h2().into();
let b0: IndexedBlock = zebra_test_data::block_h0().into();
let b1: IndexedBlock = zebra_test_data::block_h1().into();
let b2: IndexedBlock = zebra_test_data::block_h2().into();
store.insert(b0.clone()).unwrap();
store.insert(b1.clone()).unwrap();
@ -51,9 +51,9 @@ fn insert_block() {
#[test]
fn reopen_db() {
let shared_database = SharedMemoryDatabase::default();
let b0: IndexedBlock = test_data::block_h0().into();
let b1: IndexedBlock = test_data::block_h1().into();
let b2: IndexedBlock = test_data::block_h2().into();
let b0: IndexedBlock = zebra_test_data::block_h0().into();
let b1: IndexedBlock = zebra_test_data::block_h1().into();
let b2: IndexedBlock = zebra_test_data::block_h2().into();
{
let store = BlockChainDatabase::open(shared_database.clone());
@ -78,9 +78,9 @@ fn reopen_db() {
#[test]
fn switch_to_simple_fork() {
let store = BlockChainDatabase::open(MemoryDatabase::default());
let b0: IndexedBlock = test_data::block_h0().into();
let b1: IndexedBlock = test_data::block_h1().into();
let b2: IndexedBlock = test_data::block_h2().into();
let b0: IndexedBlock = zebra_test_data::block_h0().into();
let b1: IndexedBlock = zebra_test_data::block_h1().into();
let b2: IndexedBlock = zebra_test_data::block_h2().into();
store.insert(b0.clone()).unwrap();
store.insert(b1.clone()).unwrap();

View File

@ -1,4 +1,4 @@
extern crate bitcrypto as crypto;
extern crate zebra_crypto;
fn target(data: &[u8]) {
crypto::ripemd160(data);

View File

@ -1,10 +1,11 @@
[package]
name = "import"
name = "zebra-import"
version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies]
log = "0.4"
primitives = { path = "../primitives" }
chain = { path = "../chain" }
serialization = { path = "../serialization" }
zebra-primitives = { path = "../primitives" }
zebra-chain = { path = "../chain" }
zebra-serialization = { path = "../serialization" }

View File

@ -1,7 +1,7 @@
use chain::IndexedBlock;
use hash::H32;
use ser::{Deserializable, Error as ReaderError, Reader};
use std::io;
use zebra_chain::IndexedBlock;
#[derive(Debug, PartialEq)]
pub struct Block {

View File

@ -2,14 +2,14 @@
#[macro_use]
extern crate log;
extern crate chain;
extern crate primitives;
extern crate serialization as ser;
extern crate zebra_chain;
extern crate zebra_primitives;
extern crate zebra_serialization as ser;
mod blk;
mod block;
mod fs;
pub use primitives::{bytes, hash};
pub use zebra_primitives::{bytes, hash};
pub use blk::{open_blk_dir, BlkDir};

View File

@ -1,13 +1,14 @@
[package]
name = "keys"
name = "zebra-keys"
version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies]
rand = "0.4"
rustc-hex = "2"
lazy_static = "1.3"
base58 = "0.1"
eth-secp256k1 = { git = "https://github.com/ethcore/rust-secp256k1" }
bitcrypto = { path = "../crypto" }
primitives = { path = "../primitives" }
eth-secp256k1 = "0.5.7"
zebra-crypto = { path = "../crypto" }
zebra-primitives = { path = "../primitives" }

View File

@ -6,11 +6,11 @@
//! https://en.bitcoin.it/wiki/Address
use base58::{FromBase58, ToBase58};
use crypto::checksum;
use network::Network;
use std::fmt;
use std::ops::Deref;
use std::str::FromStr;
use zebra_crypto::checksum;
use {AddressHash, DisplayLayout, Error};
/// There are two transparent address formats currently in use.

View File

@ -88,7 +88,7 @@ impl KeyPair {
#[cfg(test)]
mod tests {
use super::KeyPair;
use crypto::dhash256;
use zebra_crypto::dhash256;
use Public;
/// Tests from:

View File

@ -5,9 +5,9 @@ extern crate rustc_hex as hex;
#[macro_use]
extern crate lazy_static;
extern crate base58;
extern crate bitcrypto as crypto;
extern crate primitives;
extern crate secp256k1;
extern crate zebra_crypto;
extern crate zebra_primitives;
mod address;
mod display;
@ -19,7 +19,7 @@ mod private;
mod public;
mod signature;
pub use primitives::{bytes, hash};
pub use zebra_primitives::{bytes, hash};
pub use address::{Address, Type};
pub use display::DisplayLayout;

View File

@ -1,7 +1,6 @@
//! Secret with additional network identifier and format type
use base58::{FromBase58, ToBase58};
use crypto::checksum;
use hash::H520;
use hex::ToHex;
use network::Network;
@ -9,6 +8,7 @@ use secp256k1::key;
use secp256k1::Message as SecpMessage;
use std::fmt;
use std::str::FromStr;
use zebra_crypto::checksum;
use {CompactSignature, DisplayLayout, Error, Message, Secret, Signature, SECP256K1};
/// Secret with additional network identifier and format type

View File

@ -1,4 +1,3 @@
use crypto::dhash160;
use hash::{H264, H520};
use hex::ToHex;
use secp256k1::key;
@ -7,6 +6,7 @@ use secp256k1::{
Signature as SecpSignature,
};
use std::{fmt, ops};
use zebra_crypto::dhash160;
use {AddressHash, CompactSignature, Error, Message, Signature, SECP256K1};
/// Secret public key

View File

@ -1,7 +1,8 @@
[package]
name = "logs"
name = "zebra-logs"
version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies]
ansi_term = "0.11"

View File

@ -1,14 +1,15 @@
[package]
name = "message"
name = "zebra-message"
version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies]
byteorder = "1.0"
bitcrypto = { path = "../crypto" }
chain = { path = "../chain" }
primitives = { path = "../primitives" }
serialization = { path = "../serialization" }
serialization_derive = { path = "../serialization_derive" }
network = { path = "../network" }
zebra-crypto = { path = "../crypto" }
zebra-chain = { path = "../chain" }
zebra-primitives = { path = "../primitives" }
zebra-serialization = { path = "../serialization" }
zebra-serialization_derive = { path = "../serialization_derive" }
zebra-network = { path = "../network" }

View File

@ -1,5 +1,5 @@
use chain::{BlockHeader, ShortTransactionID};
use common::PrefilledTransaction;
use zebra_chain::{BlockHeader, ShortTransactionID};
#[derive(Debug, PartialEq, Serializable, Deserializable)]
pub struct BlockHeaderAndIDs {

View File

@ -1,5 +1,5 @@
use chain::Transaction;
use hash::H256;
use zebra_chain::Transaction;
#[derive(Debug, PartialEq, Serializable, Deserializable)]
pub struct BlockTransactions {

View File

@ -1,6 +1,6 @@
use chain::Transaction;
use ser::{CompactInteger, Deserializable, Error as ReaderError, Reader, Serializable, Stream};
use std::io;
use zebra_chain::Transaction;
#[derive(Debug, PartialEq)]
pub struct PrefilledTransaction {

View File

@ -1,11 +1,11 @@
extern crate bitcrypto as crypto;
extern crate byteorder;
extern crate chain;
extern crate primitives;
extern crate serialization as ser;
extern crate zebra_chain;
extern crate zebra_crypto;
extern crate zebra_primitives;
extern crate zebra_serialization as ser;
#[macro_use]
extern crate serialization_derive;
extern crate network;
extern crate zebra_serialization_derive;
extern crate zebra_network;
pub mod common;
mod error;
@ -13,7 +13,7 @@ mod message;
mod serialization;
pub mod types;
pub use primitives::{bytes, hash};
pub use zebra_primitives::{bytes, hash};
pub use common::{Command, Services};
pub use error::{Error, MessageResult};

View File

@ -1,8 +1,8 @@
use bytes::{Bytes, TaggedBytes};
use common::Command;
use network::Magic;
use ser::Stream;
use serialization::serialize_payload;
use zebra_network::Magic;
use {MessageHeader, MessageResult, Payload};
pub fn to_raw_message(magic: Magic, command: Command, payload: &Bytes) -> Bytes {

View File

@ -1,8 +1,8 @@
use common::Command;
use crypto::checksum;
use hash::H32;
use network::Magic;
use ser::{Reader, Serializable, Stream};
use zebra_crypto::checksum;
use zebra_network::Magic;
use Error;
#[derive(Debug, PartialEq)]
@ -62,8 +62,8 @@ impl Serializable for MessageHeader {
mod tests {
use super::MessageHeader;
use bytes::Bytes;
use network::Network;
use ser::serialize;
use zebra_network::Network;
#[test]
fn test_message_header_serialization() {

View File

@ -1,6 +1,6 @@
use chain::Block as ChainBlock;
use ser::{Reader, Stream};
use std::io;
use zebra_chain::Block as ChainBlock;
use {MessageResult, Payload};
#[derive(Debug, PartialEq)]

View File

@ -1,6 +1,6 @@
use chain::BlockHeader;
use ser::{CompactInteger, Deserializable, Error as ReaderError, Reader, Serializable, Stream};
use std::io;
use zebra_chain::BlockHeader;
use {MessageResult, Payload};
pub const HEADERS_MAX_HEADERS_LEN: usize = 160;

View File

@ -1,8 +1,8 @@
use bytes::Bytes;
use chain::BlockHeader;
use hash::H256;
use ser::{Reader, Stream};
use std::io;
use zebra_chain::BlockHeader;
use {MessageResult, Payload};
#[derive(Debug, PartialEq)]

View File

@ -1,6 +1,6 @@
use chain::Transaction;
use ser::{Reader, Stream};
use std::io;
use zebra_chain::Transaction;
use {MessageResult, Payload};
#[derive(Debug, PartialEq)]

View File

@ -1,24 +1,25 @@
[package]
name = "miner"
name = "zebra-miner"
version = "0.1.0"
authors = ["Ethcore <admin@ethcore.io>"]
license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies]
byteorder = "1.0"
heapsize = "0.4"
bitcrypto = { path = "../crypto" }
chain = { path = "../chain" }
storage = { path = "../storage" }
db = { path = "../db" }
network = { path = "../network" }
primitives = { path = "../primitives" }
serialization = { path = "../serialization" }
verification = { path = "../verification" }
keys = { path = "../keys" }
script = { path = "../script" }
zebra-crypto = { path = "../crypto" }
zebra-chain = { path = "../chain" }
zebra-storage = { path = "../storage" }
zebra-db = { path = "../db" }
zebra-network = { path = "../network" }
zebra-primitives = { path = "../primitives" }
zebra-serialization = { path = "../serialization" }
zebra-verification = { path = "../verification" }
zebra-keys = { path = "../keys" }
zebra-script = { path = "../script" }
[dev-dependencies]
test-data = { path = "../test-data" }
zebra-test-data = { path = "../test-data" }
[features]
test-helpers = []

View File

@ -1,10 +1,10 @@
#![feature(test)]
extern crate chain;
extern crate miner;
extern crate primitives;
extern crate serialization as ser;
extern crate test;
extern crate zebra_chain;
extern crate zebra_miner;
extern crate zebra_primitives;
extern crate zebra_serialization as ser;
#[cfg(test)]
mod benchmarks {

View File

@ -1,16 +1,16 @@
use chain::{
use memory_pool::{Entry, MemoryPool, OrderingStrategy};
use std::collections::HashSet;
use zebra_chain::{
IndexedTransaction, OutPoint, Transaction, TransactionInput, TransactionOutput,
SAPLING_TX_VERSION, SAPLING_TX_VERSION_GROUP_ID,
};
use keys::Address;
use memory_pool::{Entry, MemoryPool, OrderingStrategy};
use network::ConsensusParams;
use primitives::compact::Compact;
use primitives::hash::H256;
use script::Builder;
use std::collections::HashSet;
use storage::{SaplingTreeState, SharedStore, TransactionOutputProvider};
use verification::{transaction_sigops, work_required};
use zebra_keys::Address;
use zebra_network::ConsensusParams;
use zebra_primitives::compact::Compact;
use zebra_primitives::hash::H256;
use zebra_script::Builder;
use zebra_storage::{SaplingTreeState, SharedStore, TransactionOutputProvider};
use zebra_verification::{transaction_sigops, work_required};
const BLOCK_VERSION: u32 = 4;
const BLOCK_HEADER_SIZE: u32 = 4 + 32 + 32 + 32 + 4 + 4 + 32 + 1344;
@ -385,18 +385,18 @@ impl<'a> BlockAssembler<'a> {
#[cfg(test)]
mod tests {
extern crate test_data;
extern crate zebra_test_data;
use self::test_data::{ChainBuilder, TransactionBuilder};
use self::zebra_test_data::{ChainBuilder, TransactionBuilder};
use super::{BlockAssembler, BlockTemplate, NextStep, SizePolicy};
use chain::IndexedTransaction;
use db::BlockChainDatabase;
use fee::{FeeCalculator, NonZeroFeeCalculator};
use memory_pool::MemoryPool;
use network::{ConsensusParams, Network};
use primitives::hash::H256;
use std::sync::Arc;
use storage::SharedStore;
use zebra_chain::IndexedTransaction;
use zebra_db::BlockChainDatabase;
use zebra_network::{ConsensusParams, Network};
use zebra_primitives::hash::H256;
use zebra_storage::SharedStore;
#[test]
fn test_size_policy() {
@ -478,7 +478,7 @@ mod tests {
let mut pool = MemoryPool::new();
let storage: SharedStore = Arc::new(BlockChainDatabase::init_test_chain(vec![
test_data::genesis().into(),
zebra_test_data::genesis().into(),
]));
pool.insert_verified(chain.at(0).into(), &NonZeroFeeCalculator);
pool.insert_verified(chain.at(1).into(), &NonZeroFeeCalculator);
@ -506,15 +506,15 @@ mod tests {
#[test]
fn block_assembler_miner_fee() {
let input_tx = test_data::block_h1().transactions[0].clone();
let input_tx = zebra_test_data::block_h1().transactions[0].clone();
let tx0: IndexedTransaction = TransactionBuilder::with_input(&input_tx, 0)
.set_output(10_000)
.into();
let expected_tx0_fee = input_tx.outputs[0].value - tx0.raw.total_spends();
let storage: SharedStore = Arc::new(BlockChainDatabase::init_test_chain(vec![
test_data::genesis().into(),
test_data::block_h1().into(),
zebra_test_data::genesis().into(),
zebra_test_data::block_h1().into(),
]));
let mut pool = MemoryPool::new();
pool.insert_verified(

View File

@ -1,7 +1,7 @@
use chain::Transaction;
use ser::Serializable;
use storage::{DuplexTransactionOutputProvider, TransactionOutputProvider};
use verification::checked_transaction_fee;
use zebra_chain::Transaction;
use zebra_storage::{DuplexTransactionOutputProvider, TransactionOutputProvider};
use zebra_verification::checked_transaction_fee;
use MemoryPool;
/// Transaction fee calculator for memory pool
@ -48,13 +48,13 @@ pub fn transaction_fee_rate(store: &TransactionOutputProvider, tx: &Transaction)
#[cfg(test)]
mod tests {
use super::transaction_fee_rate;
use db::BlockChainDatabase;
use std::sync::Arc;
use storage::AsSubstore;
use zebra_db::BlockChainDatabase;
use zebra_storage::AsSubstore;
#[test]
fn transaction_fee_rate_works() {
let b0 = test_data::block_builder()
let b0 = zebra_test_data::block_builder()
.header()
.nonce(1.into())
.build()
@ -69,7 +69,7 @@ mod tests {
.build();
let tx0 = b0.transactions[0].clone();
let tx0_hash = tx0.hash();
let b1 = test_data::block_builder()
let b1 = zebra_test_data::block_builder()
.header()
.parent(b0.hash().clone())
.nonce(2.into())

View File

@ -1,16 +1,16 @@
extern crate byteorder;
extern crate heapsize;
extern crate bitcrypto as crypto;
extern crate chain;
extern crate db;
extern crate keys;
extern crate network;
extern crate primitives;
extern crate script;
extern crate serialization as ser;
extern crate storage;
extern crate verification;
extern crate zebra_chain;
extern crate zebra_crypto;
extern crate zebra_db;
extern crate zebra_keys;
extern crate zebra_network;
extern crate zebra_primitives;
extern crate zebra_script;
extern crate zebra_serialization as ser;
extern crate zebra_storage;
extern crate zebra_verification;
mod block_assembler;
mod fee;

View File

@ -5,11 +5,8 @@
//! transactions.
//! It also guarantees that ancestor-descendant relation won't break during ordered removal (ancestors always removed
//! before descendants). Removal using `remove_by_hash` can break this rule.
use chain::{IndexedTransaction, OutPoint, Transaction, TransactionOutput};
use fee::MemoryPoolFeeCalculator;
use heapsize::HeapSizeOf;
use primitives::bytes::Bytes;
use primitives::hash::H256;
use ser::{serialize, Serializable};
use std::cmp::Ordering;
use std::collections::BTreeSet;
@ -17,7 +14,10 @@ use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::hash::{Hash, Hasher};
use storage::{TransactionOutputProvider, TransactionProvider};
use zebra_chain::{IndexedTransaction, OutPoint, Transaction, TransactionOutput};
use zebra_primitives::bytes::Bytes;
use zebra_primitives::hash::H256;
use zebra_storage::{TransactionOutputProvider, TransactionProvider};
/// Transactions ordering strategy
#[cfg_attr(feature = "cargo-clippy", allow(enum_variant_names))]
@ -1070,13 +1070,13 @@ impl<'a> Iterator for MemoryPoolIterator<'a> {
#[cfg(test)]
pub mod tests {
extern crate test_data;
extern crate zebra_test_data;
use self::test_data::{ChainBuilder, TransactionBuilder};
use self::zebra_test_data::{ChainBuilder, TransactionBuilder};
use super::{DoubleSpendCheckResult, MemoryPool, OrderingStrategy};
use chain::{OutPoint, Transaction};
use fee::NonZeroFeeCalculator;
use heapsize::HeapSizeOf;
use zebra_chain::{OutPoint, Transaction};
fn to_memory_pool(chain: &mut ChainBuilder) -> MemoryPool {
let mut pool = MemoryPool::new();

View File

@ -1,13 +1,14 @@
[package]
name = "network"
name = "zebra-network"
version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies]
lazy_static = "1.3"
chain = { path = "../chain" }
keys = { path = "../keys" }
primitives = { path = "../primitives" }
serialization = { path = "../serialization" }
bitcrypto = { path = "../crypto" }
rustc-hex = "2"
zebra-chain = { path = "../chain" }
zebra-keys = { path = "../keys" }
zebra-primitives = { path = "../primitives" }
zebra-serialization = { path = "../serialization" }
zebra-crypto = { path = "../crypto" }

View File

@ -1,15 +1,16 @@
use keys::Address;
use {crypto, Deployment, Magic, Network};
use zebra_crypto;
use zebra_keys::Address;
use {Deployment, Magic, Network};
lazy_static! {
static ref SAPLING_SPEND_VK: crypto::Groth16VerifyingKey =
crypto::load_sapling_spend_verifying_key()
static ref SAPLING_SPEND_VK: zebra_crypto::Groth16VerifyingKey =
zebra_crypto::load_sapling_spend_verifying_key()
.expect("hardcoded value should load without errors");
static ref SAPLING_OUTPUT_VK: crypto::Groth16VerifyingKey =
crypto::load_sapling_output_verifying_key()
static ref SAPLING_OUTPUT_VK: zebra_crypto::Groth16VerifyingKey =
zebra_crypto::load_sapling_output_verifying_key()
.expect("hardcoded value should load without errors");
static ref JOINSPLIT_GROTH16_VK: crypto::Groth16VerifyingKey =
crypto::load_joinsplit_groth16_verifying_key()
static ref JOINSPLIT_GROTH16_VK: zebra_crypto::Groth16VerifyingKey =
zebra_crypto::load_joinsplit_groth16_verifying_key()
.expect("hardcoded value should load without errors");
}
@ -76,19 +77,19 @@ pub struct ConsensusParams {
pub equihash_params: Option<(u32, u32)>,
/// Active key for pghr13 joinsplit verification
pub joinsplit_verification_key: crypto::Pghr13VerifyingKey,
pub joinsplit_verification_key: zebra_crypto::Pghr13VerifyingKey,
/// Active key for groth16 joinsplit verification
pub joinsplit_groth16_verification_key: &'static crypto::Groth16VerifyingKey,
pub joinsplit_groth16_verification_key: &'static zebra_crypto::Groth16VerifyingKey,
/// Sapling spend verification key.
pub sapling_spend_verifying_key: &'static crypto::Groth16VerifyingKey,
pub sapling_spend_verifying_key: &'static zebra_crypto::Groth16VerifyingKey,
/// Sapling output verification key.
pub sapling_output_verifying_key: &'static crypto::Groth16VerifyingKey,
pub sapling_output_verifying_key: &'static zebra_crypto::Groth16VerifyingKey,
}
fn mainnet_pghr_verification_key() -> crypto::Pghr13VerifyingKey {
crypto::json::pghr13::decode(include_bytes!("../../res/sprout-verifying-key.json"))
fn mainnet_pghr_verification_key() -> zebra_crypto::Pghr13VerifyingKey {
zebra_crypto::json::pghr13::decode(include_bytes!("../../res/sprout-verifying-key.json"))
.expect("verifying key json invalid")
.into()
}

View File

@ -1,18 +1,18 @@
#[macro_use]
extern crate lazy_static;
extern crate bitcrypto as crypto;
extern crate chain;
extern crate keys;
extern crate primitives;
extern crate rustc_hex as hex;
extern crate serialization;
extern crate zebra_chain;
extern crate zebra_crypto;
extern crate zebra_keys;
extern crate zebra_primitives;
extern crate zebra_serialization;
mod consensus;
mod deployments;
mod network;
pub use primitives::{compact, hash};
pub use zebra_primitives::{compact, hash};
pub use consensus::ConsensusParams;
pub use deployments::Deployment;

View File

@ -1,10 +1,10 @@
//! Bitcoin network
//! https://www.anintegratedworld.com/unravelling-the-mysterious-block-chain-magic-number/
use chain::IndexedBlock;
use compact::Compact;
use primitives::bigint::U256;
use primitives::hash::H256;
use zebra_chain::IndexedBlock;
use zebra_primitives::bigint::U256;
use zebra_primitives::hash::H256;
const ZCASH_MAGIC_MAINNET: u32 = 0x6427e924;
const ZCASH_MAGIC_TESTNET: u32 = 0xbff91afa;

View File

@ -1,7 +1,8 @@
[package]
name = "p2p"
name = "zebra-p2p"
version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies]
tokio-core = "0.1.6"
@ -16,8 +17,8 @@ abstract-ns = "0.3"
ns-dns-tokio = "0.3"
csv = "1"
primitives = { path = "../primitives" }
bitcrypto = { path = "../crypto" }
message = { path = "../message" }
serialization = { path = "../serialization" }
network = { path = "../network" }
zebra-primitives = { path = "../primitives" }
zebra-crypto = { path = "../crypto" }
zebra-message = { path = "../message" }
zebra-serialization = { path = "../serialization" }
zebra-network = { path = "../network" }

View File

@ -1,7 +1,7 @@
use message::common::Services;
use net::Config as NetConfig;
use std::{net, path};
use util::InternetProtocol;
use zebra_message::common::Services;
#[derive(Debug, Clone)]
pub struct Config {

View File

@ -1,10 +1,10 @@
use futures::{Async, Future, Poll};
use io::{read_message, write_message, ReadMessage, WriteMessage};
use message::types::{Verack, Version};
use message::{Error, Message, MessageResult};
use network::Magic;
use std::{cmp, io};
use tokio_io::{AsyncRead, AsyncWrite};
use zebra_message::types::{Verack, Version};
use zebra_message::{Error, Message, MessageResult};
use zebra_network::Magic;
pub fn handshake<A>(a: A, magic: Magic, version: Version, min_version: u32) -> Handshake<A>
where
@ -241,13 +241,13 @@ mod tests {
use super::{accept_handshake, handshake, HandshakeResult};
use bytes::Bytes;
use futures::{Future, Poll};
use message::types::version::{Version, V0, V106, V70001};
use message::types::Verack;
use message::{Error, Message};
use network::Network;
use ser::Stream;
use std::io;
use tokio_io::{AsyncRead, AsyncWrite};
use zebra_message::types::version::{Version, V0, V106, V70001};
use zebra_message::types::Verack;
use zebra_message::{Error, Message};
use zebra_network::Network;
pub struct TestIo {
read: io::Cursor<Bytes>,

View File

@ -1,12 +1,12 @@
use bytes::Bytes;
use crypto::checksum;
use futures::{Async, Future, Poll};
use io::{read_header, ReadHeader};
use message::{Command, Error, MessageHeader, MessageResult};
use network::Magic;
use std::io;
use tokio_io::io::{read_exact, ReadExact};
use tokio_io::AsyncRead;
use zebra_crypto::checksum;
use zebra_message::{Command, Error, MessageHeader, MessageResult};
use zebra_network::Magic;
pub fn read_any_message<A>(a: A, magic: Magic) -> ReadAnyMessage<A>
where
@ -73,8 +73,8 @@ mod tests {
use super::read_any_message;
use bytes::Bytes;
use futures::Future;
use message::Error;
use network::Network;
use zebra_message::Error;
use zebra_network::Network;
#[test]
fn test_read_any_message() {

View File

@ -1,9 +1,9 @@
use futures::{Async, Future, Poll};
use message::{MessageHeader, MessageResult};
use network::Magic;
use std::io;
use tokio_io::io::{read_exact, ReadExact};
use tokio_io::AsyncRead;
use zebra_message::{MessageHeader, MessageResult};
use zebra_network::Magic;
pub fn read_header<A>(a: A, magic: Magic) -> ReadHeader<A>
where
@ -39,8 +39,8 @@ mod tests {
use super::read_header;
use bytes::Bytes;
use futures::Future;
use message::{Error, MessageHeader};
use network::Network;
use zebra_message::{Error, MessageHeader};
use zebra_network::Network;
#[test]
fn test_read_header() {

View File

@ -1,10 +1,10 @@
use futures::{Async, Future, Poll};
use io::{read_header, read_payload, ReadHeader, ReadPayload};
use message::{Error, MessageResult, Payload};
use network::Magic;
use std::io;
use std::marker::PhantomData;
use tokio_io::AsyncRead;
use zebra_message::{Error, MessageResult, Payload};
use zebra_network::Magic;
pub fn read_message<M, A>(a: A, magic: Magic, version: u32) -> ReadMessage<M, A>
where
@ -72,9 +72,9 @@ mod tests {
use super::read_message;
use bytes::Bytes;
use futures::Future;
use message::types::{Ping, Pong};
use message::Error;
use network::Network;
use zebra_message::types::{Ping, Pong};
use zebra_message::Error;
use zebra_network::Network;
#[test]
fn test_read_message() {

View File

@ -1,12 +1,12 @@
use bytes::Bytes;
use crypto::checksum;
use futures::{Future, Poll};
use hash::H32;
use message::{deserialize_payload, Error, MessageResult, Payload};
use std::io;
use std::marker::PhantomData;
use tokio_io::io::{read_exact, ReadExact};
use tokio_io::AsyncRead;
use zebra_crypto::checksum;
use zebra_message::{deserialize_payload, Error, MessageResult, Payload};
pub fn read_payload<M, A>(a: A, version: u32, len: usize, checksum: H32) -> ReadPayload<M, A>
where
@ -51,8 +51,8 @@ mod tests {
use super::read_payload;
use bytes::Bytes;
use futures::Future;
use message::types::Ping;
use message::Error;
use zebra_message::types::Ping;
use zebra_message::Error;
#[test]
fn test_read_payload() {

View File

@ -1,8 +1,8 @@
use futures::{Future, Poll};
use message::Message;
use std::io;
use tokio_io::io::{write_all, WriteAll};
use tokio_io::AsyncWrite;
use zebra_message::Message;
pub fn write_message<M, A>(a: A, message: Message<M>) -> WriteMessage<M, A>
where

View File

@ -12,11 +12,11 @@ extern crate abstract_ns;
extern crate csv;
extern crate ns_dns_tokio;
extern crate bitcrypto as crypto;
extern crate message;
extern crate network;
extern crate primitives;
extern crate serialization as ser;
extern crate zebra_crypto;
extern crate zebra_message;
extern crate zebra_network;
extern crate zebra_primitives;
extern crate zebra_serialization as ser;
mod config;
mod event_loop;
@ -27,7 +27,7 @@ mod protocol;
mod session;
mod util;
pub use primitives::{bytes, hash};
pub use zebra_primitives::{bytes, hash};
pub use config::Config;
pub use event_loop::{event_loop, forever};

View File

@ -1,12 +1,12 @@
use futures::{Future, Poll};
use io::{accept_handshake, deadline, AcceptHandshake, Deadline};
use message::MessageResult;
use net::{Config, Connection};
use network::Magic;
use std::time::Duration;
use std::{io, net};
use tokio_core::net::TcpStream;
use tokio_core::reactor::Handle;
use zebra_message::MessageResult;
use zebra_network::Magic;
pub fn accept_connection(
stream: TcpStream,

View File

@ -1,9 +1,9 @@
use message::common::{NetAddress, Services};
use message::types::version::{Version, V0, V106, V70001};
use network::Magic;
use std::net::SocketAddr;
use util::nonce::{NonceGenerator, RandomNonce};
use util::time::{RealTime, Time};
use zebra_message::common::{NetAddress, Services};
use zebra_message::types::version::{Version, V0, V106, V70001};
use zebra_network::Magic;
#[derive(Debug, Clone)]
pub struct Config {

View File

@ -1,14 +1,14 @@
use futures::{Async, Future, Poll};
use io::{deadline, handshake, Deadline, Handshake};
use message::types::Version;
use message::Error;
use net::{Config, Connection};
use network::Magic;
use std::io;
use std::net::SocketAddr;
use std::time::Duration;
use tokio_core::net::{TcpStream, TcpStreamNew};
use tokio_core::reactor::Handle;
use zebra_message::types::Version;
use zebra_message::Error;
use zebra_network::Magic;
pub fn connect(address: &SocketAddr, handle: &Handle, config: &Config) -> Deadline<Connect> {
let connect = Connect {

View File

@ -1,8 +1,8 @@
use io::SharedTcpStream;
use message::common::Services;
use message::types;
use network::Magic;
use std::net;
use zebra_message::common::Services;
use zebra_message::types;
use zebra_network::Magic;
pub struct Connection {
pub stream: SharedTcpStream,

View File

@ -1,10 +1,10 @@
use futures::{finished, lazy};
use message::{Message, Payload};
use net::PeerStats;
use p2p::Context;
use parking_lot::Mutex;
use std::sync::Arc;
use util::{ConfigurableSynchronizer, PeerInfo, ResponseQueue, Responses, Synchronizer};
use zebra_message::{Message, Payload};
pub struct PeerContext {
context: Arc<Context>,

View File

@ -3,8 +3,8 @@ use std::collections::HashMap;
use std::time::Instant;
use util::interval::{Interval, RealInterval};
use message::types::{Ping, Pong};
use message::{Command, Payload};
use zebra_message::types::{Ping, Pong};
use zebra_message::{Command, Payload};
// delay somewhere near communication timeout
const ENORMOUS_PING_DELAY: f64 = 10f64;

View File

@ -3,9 +3,6 @@ use futures::stream::Stream;
use futures::{failed, finished, Future};
use futures_cpupool::{Builder as CpuPoolBuilder, CpuPool};
use io::DeadlineStatus;
use message::common::Services;
use message::types::addr::AddressEntry;
use message::{Message, MessageResult, Payload};
use net::{
accept_connection, connect, Channel, Config as NetConfig, ConnectionCounter, Connections,
};
@ -20,6 +17,9 @@ use tokio_core::net::{TcpListener, TcpStream};
use tokio_core::reactor::{Handle, Interval, Remote, Timeout};
use tokio_io::IoFuture;
use util::{Direction, Node, NodeTable, NodeTableError};
use zebra_message::common::Services;
use zebra_message::types::addr::AddressEntry;
use zebra_message::{Message, MessageResult, Payload};
use {Config, PeerId};
pub type BoxedEmptyFuture = Box<Future<Item = (), Error = ()> + Send>;

View File

@ -1,11 +1,11 @@
use bytes::Bytes;
use message::types::{Addr, GetAddr};
use message::{deserialize_payload, Command, Error, Payload};
use net::PeerContext;
use protocol::Protocol;
use std::sync::Arc;
use std::time::Duration;
use util::Direction;
use zebra_message::types::{Addr, GetAddr};
use zebra_message::{deserialize_payload, Command, Error, Payload};
pub struct AddrProtocol {
/// Context

View File

@ -3,8 +3,8 @@ mod ping;
mod sync;
use bytes::Bytes;
use message::common::Command;
use message::Error;
use zebra_message::common::Command;
use zebra_message::Error;
pub use self::addr::{AddrProtocol, SeednodeProtocol};
pub use self::ping::PingProtocol;

View File

@ -1,12 +1,12 @@
use bytes::Bytes;
use message::common::Command;
use message::types::{Ping, Pong};
use message::{deserialize_payload, Error, Payload};
use net::PeerContext;
use protocol::Protocol;
use std::sync::Arc;
use time;
use util::nonce::{NonceGenerator, RandomNonce};
use zebra_message::common::Command;
use zebra_message::types::{Ping, Pong};
use zebra_message::{deserialize_payload, Error, Payload};
/// Time that must pass since last message from this peer, before we send ping request
const PING_INTERVAL_S: f64 = 60f64;

View File

@ -1,8 +1,8 @@
use bytes::Bytes;
use message::{deserialize_payload, types, Command, Error, Payload, Services};
use net::PeerContext;
use protocol::Protocol;
use std::sync::Arc;
use zebra_message::{deserialize_payload, types, Command, Error, Payload, Services};
pub type InboundSyncConnectionRef = Box<InboundSyncConnection>;
pub type OutboundSyncConnectionRef = Arc<OutboundSyncConnection>;

View File

@ -1,11 +1,11 @@
use bytes::Bytes;
use message::{Command, Error};
use net::{PeerContext, PeerStats};
use p2p::Context;
use parking_lot::Mutex;
use protocol::{AddrProtocol, PingProtocol, Protocol, SeednodeProtocol, SyncProtocol};
use std::sync::Arc;
use util::PeerInfo;
use zebra_message::{Command, Error};
pub trait SessionFactory {
fn new_session(context: Arc<Context>, info: PeerInfo, synchronous: bool) -> Session;

View File

@ -1,6 +1,4 @@
use csv;
use message::common::{NetAddress, Services};
use message::types::addr::AddressEntry;
use std::cmp::{Ord, Ordering, PartialOrd};
use std::collections::hash_map::Entry;
use std::collections::{BTreeSet, HashMap, HashSet};
@ -8,6 +6,8 @@ use std::net::SocketAddr;
use std::{fs, io, net, path};
use util::time::{RealTime, Time};
use util::InternetProtocol;
use zebra_message::common::{NetAddress, Services};
use zebra_message::types::addr::AddressEntry;
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Node {
@ -462,11 +462,11 @@ where
#[cfg(test)]
mod tests {
use super::NodeTable;
use message::common::Services;
use std::collections::HashSet;
use std::net::SocketAddr;
use util::time::{IncrementalTime, ZeroTime};
use util::InternetProtocol;
use zebra_message::common::Services;
#[test]
fn test_node_table_insert() {

View File

@ -1,6 +1,6 @@
use message::types;
use network::Magic;
use std::net::SocketAddr;
use zebra_message::types;
use zebra_network::Magic;
pub type PeerId = usize;

View File

@ -1,7 +1,8 @@
[package]
name = "primitives"
name = "zebra-primitives"
version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies]
heapsize = "0.4"

View File

@ -1,7 +1,8 @@
[package]
name = "rpc"
name = "zebra-rpc"
version = "0.1.0"
authors = ["Ethcore <admin@ethcore.io>"]
license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[lib]
@ -18,18 +19,18 @@ jsonrpc-derive = "10.0"
jsonrpc-pubsub = "10.0"
jsonrpc-http-server = "10.0"
sync = { path = "../sync" }
serialization = { path = "../serialization" }
chain = { path = "../chain" }
primitives = { path = "../primitives" }
p2p = { path = "../p2p" }
network = { path = "../network" }
storage = { path = "../storage" }
db = { path = "../db" }
miner = { path = "../miner" }
verification = { path = "../verification" }
script = { path = "../script" }
keys = { path = "../keys" }
zebra-sync = { path = "../sync" }
zebra-serialization = { path = "../serialization" }
zebra-chain = { path = "../chain" }
zebra-primitives = { path = "../primitives" }
zebra-p2p = { path = "../p2p" }
zebra-network = { path = "../network" }
zebra-storage = { path = "../storage" }
zebra-db = { path = "../db" }
zebra-miner = { path = "../miner" }
zebra-verification = { path = "../verification" }
zebra-script = { path = "../script" }
zebra-keys = { path = "../keys" }
[dev-dependencies]
test-data = { path = "../test-data" }
zebra-test-data = { path = "../test-data" }

View File

@ -7,21 +7,21 @@ extern crate serde_derive;
extern crate jsonrpc_core;
#[macro_use]
extern crate jsonrpc_derive;
extern crate chain;
extern crate db;
extern crate jsonrpc_http_server;
extern crate keys;
extern crate miner;
extern crate network;
extern crate p2p;
extern crate primitives;
extern crate script as global_script;
extern crate serialization as ser;
extern crate storage;
extern crate sync;
extern crate time;
extern crate tokio_core;
extern crate verification;
extern crate zebra_chain;
extern crate zebra_db;
extern crate zebra_keys;
extern crate zebra_miner;
extern crate zebra_network;
extern crate zebra_p2p;
extern crate zebra_primitives;
extern crate zebra_script as global_script;
extern crate zebra_serialization as ser;
extern crate zebra_storage;
extern crate zebra_sync;
extern crate zebra_verification;
pub mod rpc_server;
pub mod v1;

View File

@ -1,11 +1,6 @@
use chain::OutPoint;
use global_script::Script;
use jsonrpc_core::Error;
use keys::{self, Address};
use network::{ConsensusParams, Network};
use primitives::hash::H256 as GlobalH256;
use ser::serialize;
use storage;
use v1::helpers::errors::{
block_at_height_not_found, block_not_found, invalid_params, transaction_not_found,
transaction_of_side_branch, transaction_output_not_found,
@ -15,7 +10,12 @@ use v1::types::GetTxOutSetInfoResponse;
use v1::types::H256;
use v1::types::{BlockRef, GetBlockResponse, RawBlock, VerboseBlock};
use v1::types::{GetTxOutResponse, TransactionOutputScript};
use verification;
use zebra_chain::OutPoint;
use zebra_keys::{self, Address};
use zebra_network::{ConsensusParams, Network};
use zebra_primitives::hash::H256 as GlobalH256;
use zebra_storage;
use zebra_verification;
pub struct BlockChainClient<T: BlockChainClientCoreApi> {
core: T,
@ -33,11 +33,11 @@ pub trait BlockChainClientCoreApi: Send + Sync + 'static {
pub struct BlockChainClientCore {
consensus: ConsensusParams,
storage: storage::SharedStore,
storage: zebra_storage::SharedStore,
}
impl BlockChainClientCore {
pub fn new(consensus: ConsensusParams, storage: storage::SharedStore) -> Self {
pub fn new(consensus: ConsensusParams, storage: zebra_storage::SharedStore) -> Self {
BlockChainClientCore {
consensus: consensus,
storage: storage,
@ -62,7 +62,7 @@ impl BlockChainClientCoreApi for BlockChainClientCore {
let best_block = self.storage.best_block();
let now = ::time::get_time().sec as u32;
let next_work_required = verification::work_required(
let next_work_required = zebra_verification::work_required(
best_block.hash,
now,
best_block.number + 1,
@ -163,10 +163,10 @@ impl BlockChainClientCoreApi for BlockChainClientCore {
.into_iter()
.map(|a| Address {
network: match self.consensus.network {
Network::Mainnet => keys::Network::Mainnet,
Network::Mainnet => zebra_keys::Network::Mainnet,
// there's no correct choices for Regtests && Other networks
// => let's just make Testnet key
_ => keys::Network::Testnet,
_ => zebra_keys::Network::Testnet,
},
hash: a.hash,
kind: a.kind,
@ -280,16 +280,11 @@ where
#[cfg(test)]
pub mod tests {
extern crate test_data;
extern crate zebra_test_data;
use super::*;
use chain::OutPoint;
use db::BlockChainDatabase;
use jsonrpc_core::Error;
use jsonrpc_core::IoHandler;
use network::Network;
use primitives::bytes::Bytes as GlobalBytes;
use primitives::hash::H256 as GlobalH256;
use std::sync::Arc;
use v1::helpers::errors::block_not_found;
use v1::traits::BlockChain;
@ -298,6 +293,11 @@ pub mod tests {
use v1::types::H256;
use v1::types::{GetTxOutResponse, TransactionOutputScript};
use v1::types::{RawBlock, VerboseBlock};
use zebra_chain::OutPoint;
use zebra_db::BlockChainDatabase;
use zebra_network::Network;
use zebra_primitives::bytes::Bytes as GlobalBytes;
use zebra_primitives::hash::H256 as GlobalH256;
#[derive(Default)]
struct SuccessBlockChainClientCore;
@ -306,7 +306,7 @@ pub mod tests {
impl BlockChainClientCoreApi for SuccessBlockChainClientCore {
fn best_block_hash(&self) -> GlobalH256 {
test_data::genesis().hash()
zebra_test_data::genesis().hash()
}
fn block_count(&self) -> u32 {
@ -314,7 +314,7 @@ pub mod tests {
}
fn block_hash(&self, _height: u32) -> Option<GlobalH256> {
Some(test_data::genesis().hash())
Some(zebra_test_data::genesis().hash())
}
fn difficulty(&self) -> f64 {
@ -375,7 +375,7 @@ pub mod tests {
impl BlockChainClientCoreApi for ErrorBlockChainClientCore {
fn best_block_hash(&self) -> GlobalH256 {
test_data::genesis().hash()
zebra_test_data::genesis().hash()
}
fn block_count(&self) -> u32 {
@ -511,9 +511,9 @@ pub mod tests {
#[test]
fn verbose_block_contents() {
let storage = Arc::new(BlockChainDatabase::init_test_chain(vec![
test_data::genesis().into(),
test_data::block_h1().into(),
test_data::block_h2().into(),
zebra_test_data::genesis().into(),
zebra_test_data::block_h1().into(),
zebra_test_data::block_h2().into(),
]));
let core = BlockChainClientCore::new(ConsensusParams::new(Network::Mainnet), storage);
@ -683,8 +683,8 @@ pub mod tests {
#[test]
fn verbose_transaction_out_contents() {
let storage = Arc::new(BlockChainDatabase::init_test_chain(vec![
test_data::genesis().into(),
test_data::block_h1().into(),
zebra_test_data::genesis().into(),
zebra_test_data::block_h1().into(),
]));
let core = BlockChainClientCore::new(ConsensusParams::new(Network::Mainnet), storage);

View File

@ -1,26 +1,26 @@
use jsonrpc_core::Error;
use keys::Address;
use miner;
use sync;
use v1::helpers::errors::execution;
use v1::traits::Miner;
use v1::types::{BlockTemplate, BlockTemplateRequest};
use zebra_keys::Address;
use zebra_miner;
use zebra_sync;
pub struct MinerClient<T: MinerClientCoreApi> {
core: T,
}
pub trait MinerClientCoreApi: Send + Sync + 'static {
fn get_block_template(&self) -> Result<miner::BlockTemplate, String>;
fn get_block_template(&self) -> Result<zebra_miner::BlockTemplate, String>;
}
pub struct MinerClientCore {
local_sync_node: sync::LocalNodeRef,
local_sync_node: zebra_sync::LocalNodeRef,
miner_address: Option<Address>,
}
impl MinerClientCore {
pub fn new(local_sync_node: sync::LocalNodeRef, miner_address: Option<Address>) -> Self {
pub fn new(local_sync_node: zebra_sync::LocalNodeRef, miner_address: Option<Address>) -> Self {
MinerClientCore {
local_sync_node: local_sync_node,
miner_address: miner_address,
@ -29,7 +29,7 @@ impl MinerClientCore {
}
impl MinerClientCoreApi for MinerClientCore {
fn get_block_template(&self) -> Result<miner::BlockTemplate, String> {
fn get_block_template(&self) -> Result<zebra_miner::BlockTemplate, String> {
self.miner_address
.as_ref()
.ok_or_else(|| "miner address not set".into())
@ -61,19 +61,19 @@ where
#[cfg(test)]
pub mod tests {
use super::*;
use chain;
use jsonrpc_core::IoHandler;
use miner;
use primitives::hash::H256;
use v1::traits::Miner;
use zebra_chain;
use zebra_miner;
use zebra_primitives::hash::H256;
#[derive(Default)]
struct SuccessMinerClientCore;
impl MinerClientCoreApi for SuccessMinerClientCore {
fn get_block_template(&self) -> Result<miner::BlockTemplate, String> {
let tx: chain::Transaction = "00000000013ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a0000000000000000000101000000000000000000000000".into();
Ok(miner::BlockTemplate {
fn get_block_template(&self) -> Result<zebra_miner::BlockTemplate, String> {
let tx: zebra_chain::Transaction = "00000000013ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a0000000000000000000101000000000000000000000000".into();
Ok(zebra_miner::BlockTemplate {
version: 777,
previous_header_hash: H256::from(1),
final_sapling_root_hash: H256::from(2),

View File

@ -1,16 +1,16 @@
use jsonrpc_core::Error;
use p2p;
use std::net::{IpAddr, SocketAddr};
use std::sync::Arc;
use v1::helpers::errors;
use v1::traits::Network as NetworkRpc;
use v1::types::{AddNodeOperation, NodeInfo};
use zebra_p2p;
pub trait NetworkApi: Send + Sync + 'static {
fn add_node(&self, socket_addr: SocketAddr) -> Result<(), p2p::NodeTableError>;
fn remove_node(&self, socket_addr: SocketAddr) -> Result<(), p2p::NodeTableError>;
fn add_node(&self, socket_addr: SocketAddr) -> Result<(), zebra_p2p::NodeTableError>;
fn remove_node(&self, socket_addr: SocketAddr) -> Result<(), zebra_p2p::NodeTableError>;
fn connect(&self, socket_addr: SocketAddr);
fn node_info(&self, node_addr: IpAddr) -> Result<NodeInfo, p2p::NodeTableError>;
fn node_info(&self, node_addr: IpAddr) -> Result<NodeInfo, zebra_p2p::NodeTableError>;
fn nodes_info(&self) -> Vec<NodeInfo>;
fn connection_count(&self) -> usize;
}
@ -77,38 +77,38 @@ where
}
pub struct NetworkClientCore {
p2p: Arc<p2p::Context>,
p2p: Arc<zebra_p2p::Context>,
}
impl NetworkClientCore {
pub fn new(p2p: Arc<p2p::Context>) -> Self {
pub fn new(p2p: Arc<zebra_p2p::Context>) -> Self {
NetworkClientCore { p2p: p2p }
}
}
impl NetworkApi for NetworkClientCore {
fn add_node(&self, socket_addr: SocketAddr) -> Result<(), p2p::NodeTableError> {
fn add_node(&self, socket_addr: SocketAddr) -> Result<(), zebra_p2p::NodeTableError> {
self.p2p.add_node(socket_addr)
}
fn remove_node(&self, socket_addr: SocketAddr) -> Result<(), p2p::NodeTableError> {
fn remove_node(&self, socket_addr: SocketAddr) -> Result<(), zebra_p2p::NodeTableError> {
self.p2p.remove_node(socket_addr)
}
fn connect(&self, socket_addr: SocketAddr) {
p2p::Context::connect_normal(self.p2p.clone(), socket_addr);
zebra_p2p::Context::connect_normal(self.p2p.clone(), socket_addr);
}
fn node_info(&self, node_addr: IpAddr) -> Result<NodeInfo, p2p::NodeTableError> {
fn node_info(&self, node_addr: IpAddr) -> Result<NodeInfo, zebra_p2p::NodeTableError> {
let exact_node = try!(self
.p2p
.nodes()
.iter()
.find(|n| n.address().ip() == node_addr)
.cloned()
.ok_or(p2p::NodeTableError::NoAddressInTable));
.ok_or(zebra_p2p::NodeTableError::NoAddressInTable));
let peers: Vec<p2p::PeerInfo> = self
let peers: Vec<zebra_p2p::PeerInfo> = self
.p2p
.connections()
.info()
@ -124,13 +124,13 @@ impl NetworkApi for NetworkClientCore {
}
fn nodes_info(&self) -> Vec<NodeInfo> {
let peers: Vec<p2p::PeerInfo> = self.p2p.connections().info();
let peers: Vec<zebra_p2p::PeerInfo> = self.p2p.connections().info();
self.p2p
.nodes()
.iter()
.map(|n| {
let node_peers: Vec<p2p::PeerInfo> = peers
let node_peers: Vec<zebra_p2p::PeerInfo> = peers
.iter()
.filter(|p| p.address == n.address())
.cloned()

View File

@ -1,12 +1,5 @@
use chain::{
IndexedTransaction as GlobalIndexedTransaction, Transaction as GlobalTransaction,
SAPLING_TX_VERSION, SAPLING_TX_VERSION_GROUP_ID,
};
use jsonrpc_core::Error;
use primitives::bytes::Bytes as GlobalBytes;
use primitives::hash::H256 as GlobalH256;
use ser::{deserialize, serialize, Reader};
use sync;
use v1::helpers::errors::{execution, invalid_params};
use v1::traits::Raw;
use v1::types::H256;
@ -14,6 +7,13 @@ use v1::types::{
GetRawTransactionResponse, RawTransaction, Transaction, TransactionInput, TransactionOutput,
TransactionOutputs,
};
use zebra_chain::{
IndexedTransaction as GlobalIndexedTransaction, Transaction as GlobalTransaction,
SAPLING_TX_VERSION, SAPLING_TX_VERSION_GROUP_ID,
};
use zebra_primitives::bytes::Bytes as GlobalBytes;
use zebra_primitives::hash::H256 as GlobalH256;
use zebra_sync;
/// Default expiry height delta (best blocks number + height in blocks) for transactions
/// created by `createrawtransaction` RPC.
@ -35,11 +35,11 @@ pub trait RawClientCoreApi: Send + Sync + 'static {
}
pub struct RawClientCore {
local_sync_node: sync::LocalNodeRef,
local_sync_node: zebra_sync::LocalNodeRef,
}
impl RawClientCore {
pub fn new(local_sync_node: sync::LocalNodeRef) -> Self {
pub fn new(local_sync_node: zebra_sync::LocalNodeRef) -> Self {
RawClientCore {
local_sync_node: local_sync_node,
}
@ -61,9 +61,9 @@ impl RawClientCore {
// to make lock_time work at least one input must have sequence < SEQUENCE_FINAL
let lock_time = lock_time.unwrap_or_default();
let default_sequence = if lock_time != 0 {
chain::constants::SEQUENCE_FINAL - 1
zebra_chain::constants::SEQUENCE_FINAL - 1
} else {
chain::constants::SEQUENCE_FINAL
zebra_chain::constants::SEQUENCE_FINAL
};
// by default we're creating transactions that are expired in DEFAULT_TX_EXPIRY_DELTA blocks
@ -73,8 +73,8 @@ impl RawClientCore {
// prepare inputs
let inputs: Vec<_> = inputs
.into_iter()
.map(|input| chain::TransactionInput {
previous_output: chain::OutPoint {
.map(|input| zebra_chain::TransactionInput {
previous_output: zebra_chain::OutPoint {
hash: Into::<GlobalH256>::into(input.txid).reversed(),
index: input.vout,
},
@ -89,14 +89,19 @@ impl RawClientCore {
.into_iter()
.map(|output| match output {
TransactionOutput::Address(with_address) => {
let amount_in_satoshis =
(with_address.amount * (chain::constants::SATOSHIS_IN_COIN as f64)) as u64;
let amount_in_satoshis = (with_address.amount
* (zebra_chain::constants::SATOSHIS_IN_COIN as f64))
as u64;
let script = match with_address.address.kind {
keys::Type::P2PKH => ScriptBuilder::build_p2pkh(&with_address.address.hash),
keys::Type::P2SH => ScriptBuilder::build_p2sh(&with_address.address.hash),
zebra_keys::Type::P2PKH => {
ScriptBuilder::build_p2pkh(&with_address.address.hash)
}
zebra_keys::Type::P2SH => {
ScriptBuilder::build_p2sh(&with_address.address.hash)
}
};
chain::TransactionOutput {
zebra_chain::TransactionOutput {
value: amount_in_satoshis,
script_pubkey: script.to_bytes(),
}
@ -106,7 +111,7 @@ impl RawClientCore {
.return_bytes(&*with_script_data.script_data)
.into_script();
chain::TransactionOutput {
zebra_chain::TransactionOutput {
value: 0,
script_pubkey: script.to_bytes(),
}
@ -217,11 +222,11 @@ where
#[cfg(test)]
pub mod tests {
use super::*;
use chain::Transaction;
use jsonrpc_core::IoHandler;
use primitives::hash::H256 as GlobalH256;
use v1::traits::Raw;
use v1::types::{TransactionInput, TransactionOutputs};
use zebra_chain::Transaction;
use zebra_primitives::hash::H256 as GlobalH256;
#[derive(Default)]
struct SuccessRawClientCore;

View File

@ -1,7 +1,7 @@
use keys::Address;
use serde::de::{Unexpected, Visitor};
use serde::{Deserializer, Serialize, Serializer};
use std::fmt;
use zebra_keys::Address;
pub fn serialize<S>(address: &Address, serializer: S) -> Result<S::Ok, S::Error>
where
@ -39,9 +39,9 @@ impl<'b> Visitor<'b> for AddressVisitor {
pub mod vec {
use super::AddressVisitor;
use keys::Address;
use serde::de::Visitor;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use zebra_keys::Address;
pub fn serialize<S>(addresses: &Vec<Address>, serializer: S) -> Result<S::Ok, S::Error>
where
@ -67,9 +67,9 @@ pub mod vec {
#[cfg(test)]
mod tests {
use keys::Address;
use serde_json;
use v1::types;
use zebra_keys::Address;
#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct TestStruct {

View File

@ -1,7 +1,7 @@
use super::hash::H256;
use super::transaction::RawTransaction;
use chain;
use miner;
use zebra_chain;
use zebra_miner;
/// Block template as described in:
/// https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki
@ -57,8 +57,8 @@ pub struct BlockTemplateTransaction {
pub required: bool,
}
impl From<miner::BlockTemplate> for BlockTemplate {
fn from(block: miner::BlockTemplate) -> Self {
impl From<zebra_miner::BlockTemplate> for BlockTemplate {
fn from(block: zebra_miner::BlockTemplate) -> Self {
BlockTemplate {
version: block.version,
previousblockhash: block.previous_header_hash.reversed().into(),
@ -74,8 +74,8 @@ impl From<miner::BlockTemplate> for BlockTemplate {
}
}
impl From<chain::IndexedTransaction> for BlockTemplateTransaction {
fn from(transaction: chain::IndexedTransaction) -> Self {
impl From<zebra_chain::IndexedTransaction> for BlockTemplateTransaction {
fn from(transaction: zebra_chain::IndexedTransaction) -> Self {
use ser::serialize;
let serialize = serialize(&transaction.raw);
BlockTemplateTransaction {

View File

@ -1,9 +1,9 @@
use hex::{FromHex, ToHex};
use primitives::bytes::Bytes as GlobalBytes;
use serde::de::{Error, Visitor};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
///! Serializable wrapper around vector of bytes
use std::{fmt, ops};
use zebra_primitives::bytes::Bytes as GlobalBytes;
/// Wrapper structure around vector of bytes.
#[derive(Debug, PartialEq, Eq, Default, Hash, Clone)]

View File

@ -1,12 +1,12 @@
use hex::{FromHex, ToHex};
use primitives::hash::H160 as GlobalH160;
use primitives::hash::H256 as GlobalH256;
use serde;
use serde::de::Unexpected;
use std::cmp::Ordering;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::str::FromStr;
use zebra_primitives::hash::H160 as GlobalH160;
use zebra_primitives::hash::H256 as GlobalH256;
macro_rules! impl_hash {
($name: ident, $other: ident, $size: expr) => {
@ -162,8 +162,8 @@ impl H256 {
#[cfg(test)]
mod tests {
use super::H256;
use primitives::hash::H256 as GlobalH256;
use std::str::FromStr;
use zebra_primitives::hash::H256 as GlobalH256;
#[test]
fn hash_debug() {

View File

@ -1,7 +1,7 @@
use p2p::{Direction, PeerInfo};
use serde::de::Unexpected;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt;
use zebra_p2p::{Direction, PeerInfo};
#[derive(Debug, PartialEq)]
pub enum AddNodeOperation {

View File

@ -1,11 +1,11 @@
use super::bytes::Bytes;
use super::hash::H256;
use super::script::ScriptType;
use keys::Address;
use serde::ser::SerializeMap;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt;
use v1::types;
use zebra_keys::Address;
/// Hex-encoded transaction
pub type RawTransaction = Bytes;

View File

@ -1,8 +1,8 @@
use primitives::bigint::U256 as GlobalU256;
use serde;
use serde::de::Unexpected;
use std::fmt;
use std::str::FromStr;
use zebra_primitives::bigint::U256 as GlobalU256;
macro_rules! impl_uint {
($name: ident, $other: ident, $size: expr) => {

View File

@ -1,18 +1,19 @@
[package]
name = "script"
name = "zebra-script"
version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies]
bitcrypto = { path = "../crypto" }
byteorder = "1.0"
chain = { path = "../chain" }
keys = { path = "../keys" }
primitives = { path = "../primitives" }
serialization = { path = "../serialization" }
log = "0.4"
zebra-crypto = { path = "../crypto" }
zebra-chain = { path = "../chain" }
zebra-keys = { path = "../keys" }
zebra-primitives = { path = "../primitives" }
zebra-serialization = { path = "../serialization" }
[dev-dependencies]
rustc-hex = "2"
serde_json = "1.0"
chain = { path = "../chain", features = ["test-helpers"] }
zebra-chain = { path = "../chain", features = ["test-helpers"] }

View File

@ -1,7 +1,7 @@
//! Script builder
use bytes::Bytes;
use keys::AddressHash;
use zebra_keys::AddressHash;
use {Num, Opcode, Script};
/// Script builder

View File

@ -1,9 +1,9 @@
use bytes::Bytes;
use chain::constants::SEQUENCE_LOCKTIME_DISABLE_FLAG;
use crypto::{dhash160, dhash256, ripemd160, sha1, sha256};
use keys::{Public, Signature};
use sign::Sighash;
use std::{cmp, mem};
use zebra_chain::constants::SEQUENCE_LOCKTIME_DISABLE_FLAG;
use zebra_crypto::{dhash160, dhash256, ripemd160, sha1, sha256};
use zebra_keys::{Public, Signature};
use {script, Error, Num, Opcode, Script, SignatureChecker, Stack, VerificationFlags};
/// Helper function.
@ -892,7 +892,7 @@ pub fn eval_script(
mod tests {
use super::{eval_script, is_public_key, verify_script};
use bytes::Bytes;
use chain::Transaction;
use zebra_chain::Transaction;
use {
Builder, Error, NoopSignatureChecker, Num, Opcode, Script, Stack, TransactionInputSigner,
TransactionSignatureChecker, VerificationFlags,

View File

@ -1,10 +1,10 @@
extern crate bitcrypto as crypto;
extern crate byteorder;
extern crate chain;
extern crate keys;
extern crate log;
extern crate primitives;
extern crate serialization as ser;
extern crate zebra_chain;
extern crate zebra_crypto;
extern crate zebra_keys;
extern crate zebra_primitives;
extern crate zebra_serialization as ser;
#[cfg(test)]
extern crate rustc_hex as hex;
@ -22,7 +22,7 @@ mod sign;
mod stack;
mod verify;
pub use primitives::{bytes, hash};
pub use zebra_primitives::{bytes, hash};
pub use self::builder::Builder;
pub use self::error::Error;

View File

@ -1,8 +1,8 @@
//! Serialized script, used inside transaction inputs and outputs.
use bytes::Bytes;
use keys::{self, AddressHash, Public};
use std::{fmt, ops};
use zebra_keys::{self, AddressHash, Public};
use {Error, Opcode};
/// Maximum number of bytes pushable to the stack
@ -32,7 +32,7 @@ pub enum ScriptType {
#[derive(PartialEq, Debug)]
pub struct ScriptAddress {
/// The type of the address.
pub kind: keys::Type,
pub kind: zebra_keys::Type,
/// Public key hash.
pub hash: AddressHash,
}
@ -41,7 +41,7 @@ impl ScriptAddress {
/// Creates P2PKH-type ScriptAddress
pub fn new_p2pkh(hash: AddressHash) -> Self {
ScriptAddress {
kind: keys::Type::P2PKH,
kind: zebra_keys::Type::P2PKH,
hash: hash,
}
}
@ -49,7 +49,7 @@ impl ScriptAddress {
/// Creates P2SH-type ScriptAddress
pub fn new_p2sh(hash: AddressHash) -> Self {
ScriptAddress {
kind: keys::Type::P2SH,
kind: zebra_keys::Type::P2SH,
hash: hash,
}
}
@ -327,7 +327,7 @@ impl Script {
return 1;
}
pub fn extract_destinations(&self) -> Result<Vec<ScriptAddress>, keys::Error> {
pub fn extract_destinations(&self) -> Result<Vec<ScriptAddress>, zebra_keys::Error> {
match self.script_type() {
ScriptType::NonStandard => Ok(vec![]),
ScriptType::PubKey => {
@ -488,7 +488,7 @@ impl fmt::Display for Script {
#[cfg(test)]
mod tests {
use super::{Script, ScriptAddress, ScriptType, MAX_SCRIPT_ELEMENT_SIZE};
use keys::{Address, Public};
use zebra_keys::{Address, Public};
use {Builder, Opcode};
#[test]

View File

@ -2,13 +2,13 @@
use byteorder::{ByteOrder, LittleEndian};
use bytes::Bytes;
use chain::{
use hash::H256;
use ser::Stream;
use zebra_chain::{
JoinSplit, OutPoint, Sapling, Transaction, TransactionInput, TransactionOutput,
SAPLING_TX_VERSION_GROUP_ID,
};
use crypto::{blake2b_personal, dhash256};
use hash::H256;
use ser::Stream;
use zebra_crypto::{blake2b_personal, dhash256};
use Script;
#[derive(Debug, PartialEq, Clone, Copy)]
@ -516,13 +516,13 @@ fn compute_hash_sapling_outputs(
mod tests {
use super::{Sighash, SighashBase, TransactionInputSigner, UnsignedTransactionInput};
use bytes::Bytes;
use chain::{OutPoint, Transaction, TransactionOutput};
use hash::H256;
use hex::FromHex;
use keys::{Address, KeyPair, Private};
use script::Script;
use ser::deserialize;
use serde_json::{from_slice, Value};
use zebra_chain::{OutPoint, Transaction, TransactionOutput};
use zebra_keys::{Address, KeyPair, Private};
use {verify_script, TransactionSignatureChecker, VerificationFlags};
#[test]

View File

@ -1,8 +1,8 @@
use chain::constants::{
use zebra_chain::constants::{
LOCKTIME_THRESHOLD, SEQUENCE_FINAL, SEQUENCE_LOCKTIME_DISABLE_FLAG, SEQUENCE_LOCKTIME_MASK,
SEQUENCE_LOCKTIME_TYPE_FLAG,
};
use keys::{Message, Public, Signature};
use zebra_keys::{Message, Public, Signature};
use {Num, Script, SighashCache, TransactionInputSigner};
/// Checks transaction signature

View File

@ -1,9 +1,10 @@
[package]
name = "serialization"
name = "zebra-serialization"
version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies]
byteorder = "1.0"
primitives = { path = "../primitives" }
rustc-hex = "2"
zebra-primitives = { path = "../primitives" }

Some files were not shown because too many files have changed in this diff Show More