Documentation
¶
Overview ¶
Package baseapp contains data structures that provide basic data storage functionality and act as a bridge between the ABCI interface and the SDK abstractions.
BaseApp has no state except the CommitMultiStore you provide upon init.
nolint: golint
Index ¶
- Constants
- func NewQueryRouter() *queryRouter
- func NewRouter() *router
- func SetMinGasPrices(gasPricesStr string) func(*BaseApp)
- func SetPruning(opts sdk.PruningOptions) func(*BaseApp)
- type BaseApp
- func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeginBlock)
- func (app *BaseApp) Check(tx sdk.Tx) (result sdk.Result)
- func (app *BaseApp) CheckTx(txBytes []byte) (res abci.ResponseCheckTx)
- func (app *BaseApp) Commit() (res abci.ResponseCommit)
- func (app *BaseApp) Deliver(tx sdk.Tx) (result sdk.Result)
- func (app *BaseApp) DeliverTx(txBytes []byte) (res abci.ResponseDeliverTx)
- func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBlock)
- func (app *BaseApp) FilterPeerByAddrPort(info string) abci.ResponseQuery
- func (app *BaseApp) FilterPeerByID(info string) abci.ResponseQuery
- func (app *BaseApp) Info(req abci.RequestInfo) abci.ResponseInfo
- func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitChain)
- func (app *BaseApp) IsSealed() bool
- func (app *BaseApp) LastBlockHeight() int64
- func (app *BaseApp) LastCommitID() sdk.CommitID
- func (app *BaseApp) LoadLatestVersion(baseKey *sdk.KVStoreKey) error
- func (app *BaseApp) LoadVersion(version int64, baseKey *sdk.KVStoreKey) error
- func (app *BaseApp) Logger() log.Logger
- func (app *BaseApp) MountStore(key sdk.StoreKey, typ sdk.StoreType)
- func (app *BaseApp) MountStoreWithDB(key sdk.StoreKey, typ sdk.StoreType, db dbm.DB)
- func (app *BaseApp) MountStores(keys ...sdk.StoreKey)
- func (app *BaseApp) Name() string
- func (app *BaseApp) NewContext(isCheckTx bool, header abci.Header) sdk.Context
- func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery)
- func (app *BaseApp) QueryRouter() QueryRouter
- func (app *BaseApp) Router() Router
- func (app *BaseApp) Seal()
- func (app *BaseApp) SetAddrPeerFilter(pf sdk.PeerFilter)
- func (app *BaseApp) SetAnteHandler(ah sdk.AnteHandler)
- func (app *BaseApp) SetBeginBlocker(beginBlocker sdk.BeginBlocker)
- func (app *BaseApp) SetCMS(cms store.CommitMultiStore)
- func (app *BaseApp) SetCommitMultiStoreTracer(w io.Writer)
- func (app *BaseApp) SetDB(db dbm.DB)
- func (app *BaseApp) SetEndBlocker(endBlocker sdk.EndBlocker)
- func (app *BaseApp) SetFauxMerkleMode()
- func (app *BaseApp) SetIDPeerFilter(pf sdk.PeerFilter)
- func (app *BaseApp) SetInitChainer(initChainer sdk.InitChainer)
- func (app *BaseApp) SetName(name string)
- func (app *BaseApp) SetOption(req abci.RequestSetOption) (res abci.ResponseSetOption)
- func (app *BaseApp) Simulate(txBytes []byte, tx sdk.Tx) (result sdk.Result)
- type QueryRouter
- type Router
Constants ¶
const ( // MainStoreKey is the string representation of the main store // MainStoreKey是 主要存储的字符串表示形式 (也就是 key) MainStoreKey = "main" )
Variables ¶
This section is empty.
Functions ¶
func NewQueryRouter ¶
func NewQueryRouter() *queryRouter
NewQueryRouter returns a reference to a new queryRouter.
TODO: Either make the function private or make return type (queryRouter) public.
func NewRouter ¶
func NewRouter() *router
NewRouter returns a reference to a new router.
TODO: Either make the function private or make return type (router) public.
func SetMinGasPrices ¶
SetMinGasPrices returns an option that sets the minimum gas prices on the app. Setmingasprices: 返回在应用程序上设置最低天然气价格的选项.
func SetPruning ¶
func SetPruning(opts sdk.PruningOptions) func(*BaseApp)
SetPruning sets a pruning option on the multistore associated with the app Setpruning: 在与应用程序关联的多存储上设置一个修剪选项
Types ¶
type BaseApp ¶
type BaseApp struct {
// contains filtered or unexported fields
}
BaseApp reflects the ABCI application implementation.
func NewBaseApp ¶
func NewBaseApp( name string, logger log.Logger, db dbm.DB, txDecoder sdk.TxDecoder, options ...func(*BaseApp), ) *BaseApp
NewBaseApp returns a reference to an initialized BaseApp. It accepts a variadic number of option functions, which act on the BaseApp to set configuration choices.
NOTE: The db is used to store the version number for now.
func (*BaseApp) BeginBlock ¶
func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeginBlock)
BeginBlock implements the ABCI application interface. TODO 交由tendermint 发起 rpc调用
func (*BaseApp) CheckTx ¶
func (app *BaseApp) CheckTx(txBytes []byte) (res abci.ResponseCheckTx)
CheckTx implements the ABCI interface. It runs the "basic checks" to see whether or not a transaction can possibly be executed, first decoding, then the ante handler (which checks signatures/fees/ValidateBasic), then finally the route match to see whether a handler exists.
NOTE:CheckTx does not run the actual Msg handler function(s). * TODO 由 tendermint 来调用
CheckTx实现了ABCI接口。 它运行“基本检查”以查看是否可以执行事务, 首先解码,然后是ante处理程序(检查签名/费用/ ValidateBasic), 然后最终路由匹配以查看是否存在处理程序。
注意:CheckTx不运行实际的Msg处理函数。
CheckTx用于交易池。它只运行AnteHandler (handler累函数调用之前被调用的函数类型)。 消息处理直到交易已经被提交到区块时才开始处理的代价是非常之高的。 AnteHandler对发送者授权,确保他们有足够的手续费去支付。 如果之后交易失败,发送者仍然会支付这笔费用
func (*BaseApp) Commit ¶
func (app *BaseApp) Commit() (res abci.ResponseCommit)
Commit implements the ABCI interface. * TODO 由底层 tendermint 调用 TODO 注意因为GaiaApp 继承了 BaseApp 的哦,所以GaiaApp 可以直接调用这个哦 当处理完成交易后,应该把完成的交易从内存持久化到硬盘上, 并以上为根据创建返回被下一个Tendermint区块需要的默克尔树的Root哈希值。 这个哈希值 的作用在区块链中基本是一样的,用来验证合法性
func (*BaseApp) DeliverTx ¶
func (app *BaseApp) DeliverTx(txBytes []byte) (res abci.ResponseDeliverTx)
DeliverTx implements the ABCI interface.
TODO 这个才是 处理交易的 函数 (由 底层的tendermint 调用) 和 BeginBlock 及EndBlock 息息相关
func (*BaseApp) EndBlock ¶
func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBlock)
EndBlock implements the ABCI interface. * TODO 这个函数最终会由 底层的 tendermint 发起 rpc 调用,来向cosmos 获取最新变更的 验证人列表
最终是调到了 func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock types.pb.go
func (*BaseApp) FilterPeerByAddrPort ¶
func (app *BaseApp) FilterPeerByAddrPort(info string) abci.ResponseQuery
FilterPeerByAddrPort filters peers by address/port.
func (*BaseApp) FilterPeerByID ¶
func (app *BaseApp) FilterPeerByID(info string) abci.ResponseQuery
FilterPeerByIDfilters peers by node ID.
func (*BaseApp) Info ¶
func (app *BaseApp) Info(req abci.RequestInfo) abci.ResponseInfo
Info implements the ABCI interface.
func (*BaseApp) InitChain ¶
func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitChain)
InitChain implements the ABCI interface. It runs the initialization logic directly on the CommitMultiStore. * TODO 重要的入口 交由 tendermint 发起调用 InitChain实现了ABCI接口。 它直接在CommitMultiStore上运行初始化逻辑。
它会被Tendermint在启动时调用一次, 用来初始化各种相关的Message, 比如共识层的参数和最初的验证人的集合数据。 当然,肯定还会有决定信息处理的方式.
在调用这个函数的期间,对这些信息进行填充并存储
func (*BaseApp) LastBlockHeight ¶
LastBlockHeight returns the last committed block height.
func (*BaseApp) LastCommitID ¶
LastCommitID returns the last CommitID of the multistore.
func (*BaseApp) LoadLatestVersion ¶
func (app *BaseApp) LoadLatestVersion(baseKey *sdk.KVStoreKey) error
LoadLatestVersion loads the latest application version. It will panic if called more than once on a running BaseApp. LoadLatestVersion: 加载最新的应用程序版本。 如果在正在运行的BaseApp上多次调用它将会出现混乱。
func (*BaseApp) LoadVersion ¶
func (app *BaseApp) LoadVersion(version int64, baseKey *sdk.KVStoreKey) error
LoadVersion loads the BaseApp application version. It will panic if called more than once on a running baseapp.
func (*BaseApp) MountStore ¶
MountStore mounts a store to the provided key in the BaseApp multistore, using the default DB.
func (*BaseApp) MountStoreWithDB ¶
############ 存储相关 MountStoreWithDB mounts a store to the provided key in the BaseApp multistore, using a specified DB.
func (*BaseApp) MountStores ¶
MountStores mounts all IAVL or DB stores to the provided keys in the BaseApp multistore. * MountStore: 将所有IAVL或DB存储安装到BaseApp多存储中提供的密钥。
func (*BaseApp) NewContext ¶
Context with current {check, deliver}State of the app used by tests
func (*BaseApp) Query ¶
func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery)
Query implements the ABCI interface. It delegates to CommitMultiStore if it implements Queryable.
func (*BaseApp) QueryRouter ¶
func (app *BaseApp) QueryRouter() QueryRouter
QueryRouter returns the QueryRouter of a BaseApp.
func (*BaseApp) Seal ¶
func (app *BaseApp) Seal()
Seal seals a BaseApp. It prohibits any further modifications to a BaseApp.
func (*BaseApp) SetAddrPeerFilter ¶
func (app *BaseApp) SetAddrPeerFilter(pf sdk.PeerFilter)
func (*BaseApp) SetAnteHandler ¶
func (app *BaseApp) SetAnteHandler(ah sdk.AnteHandler)
func (*BaseApp) SetBeginBlocker ¶
func (app *BaseApp) SetBeginBlocker(beginBlocker sdk.BeginBlocker)
func (*BaseApp) SetCMS ¶
func (app *BaseApp) SetCMS(cms store.CommitMultiStore)
func (*BaseApp) SetCommitMultiStoreTracer ¶
SetCommitMultiStoreTracer sets the store tracer on the BaseApp's underlying CommitMultiStore.
func (*BaseApp) SetEndBlocker ¶
func (app *BaseApp) SetEndBlocker(endBlocker sdk.EndBlocker)
func (*BaseApp) SetFauxMerkleMode ¶
func (app *BaseApp) SetFauxMerkleMode()
func (*BaseApp) SetIDPeerFilter ¶
func (app *BaseApp) SetIDPeerFilter(pf sdk.PeerFilter)
func (*BaseApp) SetInitChainer ¶
func (app *BaseApp) SetInitChainer(initChainer sdk.InitChainer)
func (*BaseApp) SetOption ¶
func (app *BaseApp) SetOption(req abci.RequestSetOption) (res abci.ResponseSetOption)
SetOption implements the ABCI interface.
type QueryRouter ¶
type QueryRouter interface { AddRoute(r string, h sdk.Querier) (rtr QueryRouter) Route(path string) (h sdk.Querier) }
QueryRouter provides queryables for each query path.