Documentation ¶
Index ¶
- type APPState
- type Account
- type AccountState
- type BlockState
- type ConchApplication
- func (app *ConchApplication) BeginBlock(req types.RequestBeginBlock) types.ResponseBeginBlock
- func (app *ConchApplication) CheckTx(tx []byte) types.ResponseCheckTx
- func (app *ConchApplication) Commit() types.ResponseCommit
- func (app *ConchApplication) DeliverTx(tx []byte) types.ResponseDeliverTx
- func (app *ConchApplication) EndBlock(req types.RequestEndBlock) types.ResponseEndBlock
- func (app *ConchApplication) Info(req types.RequestInfo) types.ResponseInfo
- func (app *ConchApplication) InitChain(req types.RequestInitChain) types.ResponseInitChain
- func (app *ConchApplication) Query(reqQuery types.RequestQuery) types.ResponseQuery
- func (app *ConchApplication) SetLogger(l log.Logger)
- func (app *ConchApplication) SetOption(req types.RequestSetOption) types.ResponseSetOption
- type HeaderState
- type QueryProcesser
- type Transaction
- func (tx *Transaction) CheckArgs() bool
- func (tx *Transaction) FeeCalc() *big.Int
- func (tx *Transaction) FormCode() []byte
- func (tx *Transaction) Hash() []byte
- func (tx *Transaction) IsValidTx() bool
- func (tx *Transaction) Serialization() string
- func (tx *Transaction) SignTx(privKey crypto.PrivKey) (string, error)
- func (tx *Transaction) TxID() string
- type TransactionReceipt
- type TransactionReceipts
- type Transactions
- type TxRepState
- type TxState
- type VMActuator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APPState ¶
type APPState struct { HeadSt *HeaderState AccoutSt *AccountState TxSt *TxState TxRepSt *TxRepState BlkSt *BlockState DB *sqlx.DB }
APPState state set
func NewAPPState ¶
NewAPPState return app state init db (if db is not exist create the database and tables)
type AccountState ¶
AccountState means current account's info
func NewAccountState ¶
func NewAccountState(db *sqlx.DB, log log.Logger) *AccountState
NewAccountState return AccountState inst
func (*AccountState) LoadAccount ¶
func (as *AccountState) LoadAccount(address string) (*Account, error)
LoadAccount get account from cache or db
func (*AccountState) SyncToDisk ¶
func (as *AccountState) SyncToDisk() error
SyncToDisk cache to disk
func (*AccountState) UpdateAccountCache ¶
func (as *AccountState) UpdateAccountCache(acc *Account)
UpdateAccountCache update account in memory
type BlockState ¶
type BlockState struct { APPHash string TxRoot string TxRepRoot string BlockHash string BlockNum int64 TimeStamp int64 // contains filtered or unexported fields }
BlockState current app block state
func NewBlockState ¶
func NewBlockState(db *sqlx.DB, log log.Logger) *BlockState
NewBlockState block state instance
type ConchApplication ¶
type ConchApplication struct { // validator set ValUpdates []types.Validator // contains filtered or unexported fields }
ConchApplication is the Application's impl
func NewConchApplication ¶
func NewConchApplication(dbDir string) *ConchApplication
NewConchApplication return new instance
func (*ConchApplication) BeginBlock ¶
func (app *ConchApplication) BeginBlock(req types.RequestBeginBlock) types.ResponseBeginBlock
BeginBlock Track the block hash and header information
func (*ConchApplication) CheckTx ¶
func (app *ConchApplication) CheckTx(tx []byte) types.ResponseCheckTx
CheckTx is called when one tx need be send in mempool
func (*ConchApplication) Commit ¶
func (app *ConchApplication) Commit() types.ResponseCommit
Commit will panic if InitChain was not called
func (*ConchApplication) DeliverTx ¶
func (app *ConchApplication) DeliverTx(tx []byte) types.ResponseDeliverTx
DeliverTx deleiver an transaction to app
func (*ConchApplication) EndBlock ¶
func (app *ConchApplication) EndBlock(req types.RequestEndBlock) types.ResponseEndBlock
EndBlock Update the validator set
func (*ConchApplication) Info ¶
func (app *ConchApplication) Info(req types.RequestInfo) types.ResponseInfo
Info impl interface
func (*ConchApplication) InitChain ¶
func (app *ConchApplication) InitChain(req types.RequestInitChain) types.ResponseInitChain
InitChain Save the validators in the merkle tree
func (*ConchApplication) Query ¶
func (app *ConchApplication) Query(reqQuery types.RequestQuery) types.ResponseQuery
Query for query info
func (*ConchApplication) SetLogger ¶
func (app *ConchApplication) SetLogger(l log.Logger)
SetLogger set logger
func (*ConchApplication) SetOption ¶
func (app *ConchApplication) SetOption(req types.RequestSetOption) types.ResponseSetOption
SetOption set option
type HeaderState ¶
type HeaderState struct { CurBlockNum int64 `json:"cur_block_num"` CurBlockHash string `json:"cur_block_hash"` CurAPPHash string `json:"cur_app_hash"` TimeStamp int64 `json:"time_stamp"` Fee *big.Int // contains filtered or unexported fields }
HeaderState appheader state
func (*HeaderState) LoadHeaderState ¶
func (hdSt *HeaderState) LoadHeaderState() error
LoadHeaderState from db load header
type QueryProcesser ¶
QueryProcesser 查询处理
func (*QueryProcesser) Query ¶
func (q *QueryProcesser) Query(reqQuery types.RequestQuery) types.ResponseQuery
Query main entry
func (*QueryProcesser) RegistHandler ¶
func (q *QueryProcesser) RegistHandler(name string, handler handerFunc)
RegistHandler ...
type Transaction ¶
type Transaction struct { ID string `json:"id"` Sender string `json:"sender"` Receiver string `json:"receiver"` Input string `json:"input"` Sign string `json:"sign"` Value string `json:"value"` TimeStamp int64 `json:"time"` RefBlockNum int64 `json:"ref_block"` Nonce string `json:"nonce"` ExpiredNum int `json:"expired"` Cache struct { // contains filtered or unexported fields } `json:"-"` }
Transaction tx type
func BuildNewTx ¶
func BuildNewTx(sender, receive, input, nonce, value string, time, refBlock, expired int64) *Transaction
BuildNewTx create a new tx
func (*Transaction) CheckArgs ¶
func (tx *Transaction) CheckArgs() bool
CheckArgs tx's args is vaild
func (*Transaction) FormCode ¶
func (tx *Transaction) FormCode() []byte
FormCode organize tx field content then marshal
func (*Transaction) IsValidTx ¶
func (tx *Transaction) IsValidTx() bool
IsValidTx check tx valid or not
func (*Transaction) Serialization ¶
func (tx *Transaction) Serialization() string
Serialization json tx and base64
type TransactionReceipt ¶
type TransactionReceipt struct { Status int Fee *big.Int BlockNum int64 TxHash string Log string // contains filtered or unexported fields }
TransactionReceipt tx receipt
type TransactionReceipts ¶
type TransactionReceipts []*TransactionReceipt
TransactionReceipts trxreps
func (TransactionReceipts) AppendTxrp ¶
func (txrp TransactionReceipts) AppendTxrp(trp *TransactionReceipt) TransactionReceipts
AppendTxrp append an tx receipt
func (TransactionReceipts) HashRoot ¶
func (txrp TransactionReceipts) HashRoot() string
HashRoot merkle root
type Transactions ¶
type Transactions []*Transaction
Transactions list of Transaction
func (Transactions) AppendTx ¶
func (txs Transactions) AppendTx(tx *Transaction) Transactions
AppendTx append an tx
type TxRepState ¶
type TxRepState struct { sync.RWMutex Txreps TransactionReceipts // contains filtered or unexported fields }
TxRepState means current tx receipt's info
func NewTxRepState ¶
func NewTxRepState(db *sqlx.DB, log log.Logger) *TxRepState
NewTxRepState tx receipt inst
func (*TxRepState) SyncToDisk ¶
func (txrSt *TxRepState) SyncToDisk(height int64) (hashRoot string, err error)
SyncToDisk write tx to db
func (*TxRepState) UpdateTxRep ¶
func (txrSt *TxRepState) UpdateTxRep(tr *TransactionReceipt)
UpdateTxRep append tx
type TxState ¶
type TxState struct { sync.RWMutex Txs Transactions // contains filtered or unexported fields }
TxState means current tx's info
func (*TxState) QueryTxByID ¶
func (txState *TxState) QueryTxByID(id string) Transaction
QueryTxByID query tx by id
func (*TxState) QueryTxsByAccount ¶
func (txState *TxState) QueryTxsByAccount(account string, start, offset int64) Transactions
QueryTxsByAccount query account related tx
func (*TxState) SyncToDisk ¶
SyncToDisk write tx to db
type VMActuator ¶
type VMActuator struct {
// contains filtered or unexported fields
}
VMActuator vitual machine to exec transaction then update related state
func NewVMActuator ¶
func NewVMActuator(state *APPState) *VMActuator
NewVMActuator return VMActuator inst
func (*VMActuator) ExecuteTx ¶
func (vm *VMActuator) ExecuteTx(tx *Transaction) error
ExecuteTx exec tx and update state