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.

88 lines
1.7 KiB

  1. package core
  2. import (
  3. cfg "github.com/tendermint/go-config"
  4. "github.com/tendermint/go-crypto"
  5. "github.com/tendermint/go-p2p"
  6. "github.com/tendermint/tendermint/consensus"
  7. "github.com/tendermint/tendermint/proxy"
  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. config cfg.Config
  30. // interfaces defined in types and above
  31. blockStore types.BlockStore
  32. mempool types.Mempool
  33. consensusState Consensus
  34. p2pSwitch P2P
  35. // objects
  36. pubKey crypto.PubKey
  37. genDoc *types.GenesisDoc // cache the genesis structure
  38. addrBook *p2p.AddrBook
  39. )
  40. func SetConfig(c cfg.Config) {
  41. config = c
  42. }
  43. func SetEventSwitch(evsw types.EventSwitch) {
  44. eventSwitch = evsw
  45. }
  46. func SetBlockStore(bs types.BlockStore) {
  47. blockStore = bs
  48. }
  49. func SetMempool(mem types.Mempool) {
  50. mempool = mem
  51. }
  52. func SetConsensusState(cs Consensus) {
  53. consensusState = cs
  54. }
  55. func SetSwitch(sw P2P) {
  56. p2pSwitch = sw
  57. }
  58. func SetPubKey(pk crypto.PubKey) {
  59. pubKey = pk
  60. }
  61. func SetGenesisDoc(doc *types.GenesisDoc) {
  62. genDoc = doc
  63. }
  64. func SetAddrBook(book *p2p.AddrBook) {
  65. addrBook = book
  66. }
  67. func SetProxyAppQuery(appConn proxy.AppConnQuery) {
  68. proxyAppQuery = appConn
  69. }