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

View File

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

View File

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

View File

@ -1,12 +1,12 @@
extern crate byteorder; 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 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 database;
mod verifier; mod verifier;

View File

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,10 @@
extern crate bitcrypto as crypto;
extern crate heapsize; extern crate heapsize;
extern crate primitives;
extern crate rustc_hex as hex; 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] #[macro_use]
extern crate serialization_derive; extern crate zebra_serialization_derive;
pub mod constants; pub mod constants;
@ -22,7 +22,7 @@ mod indexed_transaction;
/// `IndexedBlock` extension /// `IndexedBlock` extension
mod read_and_hash; mod read_and_hash;
pub use primitives::{bigint, bytes, compact, hash}; pub use zebra_primitives::{bigint, bytes, compact, hash};
pub use transaction::{ pub use transaction::{
BTC_TX_VERSION, OVERWINTER_TX_VERSION, SAPLING_TX_VERSION, SPROUT_TX_VERSION, 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 hash::{H256, H512};
use zebra_crypto::dhash256;
#[inline] #[inline]
fn concat<T>(a: T, b: T) -> H512 fn concat<T>(a: T, b: T) -> H512

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,4 @@
use bytes::Bytes; use bytes::Bytes;
use chain::{BlockHeader, Transaction as ChainTransaction};
use hash::H256; use hash::H256;
use kv::{Key, KeyState, KeyValue, KeyValueDatabase, Operation, Transaction, Value}; use kv::{Key, KeyState, KeyValue, KeyValueDatabase, Operation, Transaction, Value};
use parking_lot::RwLock; use parking_lot::RwLock;
@ -7,7 +6,8 @@ use ser::List;
use std::collections::HashMap; use std::collections::HashMap;
use std::mem::replace; use std::mem::replace;
use std::sync::Arc; 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)] #[derive(Default, Debug)]
struct InnerDatabase { struct InnerDatabase {

View File

@ -1,8 +1,8 @@
use bytes::Bytes; use bytes::Bytes;
use chain::{BlockHeader, Transaction as ChainTransaction};
use hash::H256; use hash::H256;
use ser::{deserialize, serialize, List}; 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_COUNT: u32 = 16;
pub const COL_META: u32 = 0; pub const COL_META: u32 = 0;

View File

@ -6,13 +6,13 @@ extern crate log;
extern crate bit_vec; extern crate bit_vec;
extern crate lru_cache; extern crate lru_cache;
extern crate chain; extern crate zebra_chain;
extern crate primitives; extern crate zebra_primitives;
extern crate serialization as ser; extern crate zebra_serialization as ser;
extern crate storage; extern crate zebra_storage;
mod block_chain_db; mod block_chain_db;
pub mod kv; pub mod kv;
pub use block_chain_db::{BlockChainDatabase, ForkChainDatabase}; 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 zebra_chain;
extern crate db; extern crate zebra_db;
extern crate storage; extern crate zebra_storage;
extern crate test_data; extern crate zebra_test_data;
use chain::IndexedBlock; use zebra_chain::IndexedBlock;
use db::kv::{MemoryDatabase, SharedMemoryDatabase}; use zebra_db::kv::{MemoryDatabase, SharedMemoryDatabase};
use db::BlockChainDatabase; use zebra_db::BlockChainDatabase;
use storage::{BlockProvider, ForkChain, SideChainOrigin}; use zebra_storage::{BlockProvider, ForkChain, SideChainOrigin};
#[test] #[test]
fn insert_block() { fn insert_block() {
let store = BlockChainDatabase::open(MemoryDatabase::default()); let store = BlockChainDatabase::open(MemoryDatabase::default());
let b0: IndexedBlock = test_data::block_h0().into(); let b0: IndexedBlock = zebra_test_data::block_h0().into();
let b1: IndexedBlock = test_data::block_h1().into(); let b1: IndexedBlock = zebra_test_data::block_h1().into();
let b2: IndexedBlock = test_data::block_h2().into(); let b2: IndexedBlock = zebra_test_data::block_h2().into();
store.insert(b0.clone()).unwrap(); store.insert(b0.clone()).unwrap();
store.insert(b1.clone()).unwrap(); store.insert(b1.clone()).unwrap();
@ -51,9 +51,9 @@ fn insert_block() {
#[test] #[test]
fn reopen_db() { fn reopen_db() {
let shared_database = SharedMemoryDatabase::default(); let shared_database = SharedMemoryDatabase::default();
let b0: IndexedBlock = test_data::block_h0().into(); let b0: IndexedBlock = zebra_test_data::block_h0().into();
let b1: IndexedBlock = test_data::block_h1().into(); let b1: IndexedBlock = zebra_test_data::block_h1().into();
let b2: IndexedBlock = test_data::block_h2().into(); let b2: IndexedBlock = zebra_test_data::block_h2().into();
{ {
let store = BlockChainDatabase::open(shared_database.clone()); let store = BlockChainDatabase::open(shared_database.clone());
@ -78,9 +78,9 @@ fn reopen_db() {
#[test] #[test]
fn switch_to_simple_fork() { fn switch_to_simple_fork() {
let store = BlockChainDatabase::open(MemoryDatabase::default()); let store = BlockChainDatabase::open(MemoryDatabase::default());
let b0: IndexedBlock = test_data::block_h0().into(); let b0: IndexedBlock = zebra_test_data::block_h0().into();
let b1: IndexedBlock = test_data::block_h1().into(); let b1: IndexedBlock = zebra_test_data::block_h1().into();
let b2: IndexedBlock = test_data::block_h2().into(); let b2: IndexedBlock = zebra_test_data::block_h2().into();
store.insert(b0.clone()).unwrap(); store.insert(b0.clone()).unwrap();
store.insert(b1.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]) { fn target(data: &[u8]) {
crypto::ripemd160(data); crypto::ripemd160(data);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,13 +1,14 @@
[package] [package]
name = "network" name = "zebra-network"
version = "0.1.0" version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"] license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies] [dependencies]
lazy_static = "1.3" lazy_static = "1.3"
chain = { path = "../chain" }
keys = { path = "../keys" }
primitives = { path = "../primitives" }
serialization = { path = "../serialization" }
bitcrypto = { path = "../crypto" }
rustc-hex = "2" 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 zebra_crypto;
use {crypto, Deployment, Magic, Network}; use zebra_keys::Address;
use {Deployment, Magic, Network};
lazy_static! { lazy_static! {
static ref SAPLING_SPEND_VK: crypto::Groth16VerifyingKey = static ref SAPLING_SPEND_VK: zebra_crypto::Groth16VerifyingKey =
crypto::load_sapling_spend_verifying_key() zebra_crypto::load_sapling_spend_verifying_key()
.expect("hardcoded value should load without errors"); .expect("hardcoded value should load without errors");
static ref SAPLING_OUTPUT_VK: crypto::Groth16VerifyingKey = static ref SAPLING_OUTPUT_VK: zebra_crypto::Groth16VerifyingKey =
crypto::load_sapling_output_verifying_key() zebra_crypto::load_sapling_output_verifying_key()
.expect("hardcoded value should load without errors"); .expect("hardcoded value should load without errors");
static ref JOINSPLIT_GROTH16_VK: crypto::Groth16VerifyingKey = static ref JOINSPLIT_GROTH16_VK: zebra_crypto::Groth16VerifyingKey =
crypto::load_joinsplit_groth16_verifying_key() zebra_crypto::load_joinsplit_groth16_verifying_key()
.expect("hardcoded value should load without errors"); .expect("hardcoded value should load without errors");
} }
@ -76,19 +77,19 @@ pub struct ConsensusParams {
pub equihash_params: Option<(u32, u32)>, pub equihash_params: Option<(u32, u32)>,
/// Active key for pghr13 joinsplit verification /// 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 /// 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. /// 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. /// 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 { fn mainnet_pghr_verification_key() -> zebra_crypto::Pghr13VerifyingKey {
crypto::json::pghr13::decode(include_bytes!("../../res/sprout-verifying-key.json")) zebra_crypto::json::pghr13::decode(include_bytes!("../../res/sprout-verifying-key.json"))
.expect("verifying key json invalid") .expect("verifying key json invalid")
.into() .into()
} }

View File

@ -1,18 +1,18 @@
#[macro_use] #[macro_use]
extern crate lazy_static; 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 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 consensus;
mod deployments; mod deployments;
mod network; mod network;
pub use primitives::{compact, hash}; pub use zebra_primitives::{compact, hash};
pub use consensus::ConsensusParams; pub use consensus::ConsensusParams;
pub use deployments::Deployment; pub use deployments::Deployment;

View File

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

View File

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

View File

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

View File

@ -1,10 +1,10 @@
use futures::{Async, Future, Poll}; use futures::{Async, Future, Poll};
use io::{read_message, write_message, ReadMessage, WriteMessage}; 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 std::{cmp, io};
use tokio_io::{AsyncRead, AsyncWrite}; 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> pub fn handshake<A>(a: A, magic: Magic, version: Version, min_version: u32) -> Handshake<A>
where where
@ -241,13 +241,13 @@ mod tests {
use super::{accept_handshake, handshake, HandshakeResult}; use super::{accept_handshake, handshake, HandshakeResult};
use bytes::Bytes; use bytes::Bytes;
use futures::{Future, Poll}; 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 ser::Stream;
use std::io; use std::io;
use tokio_io::{AsyncRead, AsyncWrite}; 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 { pub struct TestIo {
read: io::Cursor<Bytes>, read: io::Cursor<Bytes>,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,12 @@
use futures::{Future, Poll}; use futures::{Future, Poll};
use io::{accept_handshake, deadline, AcceptHandshake, Deadline}; use io::{accept_handshake, deadline, AcceptHandshake, Deadline};
use message::MessageResult;
use net::{Config, Connection}; use net::{Config, Connection};
use network::Magic;
use std::time::Duration; use std::time::Duration;
use std::{io, net}; use std::{io, net};
use tokio_core::net::TcpStream; use tokio_core::net::TcpStream;
use tokio_core::reactor::Handle; use tokio_core::reactor::Handle;
use zebra_message::MessageResult;
use zebra_network::Magic;
pub fn accept_connection( pub fn accept_connection(
stream: TcpStream, 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 std::net::SocketAddr;
use util::nonce::{NonceGenerator, RandomNonce}; use util::nonce::{NonceGenerator, RandomNonce};
use util::time::{RealTime, Time}; 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)] #[derive(Debug, Clone)]
pub struct Config { pub struct Config {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,8 @@
[package] [package]
name = "rpc" name = "zebra-rpc"
version = "0.1.0" version = "0.1.0"
authors = ["Ethcore <admin@ethcore.io>"] license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[lib] [lib]
@ -18,18 +19,18 @@ jsonrpc-derive = "10.0"
jsonrpc-pubsub = "10.0" jsonrpc-pubsub = "10.0"
jsonrpc-http-server = "10.0" jsonrpc-http-server = "10.0"
sync = { path = "../sync" } zebra-sync = { path = "../sync" }
serialization = { path = "../serialization" } zebra-serialization = { path = "../serialization" }
chain = { path = "../chain" } zebra-chain = { path = "../chain" }
primitives = { path = "../primitives" } zebra-primitives = { path = "../primitives" }
p2p = { path = "../p2p" } zebra-p2p = { path = "../p2p" }
network = { path = "../network" } zebra-network = { path = "../network" }
storage = { path = "../storage" } zebra-storage = { path = "../storage" }
db = { path = "../db" } zebra-db = { path = "../db" }
miner = { path = "../miner" } zebra-miner = { path = "../miner" }
verification = { path = "../verification" } zebra-verification = { path = "../verification" }
script = { path = "../script" } zebra-script = { path = "../script" }
keys = { path = "../keys" } zebra-keys = { path = "../keys" }
[dev-dependencies] [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; extern crate jsonrpc_core;
#[macro_use] #[macro_use]
extern crate jsonrpc_derive; extern crate jsonrpc_derive;
extern crate chain;
extern crate db;
extern crate jsonrpc_http_server; 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 time;
extern crate tokio_core; 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 rpc_server;
pub mod v1; pub mod v1;

View File

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

View File

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

View File

@ -1,16 +1,16 @@
use jsonrpc_core::Error; use jsonrpc_core::Error;
use p2p;
use std::net::{IpAddr, SocketAddr}; use std::net::{IpAddr, SocketAddr};
use std::sync::Arc; use std::sync::Arc;
use v1::helpers::errors; use v1::helpers::errors;
use v1::traits::Network as NetworkRpc; use v1::traits::Network as NetworkRpc;
use v1::types::{AddNodeOperation, NodeInfo}; use v1::types::{AddNodeOperation, NodeInfo};
use zebra_p2p;
pub trait NetworkApi: Send + Sync + 'static { pub trait NetworkApi: Send + Sync + 'static {
fn add_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<(), p2p::NodeTableError>; fn remove_node(&self, socket_addr: SocketAddr) -> Result<(), zebra_p2p::NodeTableError>;
fn connect(&self, socket_addr: SocketAddr); 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 nodes_info(&self) -> Vec<NodeInfo>;
fn connection_count(&self) -> usize; fn connection_count(&self) -> usize;
} }
@ -77,38 +77,38 @@ where
} }
pub struct NetworkClientCore { pub struct NetworkClientCore {
p2p: Arc<p2p::Context>, p2p: Arc<zebra_p2p::Context>,
} }
impl NetworkClientCore { impl NetworkClientCore {
pub fn new(p2p: Arc<p2p::Context>) -> Self { pub fn new(p2p: Arc<zebra_p2p::Context>) -> Self {
NetworkClientCore { p2p: p2p } NetworkClientCore { p2p: p2p }
} }
} }
impl NetworkApi for NetworkClientCore { 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) 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) self.p2p.remove_node(socket_addr)
} }
fn connect(&self, socket_addr: SocketAddr) { 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 let exact_node = try!(self
.p2p .p2p
.nodes() .nodes()
.iter() .iter()
.find(|n| n.address().ip() == node_addr) .find(|n| n.address().ip() == node_addr)
.cloned() .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 .p2p
.connections() .connections()
.info() .info()
@ -124,13 +124,13 @@ impl NetworkApi for NetworkClientCore {
} }
fn nodes_info(&self) -> Vec<NodeInfo> { 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 self.p2p
.nodes() .nodes()
.iter() .iter()
.map(|n| { .map(|n| {
let node_peers: Vec<p2p::PeerInfo> = peers let node_peers: Vec<zebra_p2p::PeerInfo> = peers
.iter() .iter()
.filter(|p| p.address == n.address()) .filter(|p| p.address == n.address())
.cloned() .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 jsonrpc_core::Error;
use primitives::bytes::Bytes as GlobalBytes;
use primitives::hash::H256 as GlobalH256;
use ser::{deserialize, serialize, Reader}; use ser::{deserialize, serialize, Reader};
use sync;
use v1::helpers::errors::{execution, invalid_params}; use v1::helpers::errors::{execution, invalid_params};
use v1::traits::Raw; use v1::traits::Raw;
use v1::types::H256; use v1::types::H256;
@ -14,6 +7,13 @@ use v1::types::{
GetRawTransactionResponse, RawTransaction, Transaction, TransactionInput, TransactionOutput, GetRawTransactionResponse, RawTransaction, Transaction, TransactionInput, TransactionOutput,
TransactionOutputs, 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 /// Default expiry height delta (best blocks number + height in blocks) for transactions
/// created by `createrawtransaction` RPC. /// created by `createrawtransaction` RPC.
@ -35,11 +35,11 @@ pub trait RawClientCoreApi: Send + Sync + 'static {
} }
pub struct RawClientCore { pub struct RawClientCore {
local_sync_node: sync::LocalNodeRef, local_sync_node: zebra_sync::LocalNodeRef,
} }
impl RawClientCore { impl RawClientCore {
pub fn new(local_sync_node: sync::LocalNodeRef) -> Self { pub fn new(local_sync_node: zebra_sync::LocalNodeRef) -> Self {
RawClientCore { RawClientCore {
local_sync_node: local_sync_node, 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 // to make lock_time work at least one input must have sequence < SEQUENCE_FINAL
let lock_time = lock_time.unwrap_or_default(); let lock_time = lock_time.unwrap_or_default();
let default_sequence = if lock_time != 0 { let default_sequence = if lock_time != 0 {
chain::constants::SEQUENCE_FINAL - 1 zebra_chain::constants::SEQUENCE_FINAL - 1
} else { } 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 // by default we're creating transactions that are expired in DEFAULT_TX_EXPIRY_DELTA blocks
@ -73,8 +73,8 @@ impl RawClientCore {
// prepare inputs // prepare inputs
let inputs: Vec<_> = inputs let inputs: Vec<_> = inputs
.into_iter() .into_iter()
.map(|input| chain::TransactionInput { .map(|input| zebra_chain::TransactionInput {
previous_output: chain::OutPoint { previous_output: zebra_chain::OutPoint {
hash: Into::<GlobalH256>::into(input.txid).reversed(), hash: Into::<GlobalH256>::into(input.txid).reversed(),
index: input.vout, index: input.vout,
}, },
@ -89,14 +89,19 @@ impl RawClientCore {
.into_iter() .into_iter()
.map(|output| match output { .map(|output| match output {
TransactionOutput::Address(with_address) => { TransactionOutput::Address(with_address) => {
let amount_in_satoshis = let amount_in_satoshis = (with_address.amount
(with_address.amount * (chain::constants::SATOSHIS_IN_COIN as f64)) as u64; * (zebra_chain::constants::SATOSHIS_IN_COIN as f64))
as u64;
let script = match with_address.address.kind { let script = match with_address.address.kind {
keys::Type::P2PKH => ScriptBuilder::build_p2pkh(&with_address.address.hash), zebra_keys::Type::P2PKH => {
keys::Type::P2SH => ScriptBuilder::build_p2sh(&with_address.address.hash), 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, value: amount_in_satoshis,
script_pubkey: script.to_bytes(), script_pubkey: script.to_bytes(),
} }
@ -106,7 +111,7 @@ impl RawClientCore {
.return_bytes(&*with_script_data.script_data) .return_bytes(&*with_script_data.script_data)
.into_script(); .into_script();
chain::TransactionOutput { zebra_chain::TransactionOutput {
value: 0, value: 0,
script_pubkey: script.to_bytes(), script_pubkey: script.to_bytes(),
} }
@ -217,11 +222,11 @@ where
#[cfg(test)] #[cfg(test)]
pub mod tests { pub mod tests {
use super::*; use super::*;
use chain::Transaction;
use jsonrpc_core::IoHandler; use jsonrpc_core::IoHandler;
use primitives::hash::H256 as GlobalH256;
use v1::traits::Raw; use v1::traits::Raw;
use v1::types::{TransactionInput, TransactionOutputs}; use v1::types::{TransactionInput, TransactionOutputs};
use zebra_chain::Transaction;
use zebra_primitives::hash::H256 as GlobalH256;
#[derive(Default)] #[derive(Default)]
struct SuccessRawClientCore; struct SuccessRawClientCore;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,18 +1,19 @@
[package] [package]
name = "script" name = "zebra-script"
version = "0.1.0" version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"] license = "GPL-3.0"
authors = ["Zcash Foundation <zebra@zfnd.org>"]
[dependencies] [dependencies]
bitcrypto = { path = "../crypto" }
byteorder = "1.0" byteorder = "1.0"
chain = { path = "../chain" }
keys = { path = "../keys" }
primitives = { path = "../primitives" }
serialization = { path = "../serialization" }
log = "0.4" 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] [dev-dependencies]
rustc-hex = "2" rustc-hex = "2"
serde_json = "1.0" 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 //! Script builder
use bytes::Bytes; use bytes::Bytes;
use keys::AddressHash; use zebra_keys::AddressHash;
use {Num, Opcode, Script}; use {Num, Opcode, Script};
/// Script builder /// Script builder

View File

@ -1,9 +1,9 @@
use bytes::Bytes; 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 sign::Sighash;
use std::{cmp, mem}; 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}; use {script, Error, Num, Opcode, Script, SignatureChecker, Stack, VerificationFlags};
/// Helper function. /// Helper function.
@ -892,7 +892,7 @@ pub fn eval_script(
mod tests { mod tests {
use super::{eval_script, is_public_key, verify_script}; use super::{eval_script, is_public_key, verify_script};
use bytes::Bytes; use bytes::Bytes;
use chain::Transaction; use zebra_chain::Transaction;
use { use {
Builder, Error, NoopSignatureChecker, Num, Opcode, Script, Stack, TransactionInputSigner, Builder, Error, NoopSignatureChecker, Num, Opcode, Script, Stack, TransactionInputSigner,
TransactionSignatureChecker, VerificationFlags, TransactionSignatureChecker, VerificationFlags,

View File

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

View File

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

View File

@ -2,13 +2,13 @@
use byteorder::{ByteOrder, LittleEndian}; use byteorder::{ByteOrder, LittleEndian};
use bytes::Bytes; use bytes::Bytes;
use chain::{ use hash::H256;
use ser::Stream;
use zebra_chain::{
JoinSplit, OutPoint, Sapling, Transaction, TransactionInput, TransactionOutput, JoinSplit, OutPoint, Sapling, Transaction, TransactionInput, TransactionOutput,
SAPLING_TX_VERSION_GROUP_ID, SAPLING_TX_VERSION_GROUP_ID,
}; };
use crypto::{blake2b_personal, dhash256}; use zebra_crypto::{blake2b_personal, dhash256};
use hash::H256;
use ser::Stream;
use Script; use Script;
#[derive(Debug, PartialEq, Clone, Copy)] #[derive(Debug, PartialEq, Clone, Copy)]
@ -516,13 +516,13 @@ fn compute_hash_sapling_outputs(
mod tests { mod tests {
use super::{Sighash, SighashBase, TransactionInputSigner, UnsignedTransactionInput}; use super::{Sighash, SighashBase, TransactionInputSigner, UnsignedTransactionInput};
use bytes::Bytes; use bytes::Bytes;
use chain::{OutPoint, Transaction, TransactionOutput};
use hash::H256; use hash::H256;
use hex::FromHex; use hex::FromHex;
use keys::{Address, KeyPair, Private};
use script::Script; use script::Script;
use ser::deserialize; use ser::deserialize;
use serde_json::{from_slice, Value}; use serde_json::{from_slice, Value};
use zebra_chain::{OutPoint, Transaction, TransactionOutput};
use zebra_keys::{Address, KeyPair, Private};
use {verify_script, TransactionSignatureChecker, VerificationFlags}; use {verify_script, TransactionSignatureChecker, VerificationFlags};
#[test] #[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, LOCKTIME_THRESHOLD, SEQUENCE_FINAL, SEQUENCE_LOCKTIME_DISABLE_FLAG, SEQUENCE_LOCKTIME_MASK,
SEQUENCE_LOCKTIME_TYPE_FLAG, SEQUENCE_LOCKTIME_TYPE_FLAG,
}; };
use keys::{Message, Public, Signature}; use zebra_keys::{Message, Public, Signature};
use {Num, Script, SighashCache, TransactionInputSigner}; use {Num, Script, SighashCache, TransactionInputSigner};
/// Checks transaction signature /// Checks transaction signature

View File

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

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