Change Handler interface
This commit is contained in:
parent
2f220701fe
commit
cb4277f4b7
40
handler.go
40
handler.go
|
@ -25,24 +25,24 @@ type Named interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Checker interface {
|
type Checker interface {
|
||||||
CheckTx(ctx Context, store state.SimpleDB, tx Tx) (Result, error)
|
CheckTx(ctx Context, store state.SimpleDB, tx Tx) (CheckResult, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckerFunc (like http.HandlerFunc) is a shortcut for making wrapers
|
// CheckerFunc (like http.HandlerFunc) is a shortcut for making wrapers
|
||||||
type CheckerFunc func(Context, state.SimpleDB, Tx) (Result, error)
|
type CheckerFunc func(Context, state.SimpleDB, Tx) (CheckResult, error)
|
||||||
|
|
||||||
func (c CheckerFunc) CheckTx(ctx Context, store state.SimpleDB, tx Tx) (Result, error) {
|
func (c CheckerFunc) CheckTx(ctx Context, store state.SimpleDB, tx Tx) (CheckResult, error) {
|
||||||
return c(ctx, store, tx)
|
return c(ctx, store, tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Deliver interface {
|
type Deliver interface {
|
||||||
DeliverTx(ctx Context, store state.SimpleDB, tx Tx) (Result, error)
|
DeliverTx(ctx Context, store state.SimpleDB, tx Tx) (DeliverResult, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeliverFunc (like http.HandlerFunc) is a shortcut for making wrapers
|
// DeliverFunc (like http.HandlerFunc) is a shortcut for making wrapers
|
||||||
type DeliverFunc func(Context, state.SimpleDB, Tx) (Result, error)
|
type DeliverFunc func(Context, state.SimpleDB, Tx) (DeliverResult, error)
|
||||||
|
|
||||||
func (c DeliverFunc) DeliverTx(ctx Context, store state.SimpleDB, tx Tx) (Result, error) {
|
func (c DeliverFunc) DeliverTx(ctx Context, store state.SimpleDB, tx Tx) (DeliverResult, error) {
|
||||||
return c(ctx, store, tx)
|
return c(ctx, store, tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,14 +57,32 @@ func (c SetOptionFunc) SetOption(l log.Logger, store state.SimpleDB, module, key
|
||||||
return c(l, store, module, key, value)
|
return c(l, store, module, key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result captures any non-error abci result
|
// CheckResult captures any non-error abci result
|
||||||
// to make sure people use error for error cases
|
// to make sure people use error for error cases
|
||||||
type Result struct {
|
type CheckResult struct {
|
||||||
Data data.Bytes
|
Data data.Bytes
|
||||||
Log string
|
Log string
|
||||||
|
GasAllocated uint
|
||||||
|
GasPrice uint
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Result) ToABCI() abci.Result {
|
func (r CheckResult) ToABCI() abci.Result {
|
||||||
|
return abci.Result{
|
||||||
|
Data: r.Data,
|
||||||
|
Log: r.Log,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeliverResult captures any non-error abci result
|
||||||
|
// to make sure people use error for error cases
|
||||||
|
type DeliverResult struct {
|
||||||
|
Data data.Bytes
|
||||||
|
Log string
|
||||||
|
Diff []*abci.Validator
|
||||||
|
GasUsed uint
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r DeliverResult) ToABCI() abci.Result {
|
||||||
return abci.Result{
|
return abci.Result{
|
||||||
Data: r.Data,
|
Data: r.Data,
|
||||||
Log: r.Log,
|
Log: r.Log,
|
||||||
|
@ -75,11 +93,11 @@ func (r Result) ToABCI() abci.Result {
|
||||||
// holders
|
// holders
|
||||||
type NopCheck struct{}
|
type NopCheck struct{}
|
||||||
|
|
||||||
func (_ NopCheck) CheckTx(Context, state.SimpleDB, Tx) (r Result, e error) { return }
|
func (_ NopCheck) CheckTx(Context, state.SimpleDB, Tx) (r CheckResult, e error) { return }
|
||||||
|
|
||||||
type NopDeliver struct{}
|
type NopDeliver struct{}
|
||||||
|
|
||||||
func (_ NopDeliver) DeliverTx(Context, state.SimpleDB, Tx) (r Result, e error) { return }
|
func (_ NopDeliver) DeliverTx(Context, state.SimpleDB, Tx) (r DeliverResult, e error) { return }
|
||||||
|
|
||||||
type NopOption struct{}
|
type NopOption struct{}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue