app

package
v2.2.2+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2018 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CodeTypeOK                uint32 = 0
	CodeTypeEncodingError     uint32 = 1
	CodeTypeBadNonce          uint32 = 2
	CodeTypeUnauthorized      uint32 = 3
	CodeTypeUnknownRequest    uint32 = 4
	CodeTypeDeliverTxError    uint32 = 5
	CodeTypeCheckTxError      uint32 = 6
	CodeTypeQueryError        uint32 = 7
	CodeEmptySearchQuery      uint32 = 8
	CodeParseSearchQueryError uint32 = 9
)

Anychaindb response codes

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	types.BaseApplication
	// contains filtered or unexported fields
}

Application inherits BaseApplication and keeps state of anychaindb

func NewApplication

func NewApplication(dbHost, dbName string) *Application

NewApplication method initializes new application with MongoDB state

func (*Application) CheckTx

func (app *Application) CheckTx(txBytes []byte) types.ResponseCheckTx

CheckTx method responsible for check transaction on validity.

func (*Application) Commit

func (app *Application) Commit() types.ResponseCommit

Commit method generates hash of current state.

func (*Application) DeliverTx

func (app *Application) DeliverTx(txBytes []byte) types.ResponseDeliverTx

DeliverTx method responsible for deliver chosen transaction type.

func (*Application) Info

func (app *Application) Info() (resInfo types.ResponseInfo)

Info method returns information about current state. All sizes represented in kilobytes.

func (*Application) Query

func (app *Application) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery)

Query method processes user's request. Search endpoint uses Mongo DB query syntax. For make search request uses mongoQuery struct. The limit and offset fields are optional. All mongo query places in query field of struct. Check mongo query syntax at: https://docs.mongodb.com/manual/tutorial/query-documents/

func (*Application) SetLogger added in v1.2.0

func (app *Application) SetLogger(l log.Logger)

SetLogger method set logger for Application

type LastBlockInfo

type LastBlockInfo struct {
	Height  int64  `bson:"height"`
	AppHash []byte `bson:"app_hash"`
}

type PersistentApplication

type PersistentApplication struct {
	// contains filtered or unexported fields
}

func NewPersistentApplication

func NewPersistentApplication(dbHost, dbName string) *PersistentApplication

NewPersistentApplication method construct application with persistent state

func (*PersistentApplication) BeginBlock

func (app *PersistentApplication) BeginBlock(req types.RequestBeginBlock) (resBeginBlock types.ResponseBeginBlock)

BeginBlock method tracks the block hash and header information

func (*PersistentApplication) CheckTx

func (app *PersistentApplication) CheckTx(tx []byte) types.ResponseCheckTx

CheckTx method validates a transaction in mempool

func (*PersistentApplication) Commit

Commit method commits the state and returns the application state hash

func (*PersistentApplication) DeliverTx

func (app *PersistentApplication) DeliverTx(tx []byte) types.ResponseDeliverTx

DeliverTx method delivers a transaction to state

func (*PersistentApplication) EndBlock

func (app *PersistentApplication) EndBlock(reqEndBlock types.RequestEndBlock) (resEndBlock types.ResponseEndBlock)

EndBlock method should in future update the validator set

func (*PersistentApplication) Info

func (app *PersistentApplication) Info(req types.RequestInfo) (resInfo types.ResponseInfo)

Info method returns application info with last block height and hash

func (*PersistentApplication) InitChain

InitChain method initializes Anychaindb

func (*PersistentApplication) LoadLastBlock

func (app *PersistentApplication) LoadLastBlock() (lastBlock LastBlockInfo)

LoadLastBlock method load last confirmed block from DB

func (*PersistentApplication) Query

Query method invokes for state

func (*PersistentApplication) SaveLastBlock

func (app *PersistentApplication) SaveLastBlock(lastBlock LastBlockInfo)

SaveLastBlock method saves appHash of loast confirmed block in DB

func (*PersistentApplication) SetLogger

func (app *PersistentApplication) SetLogger(l log.Logger)

SetLogger method sets application logger

func (*PersistentApplication) SetOption

SetOption method sets application option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL