跨链Cosmos(5)ABCI 接口
生活随笔
收集整理的這篇文章主要介紹了
跨链Cosmos(5)ABCI 接口
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一個協議,支持任何語言的交易處理實現
1. 應用層實現交互的接口
// Application is an interface that enables any finite, deterministic state machine // to be driven by a blockchain-based replication engine via the ABCI. // All methods take a RequestXxx argument and return a ResponseXxx argument, // except CheckTx/DeliverTx, which take `tx []byte`, and `Commit`, which takes nothing. type Application interface {// Info/Query ConnectionInfo(RequestInfo) ResponseInfo // Return application infoQuery(RequestQuery) ResponseQuery // Query for state// Mempool ConnectionCheckTx(RequestCheckTx) ResponseCheckTx // Validate a tx for the mempool// Consensus ConnectionInitChain(RequestInitChain) ResponseInitChain // Initialize blockchain w validators/other info from TendermintCoreBeginBlock(RequestBeginBlock) ResponseBeginBlock // Signals the beginning of a blockDeliverTx(RequestDeliverTx) ResponseDeliverTx // Deliver a tx for full processingEndBlock(RequestEndBlock) ResponseEndBlock // Signals the end of a block, returns changes to the validator setCommit() ResponseCommit // Commit the state and return the application Merkle root hash// State Sync ConnectionListSnapshots(RequestListSnapshots) ResponseListSnapshots // List available snapshotsOfferSnapshot(RequestOfferSnapshot) ResponseOfferSnapshot // Offer a snapshot to the applicationLoadSnapshotChunk(RequestLoadSnapshotChunk) ResponseLoadSnapshotChunk // Load a snapshot chunkApplySnapshotChunk(RequestApplySnapshotChunk) ResponseApplySnapshotChunk // Apply a shapshot chunk }-
Consensus Connection: InitChain, BeginBlock, DeliverTx, EndBlock,
-
CommitMempool Connection: CheckTxInfo
-
Connection: Info, SetOption, Query
proto定義位于 https://github.com/tendermint/abci/blob/master/types/types.proto
2. 一個應用程序可以有3個 ABCI 套接字連接
對應3個消息:
- CheckTx消息
在內存池中廣播時驗證交易,用于驗證交易。Tendermint Core中的mempool通過此消息校驗交易的合法性,通過之后才會將交易廣播給其它節點。 - DeliverTx消息
應用的主要工作流程,通過此消息真正執行交易,包括驗證交易、更新應用程序的狀態。 - Commit消息
通知應用程序計算當前的世界狀態,并存在下一區塊頭中
總結
以上是生活随笔為你收集整理的跨链Cosmos(5)ABCI 接口的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 跨链Cosmos(4)Tendermin
- 下一篇: 跨链Cosmos(6)ABCI 原理