mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-22 09:21:32 +00:00
types: consolidate some file
This commit is contained in:
@ -25,7 +25,57 @@ type Application interface {
|
|||||||
Commit() ResponseCommit // Commit the state and return the application Merkle root hash
|
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
|
// GRPCApplication is a GRPC wrapper for Application
|
||||||
type GRPCApplication struct {
|
type GRPCApplication struct {
|
||||||
|
@ -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{}
|
|
||||||
}
|
|
@ -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,
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,6 +8,8 @@ import (
|
|||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Validators is a list of validators that implements the Sort interface
|
// Validators is a list of validators that implements the Sort interface
|
||||||
type Validators []*Validator
|
type Validators []*Validator
|
||||||
|
|
||||||
@ -26,13 +28,6 @@ func (v Validators) Swap(i, j int) {
|
|||||||
v[j] = v1
|
v[j] = v1
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------
|
|
||||||
|
|
||||||
type validatorPretty struct {
|
|
||||||
PubKey data.Bytes `json:"pub_key"`
|
|
||||||
Power int64 `json:"power"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func ValidatorsString(vs Validators) string {
|
func ValidatorsString(vs Validators) string {
|
||||||
s := make([]validatorPretty, len(vs))
|
s := make([]validatorPretty, len(vs))
|
||||||
for i, v := range vs {
|
for i, v := range vs {
|
||||||
@ -44,3 +39,28 @@ func ValidatorsString(vs Validators) string {
|
|||||||
}
|
}
|
||||||
return string(b)
|
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,
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user