Documentation ¶
Index ¶
- Variables
- func JointKvDataKey(acc, key string) (rkey string)
- func KVDataFromBytes(key string, data []byte) (cvtypes.StateDataItfc, error)
- func KvDataSplit(str string) (acc, key string)
- func RemoteAccFromBytes(key string, data []byte) (cvtypes.StateDataItfc, error)
- type ModifiedUndoItfc
- type ModifyBalanceUndo
- type ModifyKvUndo
- type ModifyNonceUndo
- type RemoteAccount
- func (ra *RemoteAccount) AddBalance(add *big.Int)
- func (ra *RemoteAccount) AddNonce(add uint64)
- func (ra *RemoteAccount) Bytes() ([]byte, error)
- func (ra *RemoteAccount) Copy() cvtypes.StateDataItfc
- func (ra *RemoteAccount) DelKv(key string)
- func (ra *RemoteAccount) GetBalance() *big.Int
- func (ra *RemoteAccount) GetKv(key string) []byte
- func (ra *RemoteAccount) GetNonce() uint64
- func (ra *RemoteAccount) Init(accID string, balance *big.Int, state *RemoteState)
- func (ra *RemoteAccount) Key() string
- func (ra *RemoteAccount) Load(state *RemoteState)
- func (ra *RemoteAccount) OnCommit() error
- func (ra *RemoteAccount) SetKv(key string, value []byte) (err error)
- func (ra *RemoteAccount) SubBalance(sub *big.Int) error
- type RemoteState
- func (rs *RemoteState) AccDelKv(accID string, key string)
- func (rs *RemoteState) AccGetKv(accID string, key string) []byte
- func (rs *RemoteState) AccSetKv(accID string, key string, value []byte) error
- func (rs *RemoteState) AddNonce(accID string, add uint64)
- func (rs *RemoteState) Copy() *RemoteState
- func (rs *RemoteState) CreateRemoteAcc(accID string, balance *big.Int) *RemoteAccount
- func (rs *RemoteState) GetBalance(accID string) *big.Int
- func (rs *RemoteState) GetNonce(accID string) uint64
- func (rs *RemoteState) RemoteAcc(accID string) *RemoteAccount
- func (rs *RemoteState) RevertToSnapshot(version int)
- func (rs *RemoteState) Snapshot() int
- func (rs *RemoteState) Transfer(fromID, toID string, balance *big.Int) bool
- type RevertLayer
- type StVersion
- type State
- func (os *State) Commit() ([]byte, error)
- func (os *State) Copy() (cp *State)
- func (os *State) CreateData(acc cvtypes.StateDataItfc) (err error)
- func (os *State) ExistData(accID string) bool
- func (os *State) GetData(accID string, fromBytes cvtypes.FromBytesFunc) (acc cvtypes.StateDataItfc, err error)
- func (os *State) Load(root []byte)
- func (os *State) Lock()
- func (os *State) MarkModified(key string)
- func (os *State) ModifyData(key string, data cvtypes.StateDataItfc)
- func (os *State) Reload(root []byte)
- func (os *State) RemoveData(accID string) bool
- func (os *State) Unlock()
- type StateKvData
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func JointKvDataKey ¶
key is dangerous, so be carefull
func KVDataFromBytes ¶
func KVDataFromBytes(key string, data []byte) (cvtypes.StateDataItfc, error)
func KvDataSplit ¶
func RemoteAccFromBytes ¶
func RemoteAccFromBytes(key string, data []byte) (cvtypes.StateDataItfc, error)
Types ¶
type ModifiedUndoItfc ¶
type ModifiedUndoItfc interface { Undo(state cvtypes.StateItfc) Copy() ModifiedUndoItfc }
type ModifyBalanceUndo ¶
type ModifyBalanceUndo struct {
// contains filtered or unexported fields
}
func (*ModifyBalanceUndo) Copy ¶
func (n *ModifyBalanceUndo) Copy() ModifiedUndoItfc
func (*ModifyBalanceUndo) Undo ¶
func (n *ModifyBalanceUndo) Undo(state cvtypes.StateItfc)
type ModifyKvUndo ¶
type ModifyKvUndo struct {
// contains filtered or unexported fields
}
func (*ModifyKvUndo) Copy ¶
func (n *ModifyKvUndo) Copy() ModifiedUndoItfc
func (*ModifyKvUndo) Undo ¶
func (n *ModifyKvUndo) Undo(state cvtypes.StateItfc)
type ModifyNonceUndo ¶
type ModifyNonceUndo struct {
// contains filtered or unexported fields
}
func (*ModifyNonceUndo) Copy ¶
func (n *ModifyNonceUndo) Copy() ModifiedUndoItfc
func (*ModifyNonceUndo) Undo ¶
func (n *ModifyNonceUndo) Undo(state cvtypes.StateItfc)
type RemoteAccount ¶
type RemoteAccount struct { cvtypes.RemoteAccountData // contains filtered or unexported fields }
func (*RemoteAccount) AddBalance ¶
func (ra *RemoteAccount) AddBalance(add *big.Int)
func (*RemoteAccount) AddNonce ¶
func (ra *RemoteAccount) AddNonce(add uint64)
func (*RemoteAccount) Bytes ¶
func (ra *RemoteAccount) Bytes() ([]byte, error)
func (*RemoteAccount) Copy ¶
func (ra *RemoteAccount) Copy() cvtypes.StateDataItfc
func (*RemoteAccount) DelKv ¶
func (ra *RemoteAccount) DelKv(key string)
func (*RemoteAccount) GetBalance ¶
func (ra *RemoteAccount) GetBalance() *big.Int
func (*RemoteAccount) GetKv ¶
func (ra *RemoteAccount) GetKv(key string) []byte
func (*RemoteAccount) GetNonce ¶
func (ra *RemoteAccount) GetNonce() uint64
func (*RemoteAccount) Init ¶
func (ra *RemoteAccount) Init(accID string, balance *big.Int, state *RemoteState)
func (*RemoteAccount) Key ¶
func (ra *RemoteAccount) Key() string
func (*RemoteAccount) Load ¶
func (ra *RemoteAccount) Load(state *RemoteState)
func (*RemoteAccount) OnCommit ¶
func (ra *RemoteAccount) OnCommit() error
func (*RemoteAccount) SubBalance ¶
func (ra *RemoteAccount) SubBalance(sub *big.Int) error
type RemoteState ¶
type RemoteState struct { *State // contains filtered or unexported fields }
func NewRemoteState ¶
func NewRemoteState(database db.DB, log *zap.Logger) *RemoteState
func (*RemoteState) AccDelKv ¶
func (rs *RemoteState) AccDelKv(accID string, key string)
func (*RemoteState) AccSetKv ¶
func (rs *RemoteState) AccSetKv(accID string, key string, value []byte) error
func (*RemoteState) AddNonce ¶
func (rs *RemoteState) AddNonce(accID string, add uint64)
func (*RemoteState) Copy ¶
func (rs *RemoteState) Copy() *RemoteState
func (*RemoteState) CreateRemoteAcc ¶
func (rs *RemoteState) CreateRemoteAcc(accID string, balance *big.Int) *RemoteAccount
func (*RemoteState) GetBalance ¶
func (rs *RemoteState) GetBalance(accID string) *big.Int
func (*RemoteState) GetNonce ¶
func (rs *RemoteState) GetNonce(accID string) uint64
func (*RemoteState) RemoteAcc ¶
func (rs *RemoteState) RemoteAcc(accID string) *RemoteAccount
func (*RemoteState) RevertToSnapshot ¶
func (rs *RemoteState) RevertToSnapshot(version int)
func (*RemoteState) Snapshot ¶
func (rs *RemoteState) Snapshot() int
type RevertLayer ¶
type RevertLayer struct {
// contains filtered or unexported fields
}
func (*RevertLayer) Copy ¶
func (rl *RevertLayer) Copy() *RevertLayer
func (*RevertLayer) Init ¶
func (rl *RevertLayer) Init(state cvtypes.StateItfc)
func (*RevertLayer) RevertToVerstion ¶
func (rl *RevertLayer) RevertToVerstion(v int)
func (*RevertLayer) Snapshot ¶
func (rl *RevertLayer) Snapshot() int
type State ¶
type State struct {
// contains filtered or unexported fields
}
func (*State) CreateData ¶
func (os *State) CreateData(acc cvtypes.StateDataItfc) (err error)
func (*State) GetData ¶
func (os *State) GetData(accID string, fromBytes cvtypes.FromBytesFunc) (acc cvtypes.StateDataItfc, err error)
func (*State) MarkModified ¶
MarkModified puts accounts into dirty cache and they will be persisted during commit
func (*State) ModifyData ¶
func (os *State) ModifyData(key string, data cvtypes.StateDataItfc)
func (*State) RemoveData ¶
RemoveData acts in a sync-block way remove related bufferred data and remove the data from db immediately
type StateKvData ¶
type StateKvData struct {
// contains filtered or unexported fields
}
for RemoteAccount, the key of saved KVdata should always like "<acc>-<user-key>"
func (*StateKvData) Bytes ¶
func (k *StateKvData) Bytes() ([]byte, error)
func (*StateKvData) Copy ¶
func (k *StateKvData) Copy() cvtypes.StateDataItfc
func (*StateKvData) Init ¶
func (k *StateKvData) Init(key string, value []byte)
func (*StateKvData) Key ¶
func (k *StateKvData) Key() string
func (*StateKvData) OnCommit ¶
func (k *StateKvData) OnCommit() error
func (*StateKvData) Reset ¶
func (k *StateKvData) Reset(key string, value []byte)
Click to show internal directories.
Click to hide internal directories.