      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131

    //! Bitcoin consensus verification
    //!
    //!	Full block verification consists of two phases:
    //!	- pre-verification
    //! - full-verification
    //!
    //! In this library, pre-verification is done by `VerifyXXX` structures
    //! Full-verification is done by `AcceptXXX` structures
    //!
    //! Use cases:
    //!
    //! --> A. on_new_block:
    //!
    //! A.1 VerifyHeader
    //! A.2 VerifyBlock,
    //! A.3 VerifyTransaction for each tx
    //!
    //! A.4.a if it is block from canon chain
    //! A.4.a.1 AcceptHeader
    //! A.4.a.2 AcceptBlock
    //! A.4.a.3 AcceptTransaction for each tx
    //!
    //! A.4.b if it is block from side chain becoming canon
    //! decanonize old canon chain blocks
    //! canonize new canon chain blocks (without currently processed block)
    //! A.4.b.1 AcceptHeader for each header
    //! A.4.b.2 AcceptBlock for each block
    //! A.4.b.3 AcceptTransaction for each tx in each block
    //! A.4.b.4 AcceptHeader
    //! A.4.b.5 AcceptBlock
    //! A.4.b.6 AcceptTransaction for each tx
    //! if any step failed, revert chain back to old canon
    //!
    //! A.4.c if it is block from side chain do nothing
    //!
    //! --> B. on_memory_pool_transaction
    //!
    //! B.1 VerifyMemoryPoolTransaction
    //! B.2 AcceptMemoryPoolTransaction
    //!
    //! --> C. on_block_header
    //!
    //! C.1 VerifyHeader
    //! C.2 AcceptHeader (?)
    //!
    //! --> D. after successfull chain_reorganization
    //!
    //! D.1 AcceptMemoryPoolTransaction on each tx in memory pool
    //!
    //! --> E. D might be super inefficient when memory pool is large
    //! so instead we might want to call AcceptMemoryPoolTransaction on each tx
    //! that is inserted into assembled block

    extern crate time;
    #[macro_use]
    extern crate lazy_static;
    #[macro_use]
    extern crate log;
    extern crate parking_lot;
    extern crate rayon;

    extern crate storage;
    extern crate chain;
    extern crate network;
    extern crate primitives;
    extern crate serialization as ser;
    extern crate script;
    extern crate bitcrypto as crypto;
    #[cfg(test)]
    extern crate db;

    pub mod constants;
    mod canon;
    mod deployments;
    mod duplex_store;
    mod error;
    mod sigops;
    mod timestamp;
    mod work;
    mod work_bch;

    // pre-verification
    mod verify_block;
    mod verify_chain;
    mod verify_header;
    mod verify_transaction;

    // full verification
    mod accept_block;
    mod accept_chain;
    mod accept_header;
    mod accept_transaction;

    // backwards compatibility
    mod chain_verifier;

    pub use primitives::{bigint, hash, compact};

    pub use canon::{CanonBlock, CanonHeader, CanonTransaction};
    pub use accept_block::BlockAcceptor;
    pub use accept_chain::ChainAcceptor;
    pub use accept_header::HeaderAcceptor;
    pub use accept_transaction::{TransactionAcceptor, MemoryPoolTransactionAcceptor};

    pub use verify_block::BlockVerifier;
    pub use verify_chain::ChainVerifier;
    pub use verify_header::HeaderVerifier;
    pub use verify_transaction::{TransactionVerifier, MemoryPoolTransactionVerifier};

    pub use chain_verifier::BackwardsCompatibleChainVerifier;
    pub use error::{Error, TransactionError};
    pub use sigops::transaction_sigops;
    pub use timestamp::{median_timestamp, median_timestamp_inclusive};
    pub use work::{work_required, is_valid_proof_of_work, is_valid_proof_of_work_hash, block_reward_satoshi};
    pub use deployments::Deployments;

    #[derive(Debug, Clone, Copy, PartialEq)]
    /// Blocks verification level.
    pub enum VerificationLevel {
    	/// Full verification.
    	Full,
    	/// Transaction scripts are not checked.
    	Header,
    	/// No verification at all.
    	NoVerification,
    }

    /// Interface for block verification
    pub trait Verify : Send + Sync {
    	fn verify(&self, level: VerificationLevel, block: &chain::IndexedBlock) -> Result<(), Error>;
    }

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)