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.

80 lines
1.8 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
  1. package main
  2. import (
  3. "flag"
  4. . "github.com/tendermint/go-common"
  5. "github.com/tendermint/abci/server"
  6. "github.com/tendermint/abci/types"
  7. )
  8. func main() {
  9. addrPtr := flag.String("addr", "tcp://0.0.0.0:46658", "Listen address")
  10. abciPtr := flag.String("abci", "socket", "socket | grpc")
  11. flag.Parse()
  12. // Start the listener
  13. srv, err := server.NewServer(*addrPtr, *abciPtr, NewChainAwareApplication())
  14. if err != nil {
  15. Exit(err.Error())
  16. }
  17. // Wait forever
  18. TrapSignal(func() {
  19. // Cleanup
  20. srv.Stop()
  21. })
  22. }
  23. type ChainAwareApplication struct {
  24. beginCount int
  25. endCount int
  26. }
  27. func NewChainAwareApplication() *ChainAwareApplication {
  28. return &ChainAwareApplication{}
  29. }
  30. func (app *ChainAwareApplication) Info() types.ResponseInfo {
  31. return types.ResponseInfo{}
  32. }
  33. func (app *ChainAwareApplication) SetOption(key string, value string) (log string) {
  34. return ""
  35. }
  36. func (app *ChainAwareApplication) DeliverTx(tx []byte) types.Result {
  37. return types.NewResultOK(nil, "")
  38. }
  39. func (app *ChainAwareApplication) CheckTx(tx []byte) types.Result {
  40. return types.NewResultOK(nil, "")
  41. }
  42. func (app *ChainAwareApplication) Commit() types.Result {
  43. return types.NewResultOK([]byte("nil"), "")
  44. }
  45. func (app *ChainAwareApplication) Query(query []byte) types.Result {
  46. return types.NewResultOK([]byte(Fmt("%d,%d", app.beginCount, app.endCount)), "")
  47. }
  48. func (app *ChainAwareApplication) Proof(key []byte, blockHeight int64) types.Result {
  49. return types.NewResultOK(nil, Fmt("Proof is not supported"))
  50. }
  51. func (app *ChainAwareApplication) BeginBlock(hash []byte, header *types.Header) {
  52. app.beginCount += 1
  53. return
  54. }
  55. func (app *ChainAwareApplication) EndBlock(height uint64) (resEndBlock types.ResponseEndBlock) {
  56. app.endCount += 1
  57. return
  58. }
  59. func (app *ChainAwareApplication) InitChain(vals []*types.Validator) {
  60. return
  61. }