diff --git a/types/application.go b/types/application.go index bb9a0030d..f0ce18955 100644 --- a/types/application.go +++ b/types/application.go @@ -25,7 +25,57 @@ type Application interface { Commit() ResponseCommit // Commit the state and return the application Merkle root hash } -//------------------------------------ +//------------------------------------------------------- +// BaseApplication is a base form of Application + +var _ Application = (*BaseApplication)(nil) + +type BaseApplication struct { +} + +func NewBaseApplication() *BaseApplication { + return &BaseApplication{} +} + +func (BaseApplication) Info(req RequestInfo) ResponseInfo { + return ResponseInfo{} +} + +func (BaseApplication) SetOption(req RequestSetOption) ResponseSetOption { + return ResponseSetOption{} +} + +func (BaseApplication) DeliverTx(tx []byte) ResponseDeliverTx { + return ResponseDeliverTx{Code: CodeTypeOK} +} + +func (BaseApplication) CheckTx(tx []byte) ResponseCheckTx { + return ResponseCheckTx{Code: CodeTypeOK} +} + +func (BaseApplication) Commit() ResponseCommit { + return ResponseCommit{Code: CodeTypeOK} +} + +func (BaseApplication) Query(req RequestQuery) ResponseQuery { + return ResponseQuery{Code: CodeTypeOK} +} + +func (BaseApplication) InitChain(req RequestInitChain) ResponseInitChain { + return ResponseInitChain{} +} + +func (BaseApplication) BeginBlock(req RequestBeginBlock) ResponseBeginBlock { + return ResponseBeginBlock{} +} + +func (BaseApplication) EndBlock(req RequestEndBlock) ResponseEndBlock { + return ResponseEndBlock{} +} + +//------------------------------------------------------- + +var _ Application = (*GRPCApplication)(nil) // GRPCApplication is a GRPC wrapper for Application type GRPCApplication struct { diff --git a/types/base_app.go b/types/base_app.go deleted file mode 100644 index 1998e9dcb..000000000 --- a/types/base_app.go +++ /dev/null @@ -1,44 +0,0 @@ -package types - -type BaseApplication struct { -} - -func NewBaseApplication() *BaseApplication { - return &BaseApplication{} -} - -func (BaseApplication) Info(req RequestInfo) ResponseInfo { - return ResponseInfo{} -} - -func (BaseApplication) SetOption(req RequestSetOption) ResponseSetOption { - return ResponseSetOption{} -} - -func (BaseApplication) DeliverTx(tx []byte) ResponseDeliverTx { - return ResponseDeliverTx{Code: CodeTypeOK} -} - -func (BaseApplication) CheckTx(tx []byte) ResponseCheckTx { - return ResponseCheckTx{Code: CodeTypeOK} -} - -func (BaseApplication) Commit() ResponseCommit { - return ResponseCommit{Code: CodeTypeOK} -} - -func (BaseApplication) Query(req RequestQuery) ResponseQuery { - return ResponseQuery{Code: CodeTypeOK} -} - -func (BaseApplication) InitChain(req RequestInitChain) ResponseInitChain { - return ResponseInitChain{} -} - -func (BaseApplication) BeginBlock(req RequestBeginBlock) ResponseBeginBlock { - return ResponseBeginBlock{} -} - -func (BaseApplication) EndBlock(req RequestEndBlock) ResponseEndBlock { - return ResponseEndBlock{} -} diff --git a/types/kvpair.go b/types/kvpair.go deleted file mode 100644 index c7aad4407..000000000 --- a/types/kvpair.go +++ /dev/null @@ -1,19 +0,0 @@ -package types - -// KVPairInt is a helper method to build KV pair with an integer value. -func KVPairInt(key string, val int64) *KVPair { - return &KVPair{ - Key: key, - ValueInt: val, - ValueType: KVPair_INT, - } -} - -// KVPairString is a helper method to build KV pair with a string value. -func KVPairString(key, val string) *KVPair { - return &KVPair{ - Key: key, - ValueString: val, - ValueType: KVPair_STRING, - } -} diff --git a/types/validators.go b/types/util.go similarity index 60% rename from types/validators.go rename to types/util.go index 6bbe3f847..17c53f659 100644 --- a/types/validators.go +++ b/types/util.go @@ -8,6 +8,8 @@ import ( cmn "github.com/tendermint/tmlibs/common" ) +//------------------------------------------------------------------------------ + // Validators is a list of validators that implements the Sort interface type Validators []*Validator @@ -26,13 +28,6 @@ func (v Validators) Swap(i, j int) { v[j] = v1 } -//------------------------------------- - -type validatorPretty struct { - PubKey data.Bytes `json:"pub_key"` - Power int64 `json:"power"` -} - func ValidatorsString(vs Validators) string { s := make([]validatorPretty, len(vs)) for i, v := range vs { @@ -44,3 +39,28 @@ func ValidatorsString(vs Validators) string { } return string(b) } + +type validatorPretty struct { + PubKey data.Bytes `json:"pub_key"` + Power int64 `json:"power"` +} + +//------------------------------------------------------------------------------ + +// KVPairInt is a helper method to build KV pair with an integer value. +func KVPairInt(key string, val int64) *KVPair { + return &KVPair{ + Key: key, + ValueInt: val, + ValueType: KVPair_INT, + } +} + +// KVPairString is a helper method to build KV pair with a string value. +func KVPairString(key, val string) *KVPair { + return &KVPair{ + Key: key, + ValueString: val, + ValueType: KVPair_STRING, + } +} diff --git a/types/kvpair_test.go b/types/util_test.go similarity index 100% rename from types/kvpair_test.go rename to types/util_test.go