Browse Source

types: consolidate some file

pull/1780/head
Ethan Buchman 7 years ago
parent
commit
3d3d1288d1
5 changed files with 78 additions and 71 deletions
  1. +51
    -1
      types/application.go
  2. +0
    -44
      types/base_app.go
  3. +0
    -19
      types/kvpair.go
  4. +27
    -7
      types/util.go
  5. +0
    -0
      types/util_test.go

+ 51
- 1
types/application.go View File

@ -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 {


+ 0
- 44
types/base_app.go View File

@ -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{}
}

+ 0
- 19
types/kvpair.go View File

@ -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,
}
}

types/validators.go → types/util.go View File


types/kvpair_test.go → types/util_test.go View File


Loading…
Cancel
Save