tendermint/types/services.go

92 lines
2.8 KiB
Go
Raw Normal View History

package types
import (
abci "github.com/tendermint/abci/types"
)
2017-11-19 14:18:43 -08:00
// NOTE/XXX: all type definitions in this file are considered UNSTABLE
2017-09-22 09:00:37 -07:00
//------------------------------------------------------
// blockchain services types
// NOTE: Interfaces used by RPC must be thread safe!
//------------------------------------------------------
//------------------------------------------------------
// mempool
// Mempool defines the mempool interface as used by the ConsensusState.
// Updates to the mempool need to be synchronized with committing a block
// so apps can reset their transient state on Commit
2017-09-22 09:00:37 -07:00
// UNSTABLE
type Mempool interface {
Lock()
Unlock()
Size() int
CheckTx(Tx, func(*abci.Response)) error
Reap(int) Txs
Update(height int64, txs Txs) error
Flush()
2017-07-11 22:02:16 -07:00
TxsAvailable() <-chan int64
EnableTxsAvailable()
}
2017-09-22 09:00:37 -07:00
// MockMempool is an empty implementation of a Mempool, useful for testing.
// UNSTABLE
type MockMempool struct {
}
func (m MockMempool) Lock() {}
func (m MockMempool) Unlock() {}
func (m MockMempool) Size() int { return 0 }
func (m MockMempool) CheckTx(tx Tx, cb func(*abci.Response)) error { return nil }
func (m MockMempool) Reap(n int) Txs { return Txs{} }
func (m MockMempool) Update(height int64, txs Txs) error { return nil }
func (m MockMempool) Flush() {}
func (m MockMempool) TxsAvailable() <-chan int64 { return make(chan int64) }
func (m MockMempool) EnableTxsAvailable() {}
//------------------------------------------------------
// blockstore
2017-09-22 09:00:37 -07:00
// BlockStoreRPC is the block store interface used by the RPC.
// UNSTABLE
type BlockStoreRPC interface {
Height() int64
LoadBlockMeta(height int64) *BlockMeta
LoadBlock(height int64) *Block
LoadBlockPart(height int64, index int) *Part
LoadBlockCommit(height int64) *Commit
LoadSeenCommit(height int64) *Commit
}
// BlockStore defines the BlockStore interface used by the ConsensusState.
2017-09-22 09:00:37 -07:00
// UNSTABLE
type BlockStore interface {
BlockStoreRPC
SaveBlock(block *Block, blockParts *PartSet, seenCommit *Commit)
}
//------------------------------------------------------
// evidence pool
// EvidencePool defines the EvidencePool interface used by the ConsensusState.
// UNSTABLE
type EvidencePool interface {
PendingEvidence() []Evidence
AddEvidence(Evidence) error
2017-12-28 18:08:39 -08:00
Update(*Block)
}
// MockMempool is an empty implementation of a Mempool, useful for testing.
// UNSTABLE
type MockEvidencePool struct {
}
2017-12-28 18:08:39 -08:00
func (m MockEvidencePool) PendingEvidence() []Evidence { return nil }
func (m MockEvidencePool) AddEvidence(Evidence) error { return nil }
func (m MockEvidencePool) Update(*Block) {}