tendermint/rpc/core/pipe.go

95 lines
1.9 KiB
Go
Raw Normal View History

package core
import (
crypto "github.com/tendermint/go-crypto"
2015-04-01 17:30:16 -07:00
"github.com/tendermint/tendermint/consensus"
2017-04-08 19:04:06 -07:00
p2p "github.com/tendermint/tendermint/p2p"
2016-08-22 13:00:48 -07:00
"github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/state/txindex"
"github.com/tendermint/tendermint/types"
2017-05-02 00:53:32 -07:00
"github.com/tendermint/tmlibs/log"
)
//----------------------------------------------
// These interfaces are used by RPC and must be thread safe
2016-10-14 18:36:42 -07:00
type Consensus interface {
GetValidators() (int, []*types.Validator)
GetRoundState() *consensus.RoundState
}
type P2P interface {
Listeners() []p2p.Listener
Peers() p2p.IPeerSet
NumPeers() (outbound, inbound, dialig int)
NodeInfo() *p2p.NodeInfo
IsListening() bool
2017-03-05 20:13:34 -08:00
DialSeeds(*p2p.AddrBook, []string) error
2016-10-14 18:36:42 -07:00
}
//----------------------------------------------
2016-10-14 18:36:42 -07:00
var (
// external, thread safe interfaces
eventSwitch types.EventSwitch
proxyAppQuery proxy.AppConnQuery
// interfaces defined in types and above
blockStore types.BlockStore
mempool types.Mempool
2016-10-14 18:36:42 -07:00
consensusState Consensus
p2pSwitch P2P
// objects
pubKey crypto.PubKey
genDoc *types.GenesisDoc // cache the genesis structure
addrBook *p2p.AddrBook
txIndexer txindex.TxIndexer
2017-05-02 00:53:32 -07:00
logger log.Logger
2016-10-14 18:36:42 -07:00
)
2016-05-11 20:33:09 -07:00
2016-10-09 23:58:13 -07:00
func SetEventSwitch(evsw types.EventSwitch) {
2016-06-27 17:43:09 -07:00
eventSwitch = evsw
}
func SetBlockStore(bs types.BlockStore) {
blockStore = bs
}
func SetMempool(mem types.Mempool) {
mempool = mem
}
func SetConsensusState(cs Consensus) {
consensusState = cs
}
2016-10-14 18:36:42 -07:00
func SetSwitch(sw P2P) {
p2pSwitch = sw
}
2016-10-14 18:36:42 -07:00
func SetPubKey(pk crypto.PubKey) {
pubKey = pk
}
2015-06-14 15:18:17 -07:00
2015-12-01 20:12:01 -08:00
func SetGenesisDoc(doc *types.GenesisDoc) {
2015-06-14 15:18:17 -07:00
genDoc = doc
}
2016-08-22 13:00:48 -07:00
2017-03-05 20:13:34 -08:00
func SetAddrBook(book *p2p.AddrBook) {
addrBook = book
}
2016-08-22 13:00:48 -07:00
func SetProxyAppQuery(appConn proxy.AppConnQuery) {
proxyAppQuery = appConn
}
func SetTxIndexer(indexer txindex.TxIndexer) {
txIndexer = indexer
}
2017-05-02 00:53:32 -07:00
func SetLogger(l log.Logger) {
logger = l
}