跨链Cosmos(12) Cosmos插件
生活随笔
收集整理的這篇文章主要介紹了
跨链Cosmos(12) Cosmos插件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Tendermint 有一個插件模塊,我們可以實現 plugin 中接口,在 ibc 插件中執行跨鏈交易。
1. plugin 接口的定義
//與 abci 接口很類似 type Plugin interface {// Name of this plugin, should be short.Name() string// Run a transaction from ABCI DeliverTxRunTx(store KVStore, ctx CallContext, txBytes []byte) (res abci.Result)// Other ABCI message handlersSetOption(store KVStore, key, value string) (log string)InitChain(store KVStore, vals []*abci.Validator)BeginBlock(store KVStore, hash []byte, header *abci.Header)EndBlock(store KVStore, height uint64) abci.ResponseEndBlock }2. deliverTx 時將 ibc 交易交給 plugin
// ABCI::DeliverTx func (app *BaseApp) DeliverTx(txBytes []byte) (res abci.Result) { // Exec txswitch tx := tx.(type) {case *types.SendTx: // 執行正常交交易case *types.AppTx:// 執行plugin中的交易plugin := pgz.GetByName(tx.Name)res = plugin.RunTx(cache, ctx, tx.Data)return resdefault:return abci.ErrBaseEncodingError.SetLog("Unknown tx type")}return res}總結
以上是生活随笔為你收集整理的跨链Cosmos(12) Cosmos插件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 跨链Cosmos(11) 消息结构
- 下一篇: 跨链Cosmos(3)IBC协议二