Skip to content

oliverasistemas/tendermint-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tendermint basic application

The application implements a key-value store application using the ABCI (Application Blockchain Interface) standard, which is a protocol that allows communication between a Tendermint blockchain node and an external application.

The code defines a struct called KVStoreApplication which has a badger.DB database and a badger.Txn transaction batch as fields. The NewKVStoreApplication function returns a new instance of KVStoreApplication with the specified database.

The KVStoreApplication implements several functions that fulfill the ABCI interface contract, including DeliverTx, CheckTx, Commit, Query, BeginBlock, and Info. These functions are called by the Tendermint node to interact with the key-value store application.

DeliverTx and CheckTx are used to handle transactions. DeliverTx is called when a transaction is committed to a block, while CheckTx is called when a transaction is first received by the Tendermint node. Both functions call isValid to check if the transaction is valid, and if it is, DeliverTx will add the key-value pair to the transaction batch, and CheckTx will return a success code. If the transaction is not valid, the functions will return an error code.

Commit is called when the block is committed, and it commits the transaction batch to the database.

Query is called when the application receives a query from the Tendermint node, and it searches the database for the key specified in the query. If the key exists in the database, it returns the corresponding value, otherwise, it returns an error message.

BeginBlock is called when a new block is begun, and it creates a new transaction batch for the block.

Info, EndBlock, ListSnapshots, OfferSnapshot, LoadSnapshotChunk, and ApplySnapshotChunk are not used in this code, so they are implemented as empty functions.

Overall, this code defines a simple key-value store application that can handle transactions and queries, and can be used with a Tendermint blockchain node.

About

Tendermint basic app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages