types: consolidate some file

This commit is contained in:
Ethan Buchman 2017-12-01 00:51:20 -05:00
parent b39e768a1a
commit 3d3d1288d1
5 changed files with 78 additions and 71 deletions

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 {

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

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

View File

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