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.

144 lines
3.6 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. package proxy
  2. import (
  3. abcicli "github.com/tendermint/abci/client"
  4. "github.com/tendermint/abci/types"
  5. )
  6. //----------------------------------------------------------------------------------------
  7. // Enforce which abci msgs can be sent on a connection at the type level
  8. type AppConnConsensus interface {
  9. SetResponseCallback(abcicli.Callback)
  10. Error() error
  11. InitChainSync(types.RequestInitChain) error
  12. BeginBlockSync(types.RequestBeginBlock) error
  13. DeliverTxAsync(tx []byte) *abcicli.ReqRes
  14. EndBlockSync(height uint64) (*types.ResponseEndBlock, error)
  15. CommitSync() (*types.ResponseCommit, error)
  16. }
  17. type AppConnMempool interface {
  18. SetResponseCallback(abcicli.Callback)
  19. Error() error
  20. CheckTxAsync(tx []byte) *abcicli.ReqRes
  21. FlushAsync() *abcicli.ReqRes
  22. FlushSync() error
  23. }
  24. type AppConnQuery interface {
  25. Error() error
  26. EchoSync(string) (*types.ResponseEcho, error)
  27. InfoSync(types.RequestInfo) (*types.ResponseInfo, error)
  28. QuerySync(types.RequestQuery) (*types.ResponseQuery, error)
  29. // SetOptionSync(key string, value string) (res types.Result)
  30. }
  31. //-----------------------------------------------------------------------------------------
  32. // Implements AppConnConsensus (subset of abcicli.Client)
  33. type appConnConsensus struct {
  34. appConn abcicli.Client
  35. }
  36. func NewAppConnConsensus(appConn abcicli.Client) *appConnConsensus {
  37. return &appConnConsensus{
  38. appConn: appConn,
  39. }
  40. }
  41. func (app *appConnConsensus) SetResponseCallback(cb abcicli.Callback) {
  42. app.appConn.SetResponseCallback(cb)
  43. }
  44. func (app *appConnConsensus) Error() error {
  45. return app.appConn.Error()
  46. }
  47. func (app *appConnConsensus) InitChainSync(req types.RequestInitChain) error {
  48. return app.appConn.InitChainSync(req)
  49. }
  50. func (app *appConnConsensus) BeginBlockSync(req types.RequestBeginBlock) error {
  51. return app.appConn.BeginBlockSync(req)
  52. }
  53. func (app *appConnConsensus) DeliverTxAsync(tx []byte) *abcicli.ReqRes {
  54. return app.appConn.DeliverTxAsync(tx)
  55. }
  56. func (app *appConnConsensus) EndBlockSync(height uint64) (*types.ResponseEndBlock, error) {
  57. return app.appConn.EndBlockSync(height)
  58. }
  59. func (app *appConnConsensus) CommitSync() (*types.ResponseCommit, error) {
  60. return app.appConn.CommitSync()
  61. }
  62. //------------------------------------------------
  63. // Implements AppConnMempool (subset of abcicli.Client)
  64. type appConnMempool struct {
  65. appConn abcicli.Client
  66. }
  67. func NewAppConnMempool(appConn abcicli.Client) *appConnMempool {
  68. return &appConnMempool{
  69. appConn: appConn,
  70. }
  71. }
  72. func (app *appConnMempool) SetResponseCallback(cb abcicli.Callback) {
  73. app.appConn.SetResponseCallback(cb)
  74. }
  75. func (app *appConnMempool) Error() error {
  76. return app.appConn.Error()
  77. }
  78. func (app *appConnMempool) FlushAsync() *abcicli.ReqRes {
  79. return app.appConn.FlushAsync()
  80. }
  81. func (app *appConnMempool) FlushSync() error {
  82. return app.appConn.FlushSync()
  83. }
  84. func (app *appConnMempool) CheckTxAsync(tx []byte) *abcicli.ReqRes {
  85. return app.appConn.CheckTxAsync(tx)
  86. }
  87. //------------------------------------------------
  88. // Implements AppConnQuery (subset of abcicli.Client)
  89. type appConnQuery struct {
  90. appConn abcicli.Client
  91. }
  92. func NewAppConnQuery(appConn abcicli.Client) *appConnQuery {
  93. return &appConnQuery{
  94. appConn: appConn,
  95. }
  96. }
  97. func (app *appConnQuery) Error() error {
  98. return app.appConn.Error()
  99. }
  100. func (app *appConnQuery) EchoSync(msg string) (*types.ResponseEcho, error) {
  101. return app.appConn.EchoSync(msg)
  102. }
  103. func (app *appConnQuery) InfoSync(req types.RequestInfo) (*types.ResponseInfo, error) {
  104. return app.appConn.InfoSync(req)
  105. }
  106. func (app *appConnQuery) QuerySync(reqQuery types.RequestQuery) (*types.ResponseQuery, error) {
  107. return app.appConn.QuerySync(reqQuery)
  108. }