github.com/annchain/OG@v0.0.9/arefactor_core/core/interface.go (about)

     1  package core
     2  
     3  import (
     4  	ogTypes "github.com/annchain/OG/arefactor/og_interface"
     5  	"github.com/annchain/OG/arefactor/types"
     6  	"github.com/annchain/OG/common/math"
     7  	vmtypes "github.com/annchain/OG/vm/types"
     8  )
     9  
    10  type LedgerEngine interface {
    11  	GetNonce(ogTypes.Address) uint64
    12  	SetNonce(ogTypes.Address, uint64)
    13  	IssueToken(issuer ogTypes.Address, name, symbol string, reIssuable bool, fstIssue *math.BigInt) (int32, error)
    14  	ReIssueToken(tokenID int32, amount *math.BigInt) error
    15  	DestroyToken(tokenID int32) error
    16  
    17  	GetTokenBalance(ogTypes.Address, int32) *math.BigInt
    18  	SubTokenBalance(ogTypes.Address, int32, *math.BigInt)
    19  	AddTokenBalance(ogTypes.Address, int32, *math.BigInt)
    20  }
    21  
    22  type TxProcessor interface {
    23  	Process(engine LedgerEngine, tx types.Txi) (*Receipt, error)
    24  }
    25  
    26  type VmProcessor interface {
    27  	CanProcess(txi types.Txi) bool
    28  	Process(engine VmStateDB, tx types.Txi, height uint64) (*Receipt, error)
    29  	Call(engine VmStateDB)
    30  }
    31  
    32  // TODO try to delete those useless evm functions in OG.
    33  // like AddRefund refund functions, Suicide functions, Log and PreImage functions etc.
    34  type VmStateDB interface {
    35  	CreateAccount(ogTypes.Address)
    36  
    37  	SubBalance(ogTypes.Address, *math.BigInt)
    38  	AddBalance(ogTypes.Address, *math.BigInt)
    39  	// Retrieve the balance from the given address or 0 if object not found
    40  	GetBalance(ogTypes.Address) *math.BigInt
    41  
    42  	GetNonce(ogTypes.Address) uint64
    43  	SetNonce(ogTypes.Address, uint64)
    44  
    45  	GetCodeHash(ogTypes.Address) ogTypes.Hash
    46  	GetCode(ogTypes.Address) []byte
    47  	SetCode(ogTypes.Address, []byte)
    48  	GetCodeSize(ogTypes.Address) int
    49  
    50  	// AddRefund adds gas to the refund counter
    51  	AddRefund(uint64)
    52  	// SubRefund removes gas from the refund counter.
    53  	// This method will panic if the refund counter goes below zero
    54  	SubRefund(uint64)
    55  	// GetRefund returns the current value of the refund counter.
    56  	GetRefund() uint64
    57  
    58  	GetCommittedState(ogTypes.Address, ogTypes.Hash) ogTypes.Hash
    59  	// GetState retrieves a value from the given account's storage trie.
    60  	GetState(ogTypes.Address, ogTypes.Hash) ogTypes.Hash
    61  	SetState(ogTypes.Address, ogTypes.Hash, ogTypes.Hash)
    62  
    63  	// Suicide marks the given account as suicided.
    64  	// This clears the account balance.
    65  	//
    66  	// The account's state object is still available until the state is committed,
    67  	// getStateObject will return a non-nil account after Suicide.
    68  	Suicide(ogTypes.Address) bool
    69  	HasSuicided(ogTypes.Address) bool
    70  
    71  	// IsAddressExists reports whether the given account exists in state.
    72  	// Notably this should also return true for suicided accounts.
    73  	Exist(ogTypes.Address) bool
    74  	// Empty returns whether the given account is empty. Empty
    75  	// is defined according to EIP161 (balance = nonce = code = 0).
    76  	Empty(ogTypes.Address) bool
    77  
    78  	// RevertToSnapshot reverts all state changes made since the given revision.
    79  	RevertToSnapshot(int)
    80  	// Snapshot creates a new revision
    81  	Snapshot() int
    82  
    83  	AddLog(log *vmtypes.Log)
    84  	AddPreimage(ogTypes.Hash, []byte)
    85  
    86  	ForEachStorage(ogTypes.Address, func(ogTypes.Hash, ogTypes.Hash) bool)
    87  	// for debug.
    88  	String() string
    89  }