tendermint/example/chain_aware/chain_aware_app.go
Tzu-Jung Lee fcaa545e1e lint: remove dot import (go-common)
Spell out the package explicitly.
This commit is totally textual, and does not change any logic.

The swiss-army knife package may serve a kick-start in early
stage development. But as the codebase growing, we might want
to retire it gradually:

  For simple wrapping functions, just inline it on the call site.
  For larger pice of code, make it an independent package.
2017-01-16 23:20:04 -08:00

77 lines
1.7 KiB
Go

package main
import (
"flag"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
common "github.com/tendermint/go-common"
)
func main() {
addrPtr := flag.String("addr", "tcp://0.0.0.0:46658", "Listen address")
abciPtr := flag.String("abci", "socket", "socket | grpc")
flag.Parse()
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, NewChainAwareApplication())
if err != nil {
common.Exit(err.Error())
}
// Wait forever
common.TrapSignal(func() {
// Cleanup
srv.Stop()
})
}
type ChainAwareApplication struct {
beginCount int
endCount int
}
func NewChainAwareApplication() *ChainAwareApplication {
return &ChainAwareApplication{}
}
func (app *ChainAwareApplication) Info() types.ResponseInfo {
return types.ResponseInfo{}
}
func (app *ChainAwareApplication) SetOption(key string, value string) (log string) {
return ""
}
func (app *ChainAwareApplication) DeliverTx(tx []byte) types.Result {
return types.NewResultOK(nil, "")
}
func (app *ChainAwareApplication) CheckTx(tx []byte) types.Result {
return types.NewResultOK(nil, "")
}
func (app *ChainAwareApplication) Commit() types.Result {
return types.NewResultOK([]byte("nil"), "")
}
func (app *ChainAwareApplication) Query(query []byte) types.Result {
return types.NewResultOK([]byte(common.Fmt("%d,%d", app.beginCount, app.endCount)), "")
}
func (app *ChainAwareApplication) BeginBlock(hash []byte, header *types.Header) {
app.beginCount += 1
return
}
func (app *ChainAwareApplication) EndBlock(height uint64) (resEndBlock types.ResponseEndBlock) {
app.endCount += 1
return
}
func (app *ChainAwareApplication) InitChain(vals []*types.Validator) {
return
}