2015-03-26 21:30:42 -07:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
2016-05-11 23:33:09 -04:00
|
|
|
cfg "github.com/tendermint/go-config"
|
2016-10-14 21:36:42 -04:00
|
|
|
"github.com/tendermint/go-crypto"
|
2015-11-01 11:34:08 -08:00
|
|
|
"github.com/tendermint/go-p2p"
|
2016-05-11 23:33:09 -04:00
|
|
|
|
2015-04-01 17:30:16 -07:00
|
|
|
"github.com/tendermint/tendermint/consensus"
|
2016-08-22 16:00:48 -04:00
|
|
|
"github.com/tendermint/tendermint/proxy"
|
2015-08-10 20:38:45 -07:00
|
|
|
"github.com/tendermint/tendermint/types"
|
2015-03-26 21:30:42 -07:00
|
|
|
)
|
|
|
|
|
2017-02-20 20:09:15 -05:00
|
|
|
//----------------------------------------------
|
|
|
|
// These interfaces are used by RPC and must be thread safe
|
2016-10-14 21:36:42 -04: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 23:13:34 -05:00
|
|
|
DialSeeds(*p2p.AddrBook, []string) error
|
2016-10-14 21:36:42 -04:00
|
|
|
}
|
|
|
|
|
2017-02-20 20:09:15 -05:00
|
|
|
//----------------------------------------------
|
|
|
|
|
2016-10-14 21:36:42 -04:00
|
|
|
var (
|
|
|
|
// external, thread safe interfaces
|
|
|
|
eventSwitch types.EventSwitch
|
|
|
|
proxyAppQuery proxy.AppConnQuery
|
|
|
|
config cfg.Config
|
|
|
|
|
2017-02-20 20:09:15 -05:00
|
|
|
// interfaces defined in types and above
|
|
|
|
blockStore types.BlockStore
|
|
|
|
mempool types.Mempool
|
2016-10-14 21:36:42 -04:00
|
|
|
consensusState Consensus
|
|
|
|
p2pSwitch P2P
|
|
|
|
|
|
|
|
// objects
|
2017-03-05 23:13:34 -05:00
|
|
|
pubKey crypto.PubKey
|
|
|
|
genDoc *types.GenesisDoc // cache the genesis structure
|
|
|
|
addrBook *p2p.AddrBook
|
2016-10-14 21:36:42 -04:00
|
|
|
)
|
2016-05-11 23:33:09 -04:00
|
|
|
|
|
|
|
func SetConfig(c cfg.Config) {
|
|
|
|
config = c
|
|
|
|
}
|
|
|
|
|
2016-10-10 02:58:13 -04:00
|
|
|
func SetEventSwitch(evsw types.EventSwitch) {
|
2016-06-27 20:43:09 -04:00
|
|
|
eventSwitch = evsw
|
|
|
|
}
|
|
|
|
|
2017-02-20 20:09:15 -05:00
|
|
|
func SetBlockStore(bs types.BlockStore) {
|
2015-03-26 21:30:42 -07:00
|
|
|
blockStore = bs
|
|
|
|
}
|
|
|
|
|
2017-02-20 20:09:15 -05:00
|
|
|
func SetMempool(mem types.Mempool) {
|
|
|
|
mempool = mem
|
2015-03-26 21:30:42 -07:00
|
|
|
}
|
|
|
|
|
2017-02-20 20:09:15 -05:00
|
|
|
func SetConsensusState(cs Consensus) {
|
|
|
|
consensusState = cs
|
2015-03-26 21:30:42 -07:00
|
|
|
}
|
|
|
|
|
2016-10-14 21:36:42 -04:00
|
|
|
func SetSwitch(sw P2P) {
|
2015-03-26 21:30:42 -07:00
|
|
|
p2pSwitch = sw
|
|
|
|
}
|
2015-03-31 04:53:34 -07:00
|
|
|
|
2016-10-14 21:36:42 -04:00
|
|
|
func SetPubKey(pk crypto.PubKey) {
|
|
|
|
pubKey = pk
|
2015-03-31 04:53:34 -07:00
|
|
|
}
|
2015-06-14 18:18:17 -04:00
|
|
|
|
2015-12-01 20:12:01 -08:00
|
|
|
func SetGenesisDoc(doc *types.GenesisDoc) {
|
2015-06-14 18:18:17 -04:00
|
|
|
genDoc = doc
|
|
|
|
}
|
2016-08-22 16:00:48 -04:00
|
|
|
|
2017-03-05 23:13:34 -05:00
|
|
|
func SetAddrBook(book *p2p.AddrBook) {
|
|
|
|
addrBook = book
|
|
|
|
}
|
|
|
|
|
2016-08-22 16:00:48 -04:00
|
|
|
func SetProxyAppQuery(appConn proxy.AppConnQuery) {
|
|
|
|
proxyAppQuery = appConn
|
|
|
|
}
|