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.

83 lines
1.6 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([]string)
  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. )
  39. func SetConfig(c cfg.Config) {
  40. config = c
  41. }
  42. func SetEventSwitch(evsw types.EventSwitch) {
  43. eventSwitch = evsw
  44. }
  45. func SetBlockStore(bs types.BlockStore) {
  46. blockStore = bs
  47. }
  48. func SetMempool(mem types.Mempool) {
  49. mempool = mem
  50. }
  51. func SetConsensusState(cs Consensus) {
  52. consensusState = cs
  53. }
  54. func SetSwitch(sw P2P) {
  55. p2pSwitch = sw
  56. }
  57. func SetPubKey(pk crypto.PubKey) {
  58. pubKey = pk
  59. }
  60. func SetGenesisDoc(doc *types.GenesisDoc) {
  61. genDoc = doc
  62. }
  63. func SetProxyAppQuery(appConn proxy.AppConnQuery) {
  64. proxyAppQuery = appConn
  65. }