github.com/gzuhlwang/notes-on-go-ethereum@v0.0.0-20190711012035-9f9c66e21d92/core/types.go (about)

     1  // Copyright 2015 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package core
    18  
    19  import (
    20  	"github.com/ethereum/go-ethereum/core/state"
    21  	"github.com/ethereum/go-ethereum/core/types"
    22  	"github.com/ethereum/go-ethereum/core/vm"
    23  )
    24  
    25  // Validator is an interface which defines the standard for block validation. It
    26  // is only responsible for validating block contents, as the header validation is
    27  // done by the specific consensus engines.
    28  type Validator interface {
    29  	// ValidateBody validates the given block's content.
    30  	ValidateBody(block *types.Block) error
    31  
    32  	// ValidateState validates the given statedb and optionally the receipts and
    33  	// gas used.
    34  	ValidateState(block *types.Block, state *state.StateDB, receipts types.Receipts, usedGas uint64) error
    35  }
    36  
    37  // Prefetcher is an interface for pre-caching transaction signatures and state.
    38  type Prefetcher interface {
    39  	// Prefetch processes the state changes according to the Ethereum rules by running
    40  	// the transaction messages using the statedb, but any changes are discarded. The
    41  	// only goal is to pre-cache transaction signatures and state trie nodes.
    42  	Prefetch(block *types.Block, statedb *state.StateDB, cfg vm.Config, interrupt *uint32)
    43  }
    44  
    45  // Processor is an interface for processing blocks using a given initial state.
    46  type Processor interface {
    47  	// Process processes the state changes according to the Ethereum rules by running
    48  	// the transaction messages using the statedb and applying any rewards to both
    49  	// the processor (coinbase) and any included uncles.
    50  	Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, []*types.Log, uint64, error)
    51  }