You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.8 KiB

  1. package core
  2. import (
  3. crypto "github.com/tendermint/go-crypto"
  4. "github.com/tendermint/tendermint/consensus"
  5. p2p "github.com/tendermint/tendermint/p2p"
  6. "github.com/tendermint/tendermint/proxy"
  7. "github.com/tendermint/tendermint/state/txindex"
  8. "github.com/tendermint/tendermint/types"
  9. )
  10. //----------------------------------------------
  11. // These interfaces are used by RPC and must be thread safe
  12. type Consensus interface {
  13. GetValidators() (int, []*types.Validator)
  14. GetRoundState() *consensus.RoundState
  15. }
  16. type P2P interface {
  17. Listeners() []p2p.Listener
  18. Peers() p2p.IPeerSet
  19. NumPeers() (outbound, inbound, dialig int)
  20. NodeInfo() *p2p.NodeInfo
  21. IsListening() bool
  22. DialSeeds(*p2p.AddrBook, []string) error
  23. }
  24. //----------------------------------------------
  25. var (
  26. // external, thread safe interfaces
  27. eventSwitch types.EventSwitch
  28. proxyAppQuery proxy.AppConnQuery
  29. // interfaces defined in types and above
  30. blockStore types.BlockStore
  31. mempool types.Mempool
  32. consensusState Consensus
  33. p2pSwitch P2P
  34. // objects
  35. pubKey crypto.PubKey
  36. genDoc *types.GenesisDoc // cache the genesis structure
  37. addrBook *p2p.AddrBook
  38. txIndexer txindex.TxIndexer
  39. )
  40. func SetEventSwitch(evsw types.EventSwitch) {
  41. eventSwitch = evsw
  42. }
  43. func SetBlockStore(bs types.BlockStore) {
  44. blockStore = bs
  45. }
  46. func SetMempool(mem types.Mempool) {
  47. mempool = mem
  48. }
  49. func SetConsensusState(cs Consensus) {
  50. consensusState = cs
  51. }
  52. func SetSwitch(sw P2P) {
  53. p2pSwitch = sw
  54. }
  55. func SetPubKey(pk crypto.PubKey) {
  56. pubKey = pk
  57. }
  58. func SetGenesisDoc(doc *types.GenesisDoc) {
  59. genDoc = doc
  60. }
  61. func SetAddrBook(book *p2p.AddrBook) {
  62. addrBook = book
  63. }
  64. func SetProxyAppQuery(appConn proxy.AppConnQuery) {
  65. proxyAppQuery = appConn
  66. }
  67. func SetTxIndexer(indexer txindex.TxIndexer) {
  68. txIndexer = indexer
  69. }