Trait ethcore::engines::Engine [] [src]

pub trait Engine: Sync + Send {
    fn name(&self) -> &str;
    fn params(&self) -> &CommonParams;
    fn schedule(&self, env_info: &EnvInfo) -> Schedule;
    fn builtins(&self) -> &BTreeMap<Address, Builtin>;

    fn version(&self) -> SemanticVersion { ... }
    fn seal_fields(&self) -> usize { ... }
    fn extra_info(&self, _header: &Header) -> BTreeMap<String, String> { ... }
    fn additional_params(&self) -> HashMap<String, String> { ... }
    fn maximum_extra_data_size(&self) -> usize { ... }
    fn maximum_uncle_count(&self) -> usize { ... }
    fn maximum_uncle_age(&self) -> usize { ... }
    fn account_start_nonce(&self) -> U256 { ... }
    fn on_new_block(&self, _block: &mut ExecutedBlock) { ... }
    fn on_close_block(&self, _block: &mut ExecutedBlock) { ... }
    fn is_sealer(&self, _author: &Address) -> Option<bool> { ... }
    fn is_default_sealer(&self) -> Option<bool> { ... }
    fn generate_seal(&self, _block: &ExecutedBlock) -> Seal { ... }
    fn verify_block_basic(&self,
                      _header: &Header,
                      _block: Option<&[u8]>)
                      -> Result<(), Error> { ... } fn verify_block_unordered(&self,
                          _header: &Header,
                          _block: Option<&[u8]>)
                          -> Result<(), Error> { ... } fn verify_block_family(&self,
                       _header: &Header,
                       _parent: &Header,
                       _block: Option<&[u8]>)
                       -> Result<(), Error> { ... } fn verify_transaction_basic(&self,
                            t: &UnverifiedTransaction,
                            _header: &Header)
                            -> Result<(), Error> { ... } fn verify_transaction(&self,
                      t: UnverifiedTransaction,
                      _header: &Header)
                      -> Result<SignedTransaction, Error> { ... } fn signing_network_id(&self, _env_info: &EnvInfo) -> Option<u64> { ... } fn verify_block_seal(&self, header: &Header) -> Result<(), Error> { ... } fn populate_from_parent(&self,
                        header: &mut Header,
                        parent: &Header,
                        _gas_floor_target: U256,
                        _gas_ceil_target: U256) { ... } fn handle_message(&self, _message: &[u8]) -> Result<(), Error> { ... } fn is_builtin(&self, a: &Address) -> bool { ... } fn cost_of_builtin(&self, a: &Address, input: &[u8]) -> U256 { ... } fn execute_builtin(&self, a: &Address, input: &[u8], output: &mut BytesRef) { ... } fn is_proposal(&self, _verified_header: &Header) -> bool { ... } fn set_signer(&self,
              _account_provider: Arc<AccountProvider>,
              _address: Address,
              _password: String) { ... } fn sign(&self, _hash: H256) -> Result<Signature, Error> { ... } fn register_client(&self, _client: Weak<Client>) { ... } fn step(&self) { ... } fn stop(&self) { ... } }

A consensus mechanism for the chain. Generally either proof-of-work or proof-of-stake-based. Provides hooks into each of the major parts of block import.

Required Methods

The name of this engine.

Get the general parameters of the chain.

Get the EVM schedule for the given env_info.

Builtin-contracts we would like to see in the chain. (In principle these are just hints for the engine since that has the last word on them.)

Provided Methods

The version of this engine. Should be of the form

The number of additional header fields required for this engine.

Additional engine-specific information for the user/developer concerning header.

Additional information.

Some intrinsic operation parameters; by default they take their value from the spec()'s engine_params.

Maximum number of uncles a block is allowed to declare.

The number of generations back that uncles can be.

The nonce with which accounts begin.

Block transformation functions, before the transactions.

Block transformation functions, after the transactions.

If Some(true) this author is able to generate seals, generate_seal has to be implemented. None indicates that this Engine never seals internally regardless of author (e.g. PoW).

Checks if default address is able to seal.

Attempt to seal the block internally.

If Some is returned, then you get a valid seal.

This operation is synchronous and may (quite reasonably) not be available, in which None will be returned.

Phase 1 quick block verification. Only does checks that are cheap. block (the header's full block) may be provided for additional checks. Returns either a null Ok or a general error detailing the problem with import.

Phase 2 verification. Perform costly checks such as transaction signatures. block (the header's full block) may be provided for additional checks. Returns either a null Ok or a general error detailing the problem with import.

Phase 3 verification. Check block information against parent and uncles. block (the header's full block) may be provided for additional checks. Returns either a null Ok or a general error detailing the problem with import.

Additional verification for transactions in blocks.

Verify a particular transaction is valid.

The network ID that transactions should be signed with.

Verify the seal of a block. This is an auxilliary method that actually just calls other verify_ methods to get the job done. By default it must pass verify_basic and verify_block_unordered. If more or fewer methods are needed for an Engine, this may be overridden.

Populate a header's fields based on its parent's header. Usually implements the chain scoring rule based on weight. The gas floor target must not be lower than the engine's minimum gas limit.

Handle any potential consensus messages; updating consensus state and potentially issuing a new one.

Determine whether a particular address is a builtin contract.

Determine the code execution cost of the builtin contract with address a. Panics if is_builtin(a) is not true.

Execution the builtin contract a on input and return output. Panics if is_builtin(a) is not true.

Find out if the block is a proposal block and should not be inserted into the DB. Takes a header of a fully verified block.

Register an account which signs consensus messages.

Sign using the EngineSigner, to be used for consensus tx signing.

Add Client which can be used for sealing, querying the state and sending messages.

Trigger next step of the consensus engine.

Stops any services that the may hold the Engine and makes it safe to drop.

Implementors