github.com/baptiste-b-pegasys/quorum/v22@v22.4.2/core/mps/interface.go (about)

     1  //go:generate mockgen -source interface.go -destination=mock_interface.go -package=mps
     2  
     3  package mps
     4  
     5  import (
     6  	"context"
     7  
     8  	"github.com/ethereum/go-ethereum/common"
     9  	"github.com/ethereum/go-ethereum/core/state"
    10  	"github.com/ethereum/go-ethereum/core/types"
    11  	"github.com/ethereum/go-ethereum/trie"
    12  )
    13  
    14  // PrivateStateManager interface separates
    15  type PrivateStateManager interface {
    16  	PrivateStateMetadataResolver
    17  	// StateRepository returns repository corresponding to a block hash
    18  	StateRepository(blockHash common.Hash) (PrivateStateRepository, error)
    19  	// CheckAt verifies if there's a state being managed at a block hash
    20  	CheckAt(blockHash common.Hash) error
    21  	// TrieDB returns the trie database
    22  	TrieDB() *trie.Database
    23  }
    24  
    25  type PrivateStateMetadataResolver interface {
    26  	ResolveForManagedParty(managedParty string) (*PrivateStateMetadata, error)
    27  	ResolveForUserContext(ctx context.Context) (*PrivateStateMetadata, error)
    28  	// PSIs returns list of types.PrivateStateIdentifier being managed
    29  	PSIs() []types.PrivateStateIdentifier
    30  	// NotIncludeAny returns true if NONE of the managedParties is a member
    31  	// of the given psm, otherwise returns false
    32  	NotIncludeAny(psm *PrivateStateMetadata, managedParties ...string) bool
    33  }
    34  
    35  // PrivateStateRepository abstracts how we handle private state(s) including
    36  // retrieving from and peristing private states to the underlying database
    37  type PrivateStateRepository interface {
    38  	PrivateStateRoot(psi types.PrivateStateIdentifier) (common.Hash, error)
    39  	StatePSI(psi types.PrivateStateIdentifier) (*state.StateDB, error)
    40  	CommitAndWrite(isEIP158 bool, block *types.Block) error
    41  	Commit(isEIP158 bool, block *types.Block) error
    42  	Copy() PrivateStateRepository
    43  	Reset() error
    44  	DefaultState() (*state.StateDB, error)
    45  	DefaultStateMetadata() *PrivateStateMetadata
    46  	IsMPS() bool
    47  	MergeReceipts(pub, priv types.Receipts) types.Receipts
    48  }