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.

94 lines
1.9 KiB

8 years ago
8 years ago
8 years ago
  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. "github.com/tendermint/tmlibs/log"
  10. )
  11. //----------------------------------------------
  12. // These interfaces are used by RPC and must be thread safe
  13. type Consensus interface {
  14. GetValidators() (int, []*types.Validator)
  15. GetRoundState() *consensus.RoundState
  16. }
  17. type P2P interface {
  18. Listeners() []p2p.Listener
  19. Peers() p2p.IPeerSet
  20. NumPeers() (outbound, inbound, dialig int)
  21. NodeInfo() *p2p.NodeInfo
  22. IsListening() bool
  23. DialSeeds(*p2p.AddrBook, []string) error
  24. }
  25. //----------------------------------------------
  26. var (
  27. // external, thread safe interfaces
  28. eventSwitch types.EventSwitch
  29. proxyAppQuery proxy.AppConnQuery
  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. txIndexer txindex.TxIndexer
  40. logger log.Logger
  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 SetAddrBook(book *p2p.AddrBook) {
  64. addrBook = book
  65. }
  66. func SetProxyAppQuery(appConn proxy.AppConnQuery) {
  67. proxyAppQuery = appConn
  68. }
  69. func SetTxIndexer(indexer txindex.TxIndexer) {
  70. txIndexer = indexer
  71. }
  72. func SetLogger(l log.Logger) {
  73. logger = l
  74. }