Move kvstore from types to state
This commit is contained in:
+3
-3
@@ -3,8 +3,8 @@ package stack
|
||||
import (
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
"github.com/tendermint/basecoin/txs"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -22,7 +22,7 @@ func (_ Chain) Name() string {
|
||||
|
||||
var _ Middleware = Chain{}
|
||||
|
||||
func (c Chain) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Checker) (res basecoin.Result, err error) {
|
||||
func (c Chain) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Checker) (res basecoin.Result, err error) {
|
||||
stx, err := c.checkChain(ctx.ChainID(), tx)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -30,7 +30,7 @@ func (c Chain) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx
|
||||
return next.CheckTx(ctx, store, stx)
|
||||
}
|
||||
|
||||
func (c Chain) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.Result, err error) {
|
||||
func (c Chain) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.Result, err error) {
|
||||
stx, err := c.checkChain(ctx.ChainID(), tx)
|
||||
if err != nil {
|
||||
return res, err
|
||||
|
||||
+2
-2
@@ -9,8 +9,8 @@ import (
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
"github.com/tendermint/basecoin/txs"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
)
|
||||
|
||||
func TestChain(t *testing.T) {
|
||||
@@ -31,7 +31,7 @@ func TestChain(t *testing.T) {
|
||||
|
||||
// generic args here...
|
||||
ctx := NewContext(chainID, log.NewNopLogger())
|
||||
store := types.NewMemKVStore()
|
||||
store := state.NewMemKVStore()
|
||||
|
||||
// build the stack
|
||||
ok := OKHandler{Log: msg}
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
)
|
||||
|
||||
// store nonce as it's own type so no one can even try to fake it
|
||||
@@ -115,7 +115,7 @@ func withApp(ctx basecoin.Context, app string) basecoin.Context {
|
||||
}
|
||||
|
||||
func secureCheck(h basecoin.Checker, parent basecoin.Context) basecoin.Checker {
|
||||
next := func(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
next := func(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
if !parent.IsParent(ctx) {
|
||||
return res, errors.New("Passing in non-child Context")
|
||||
}
|
||||
@@ -125,7 +125,7 @@ func secureCheck(h basecoin.Checker, parent basecoin.Context) basecoin.Checker {
|
||||
}
|
||||
|
||||
func secureDeliver(h basecoin.Deliver, parent basecoin.Context) basecoin.Deliver {
|
||||
next := func(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
next := func(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
if !parent.IsParent(ctx) {
|
||||
return res, errors.New("Passing in non-child Context")
|
||||
}
|
||||
|
||||
+4
-4
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
)
|
||||
|
||||
// nolint
|
||||
@@ -64,7 +64,7 @@ func (d *Dispatcher) Name() string {
|
||||
// Tries to find a registered module (Dispatchable) based on the name of the tx.
|
||||
// The tx name (as registered with go-data) should be in the form `<module name>/XXXX`,
|
||||
// where `module name` must match the name of a dispatchable and XXX can be any string.
|
||||
func (d *Dispatcher) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
func (d *Dispatcher) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
r, err := d.lookupTx(tx)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -79,7 +79,7 @@ func (d *Dispatcher) CheckTx(ctx basecoin.Context, store types.KVStore, tx basec
|
||||
// Tries to find a registered module (Dispatchable) based on the name of the tx.
|
||||
// The tx name (as registered with go-data) should be in the form `<module name>/XXXX`,
|
||||
// where `module name` must match the name of a dispatchable and XXX can be any string.
|
||||
func (d *Dispatcher) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
func (d *Dispatcher) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
r, err := d.lookupTx(tx)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -93,7 +93,7 @@ func (d *Dispatcher) DeliverTx(ctx basecoin.Context, store types.KVStore, tx bas
|
||||
//
|
||||
// Tries to find a registered module (Dispatchable) based on the
|
||||
// module name from SetOption of the tx.
|
||||
func (d *Dispatcher) SetOption(l log.Logger, store types.KVStore, module, key, value string) (string, error) {
|
||||
func (d *Dispatcher) SetOption(l log.Logger, store state.KVStore, module, key, value string) (string, error) {
|
||||
r, err := d.lookupModule(module)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
+9
-9
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/tendermint/go-wire/data"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -29,12 +29,12 @@ func (_ OKHandler) Name() string {
|
||||
}
|
||||
|
||||
// CheckTx always returns an empty success tx
|
||||
func (ok OKHandler) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
func (ok OKHandler) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
return basecoin.Result{Log: ok.Log}, nil
|
||||
}
|
||||
|
||||
// DeliverTx always returns an empty success tx
|
||||
func (ok OKHandler) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
func (ok OKHandler) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
return basecoin.Result{Log: ok.Log}, nil
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@ func (_ EchoHandler) Name() string {
|
||||
}
|
||||
|
||||
// CheckTx always returns an empty success tx
|
||||
func (_ EchoHandler) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
func (_ EchoHandler) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
data, err := data.ToWire(tx)
|
||||
return basecoin.Result{Data: data}, err
|
||||
}
|
||||
|
||||
// DeliverTx always returns an empty success tx
|
||||
func (_ EchoHandler) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
func (_ EchoHandler) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
data, err := data.ToWire(tx)
|
||||
return basecoin.Result{Data: data}, err
|
||||
}
|
||||
@@ -74,12 +74,12 @@ func (_ FailHandler) Name() string {
|
||||
}
|
||||
|
||||
// CheckTx always returns the given error
|
||||
func (f FailHandler) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
func (f FailHandler) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
return res, errors.WithStack(f.Err)
|
||||
}
|
||||
|
||||
// DeliverTx always returns the given error
|
||||
func (f FailHandler) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
func (f FailHandler) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
return res, errors.WithStack(f.Err)
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ func (_ PanicHandler) Name() string {
|
||||
}
|
||||
|
||||
// CheckTx always panics
|
||||
func (p PanicHandler) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
func (p PanicHandler) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
if p.Err != nil {
|
||||
panic(p.Err)
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func (p PanicHandler) CheckTx(ctx basecoin.Context, store types.KVStore, tx base
|
||||
}
|
||||
|
||||
// DeliverTx always panics
|
||||
func (p PanicHandler) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
func (p PanicHandler) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
if p.Err != nil {
|
||||
panic(p.Err)
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ import (
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
)
|
||||
|
||||
func TestOK(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
ctx := NewContext("test-chain", log.NewNopLogger())
|
||||
store := types.NewMemKVStore()
|
||||
store := state.NewMemKVStore()
|
||||
data := "this looks okay"
|
||||
tx := basecoin.Tx{}
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestFail(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
ctx := NewContext("test-chain", log.NewNopLogger())
|
||||
store := types.NewMemKVStore()
|
||||
store := state.NewMemKVStore()
|
||||
msg := "big problem"
|
||||
tx := basecoin.Tx{}
|
||||
|
||||
@@ -54,7 +54,7 @@ func TestPanic(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
ctx := NewContext("test-chain", log.NewNopLogger())
|
||||
store := types.NewMemKVStore()
|
||||
store := state.NewMemKVStore()
|
||||
msg := "system crash!"
|
||||
tx := basecoin.Tx{}
|
||||
|
||||
|
||||
+5
-5
@@ -3,7 +3,7 @@ package stack
|
||||
import (
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -24,14 +24,14 @@ func (_ CheckMiddleware) Name() string {
|
||||
return NameCheck
|
||||
}
|
||||
|
||||
func (p CheckMiddleware) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Checker) (res basecoin.Result, err error) {
|
||||
func (p CheckMiddleware) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Checker) (res basecoin.Result, err error) {
|
||||
if !ctx.HasPermission(p.Required) {
|
||||
return res, errors.ErrUnauthorized()
|
||||
}
|
||||
return next.CheckTx(ctx, store, tx)
|
||||
}
|
||||
|
||||
func (p CheckMiddleware) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.Result, err error) {
|
||||
func (p CheckMiddleware) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.Result, err error) {
|
||||
if !ctx.HasPermission(p.Required) {
|
||||
return res, errors.ErrUnauthorized()
|
||||
}
|
||||
@@ -50,12 +50,12 @@ func (_ GrantMiddleware) Name() string {
|
||||
return NameGrant
|
||||
}
|
||||
|
||||
func (g GrantMiddleware) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Checker) (res basecoin.Result, err error) {
|
||||
func (g GrantMiddleware) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Checker) (res basecoin.Result, err error) {
|
||||
ctx = ctx.WithPermissions(g.Auth)
|
||||
return next.CheckTx(ctx, store, tx)
|
||||
}
|
||||
|
||||
func (g GrantMiddleware) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.Result, err error) {
|
||||
func (g GrantMiddleware) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.Result, err error) {
|
||||
ctx = ctx.WithPermissions(g.Auth)
|
||||
return next.DeliverTx(ctx, store, tx)
|
||||
}
|
||||
|
||||
+17
-17
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
)
|
||||
|
||||
// Middleware is anything that wraps another handler to enhance functionality.
|
||||
@@ -19,57 +19,57 @@ type Middleware interface {
|
||||
}
|
||||
|
||||
type CheckerMiddle interface {
|
||||
CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Checker) (basecoin.Result, error)
|
||||
CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Checker) (basecoin.Result, error)
|
||||
}
|
||||
|
||||
type CheckerMiddleFunc func(basecoin.Context, types.KVStore, basecoin.Tx, basecoin.Checker) (basecoin.Result, error)
|
||||
type CheckerMiddleFunc func(basecoin.Context, state.KVStore, basecoin.Tx, basecoin.Checker) (basecoin.Result, error)
|
||||
|
||||
func (c CheckerMiddleFunc) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Checker) (basecoin.Result, error) {
|
||||
func (c CheckerMiddleFunc) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Checker) (basecoin.Result, error) {
|
||||
return c(ctx, store, tx, next)
|
||||
}
|
||||
|
||||
type DeliverMiddle interface {
|
||||
DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Deliver) (basecoin.Result, error)
|
||||
DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Deliver) (basecoin.Result, error)
|
||||
}
|
||||
|
||||
type DeliverMiddleFunc func(basecoin.Context, types.KVStore, basecoin.Tx, basecoin.Deliver) (basecoin.Result, error)
|
||||
type DeliverMiddleFunc func(basecoin.Context, state.KVStore, basecoin.Tx, basecoin.Deliver) (basecoin.Result, error)
|
||||
|
||||
func (d DeliverMiddleFunc) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Deliver) (basecoin.Result, error) {
|
||||
func (d DeliverMiddleFunc) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Deliver) (basecoin.Result, error) {
|
||||
return d(ctx, store, tx, next)
|
||||
}
|
||||
|
||||
type SetOptionMiddle interface {
|
||||
SetOption(l log.Logger, store types.KVStore, module, key, value string, next basecoin.SetOptioner) (string, error)
|
||||
SetOption(l log.Logger, store state.KVStore, module, key, value string, next basecoin.SetOptioner) (string, error)
|
||||
}
|
||||
|
||||
type SetOptionMiddleFunc func(log.Logger, types.KVStore, string, string, string, basecoin.SetOptioner) (string, error)
|
||||
type SetOptionMiddleFunc func(log.Logger, state.KVStore, string, string, string, basecoin.SetOptioner) (string, error)
|
||||
|
||||
func (c SetOptionMiddleFunc) SetOption(l log.Logger, store types.KVStore, module, key, value string, next basecoin.SetOptioner) (string, error) {
|
||||
func (c SetOptionMiddleFunc) SetOption(l log.Logger, store state.KVStore, module, key, value string, next basecoin.SetOptioner) (string, error) {
|
||||
return c(l, store, module, key, value, next)
|
||||
}
|
||||
|
||||
// holders
|
||||
type PassCheck struct{}
|
||||
|
||||
func (_ PassCheck) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Checker) (basecoin.Result, error) {
|
||||
func (_ PassCheck) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Checker) (basecoin.Result, error) {
|
||||
return next.CheckTx(ctx, store, tx)
|
||||
}
|
||||
|
||||
type PassDeliver struct{}
|
||||
|
||||
func (_ PassDeliver) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Deliver) (basecoin.Result, error) {
|
||||
func (_ PassDeliver) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Deliver) (basecoin.Result, error) {
|
||||
return next.DeliverTx(ctx, store, tx)
|
||||
}
|
||||
|
||||
type PassOption struct{}
|
||||
|
||||
func (_ PassOption) SetOption(l log.Logger, store types.KVStore, module, key, value string, next basecoin.SetOptioner) (string, error) {
|
||||
func (_ PassOption) SetOption(l log.Logger, store state.KVStore, module, key, value string, next basecoin.SetOptioner) (string, error) {
|
||||
return next.SetOption(l, store, module, key, value)
|
||||
}
|
||||
|
||||
type NopOption struct{}
|
||||
|
||||
func (_ NopOption) SetOption(l log.Logger, store types.KVStore, module, key, value string, next basecoin.SetOptioner) (string, error) {
|
||||
func (_ NopOption) SetOption(l log.Logger, store state.KVStore, module, key, value string, next basecoin.SetOptioner) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
@@ -98,14 +98,14 @@ func (w wrapped) Name() string {
|
||||
return w.h.Name()
|
||||
}
|
||||
|
||||
func (w wrapped) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, _ basecoin.Checker) (basecoin.Result, error) {
|
||||
func (w wrapped) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, _ basecoin.Checker) (basecoin.Result, error) {
|
||||
return w.h.CheckTx(ctx, store, tx)
|
||||
}
|
||||
|
||||
func (w wrapped) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, _ basecoin.Deliver) (basecoin.Result, error) {
|
||||
func (w wrapped) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, _ basecoin.Deliver) (basecoin.Result, error) {
|
||||
return w.h.DeliverTx(ctx, store, tx)
|
||||
}
|
||||
|
||||
func (w wrapped) SetOption(l log.Logger, store types.KVStore, module, key, value string, _ basecoin.SetOptioner) (string, error) {
|
||||
func (w wrapped) SetOption(l log.Logger, store state.KVStore, module, key, value string, _ basecoin.SetOptioner) (string, error) {
|
||||
return w.h.SetOption(l, store, module, key, value)
|
||||
}
|
||||
|
||||
+4
-4
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -22,7 +22,7 @@ func (_ Logger) Name() string {
|
||||
|
||||
var _ Middleware = Logger{}
|
||||
|
||||
func (_ Logger) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Checker) (res basecoin.Result, err error) {
|
||||
func (_ Logger) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Checker) (res basecoin.Result, err error) {
|
||||
start := time.Now()
|
||||
res, err = next.CheckTx(ctx, store, tx)
|
||||
delta := time.Now().Sub(start)
|
||||
@@ -36,7 +36,7 @@ func (_ Logger) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.T
|
||||
return
|
||||
}
|
||||
|
||||
func (_ Logger) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.Result, err error) {
|
||||
func (_ Logger) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.Result, err error) {
|
||||
start := time.Now()
|
||||
res, err = next.DeliverTx(ctx, store, tx)
|
||||
delta := time.Now().Sub(start)
|
||||
@@ -50,7 +50,7 @@ func (_ Logger) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin
|
||||
return
|
||||
}
|
||||
|
||||
func (_ Logger) SetOption(l log.Logger, store types.KVStore, module, key, value string, next basecoin.SetOptioner) (string, error) {
|
||||
func (_ Logger) SetOption(l log.Logger, store state.KVStore, module, key, value string, next basecoin.SetOptioner) (string, error) {
|
||||
start := time.Now()
|
||||
res, err := next.SetOption(l, store, module, key, value)
|
||||
delta := time.Now().Sub(start)
|
||||
|
||||
+4
-4
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
)
|
||||
|
||||
// middleware lets us wrap a whole stack up into one Handler
|
||||
@@ -22,7 +22,7 @@ func (m *middleware) Name() string {
|
||||
}
|
||||
|
||||
// CheckTx always returns an empty success tx
|
||||
func (m *middleware) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (basecoin.Result, error) {
|
||||
func (m *middleware) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx) (basecoin.Result, error) {
|
||||
// make sure we pass in proper context to child
|
||||
next := secureCheck(m.next, ctx)
|
||||
// set the permissions for this app
|
||||
@@ -31,7 +31,7 @@ func (m *middleware) CheckTx(ctx basecoin.Context, store types.KVStore, tx basec
|
||||
}
|
||||
|
||||
// DeliverTx always returns an empty success tx
|
||||
func (m *middleware) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
func (m *middleware) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx) (res basecoin.Result, err error) {
|
||||
// make sure we pass in proper context to child
|
||||
next := secureDeliver(m.next, ctx)
|
||||
// set the permissions for this app
|
||||
@@ -39,7 +39,7 @@ func (m *middleware) DeliverTx(ctx basecoin.Context, store types.KVStore, tx bas
|
||||
return m.middleware.DeliverTx(ctx, store, tx, next)
|
||||
}
|
||||
|
||||
func (m *middleware) SetOption(l log.Logger, store types.KVStore, module, key, value string) (string, error) {
|
||||
func (m *middleware) SetOption(l log.Logger, store state.KVStore, module, key, value string) (string, error) {
|
||||
return m.middleware.SetOption(l, store, module, key, value, m.next)
|
||||
}
|
||||
|
||||
|
||||
@@ -5,12 +5,14 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/txs"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
|
||||
"github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
"github.com/tendermint/basecoin/txs"
|
||||
)
|
||||
|
||||
func TestPermissionSandbox(t *testing.T) {
|
||||
@@ -18,7 +20,7 @@ func TestPermissionSandbox(t *testing.T) {
|
||||
|
||||
// generic args
|
||||
ctx := NewContext("test-chain", log.NewNopLogger())
|
||||
store := types.NewMemKVStore()
|
||||
store := state.NewMemKVStore()
|
||||
raw := txs.NewRaw([]byte{1, 2, 3, 4})
|
||||
rawBytes, err := data.ToWire(raw)
|
||||
require.Nil(err)
|
||||
|
||||
@@ -3,11 +3,12 @@ package stack
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/txs"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
"github.com/tendermint/basecoin/txs"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -24,21 +25,21 @@ func (_ Multiplexer) Name() string {
|
||||
|
||||
var _ Middleware = Multiplexer{}
|
||||
|
||||
func (_ Multiplexer) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Checker) (res basecoin.Result, err error) {
|
||||
func (_ Multiplexer) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Checker) (res basecoin.Result, err error) {
|
||||
if mtx, ok := tx.Unwrap().(*txs.MultiTx); ok {
|
||||
return runAll(ctx, store, mtx.Txs, next.CheckTx)
|
||||
}
|
||||
return next.CheckTx(ctx, store, tx)
|
||||
}
|
||||
|
||||
func (_ Multiplexer) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.Result, err error) {
|
||||
func (_ Multiplexer) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.Result, err error) {
|
||||
if mtx, ok := tx.Unwrap().(*txs.MultiTx); ok {
|
||||
return runAll(ctx, store, mtx.Txs, next.DeliverTx)
|
||||
}
|
||||
return next.DeliverTx(ctx, store, tx)
|
||||
}
|
||||
|
||||
func runAll(ctx basecoin.Context, store types.KVStore, txs []basecoin.Tx, next basecoin.CheckerFunc) (res basecoin.Result, err error) {
|
||||
func runAll(ctx basecoin.Context, store state.KVStore, txs []basecoin.Tx, next basecoin.CheckerFunc) (res basecoin.Result, err error) {
|
||||
// store all results, unless anything errors
|
||||
rs := make([]basecoin.Result, len(txs))
|
||||
for i, stx := range txs {
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -23,7 +23,7 @@ func (_ Recovery) Name() string {
|
||||
|
||||
var _ Middleware = Recovery{}
|
||||
|
||||
func (_ Recovery) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Checker) (res basecoin.Result, err error) {
|
||||
func (_ Recovery) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Checker) (res basecoin.Result, err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
err = normalizePanic(r)
|
||||
@@ -32,7 +32,7 @@ func (_ Recovery) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin
|
||||
return next.CheckTx(ctx, store, tx)
|
||||
}
|
||||
|
||||
func (_ Recovery) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.Result, err error) {
|
||||
func (_ Recovery) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.Result, err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
err = normalizePanic(r)
|
||||
@@ -41,7 +41,7 @@ func (_ Recovery) DeliverTx(ctx basecoin.Context, store types.KVStore, tx baseco
|
||||
return next.DeliverTx(ctx, store, tx)
|
||||
}
|
||||
|
||||
func (_ Recovery) SetOption(l log.Logger, store types.KVStore, module, key, value string, next basecoin.SetOptioner) (log string, err error) {
|
||||
func (_ Recovery) SetOption(l log.Logger, store state.KVStore, module, key, value string, next basecoin.SetOptioner) (log string, err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
err = normalizePanic(r)
|
||||
|
||||
@@ -6,9 +6,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
)
|
||||
|
||||
func TestRecovery(t *testing.T) {
|
||||
@@ -16,7 +18,7 @@ func TestRecovery(t *testing.T) {
|
||||
|
||||
// generic args here...
|
||||
ctx := NewContext("test-chain", log.NewNopLogger())
|
||||
store := types.NewMemKVStore()
|
||||
store := state.NewMemKVStore()
|
||||
tx := basecoin.Tx{}
|
||||
|
||||
cases := []struct {
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
)
|
||||
|
||||
// app name for auth
|
||||
@@ -33,7 +33,7 @@ type Signed interface {
|
||||
Signers() ([]crypto.PubKey, error)
|
||||
}
|
||||
|
||||
func (h Signatures) CheckTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Checker) (res basecoin.Result, err error) {
|
||||
func (h Signatures) CheckTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Checker) (res basecoin.Result, err error) {
|
||||
sigs, tnext, err := getSigners(tx)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -42,7 +42,7 @@ func (h Signatures) CheckTx(ctx basecoin.Context, store types.KVStore, tx baseco
|
||||
return next.CheckTx(ctx2, store, tnext)
|
||||
}
|
||||
|
||||
func (h Signatures) DeliverTx(ctx basecoin.Context, store types.KVStore, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.Result, err error) {
|
||||
func (h Signatures) DeliverTx(ctx basecoin.Context, store state.KVStore, tx basecoin.Tx, next basecoin.Deliver) (res basecoin.Result, err error) {
|
||||
sigs, tnext, err := getSigners(tx)
|
||||
if err != nil {
|
||||
return res, err
|
||||
|
||||
@@ -5,12 +5,13 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
crypto "github.com/tendermint/go-crypto"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/basecoin/state"
|
||||
"github.com/tendermint/basecoin/txs"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
)
|
||||
|
||||
func TestSignatureChecks(t *testing.T) {
|
||||
@@ -18,7 +19,7 @@ func TestSignatureChecks(t *testing.T) {
|
||||
|
||||
// generic args
|
||||
ctx := NewContext("test-chain", log.NewNopLogger())
|
||||
store := types.NewMemKVStore()
|
||||
store := state.NewMemKVStore()
|
||||
raw := txs.NewRaw([]byte{1, 2, 3, 4})
|
||||
|
||||
// let's make some keys....
|
||||
|
||||
Reference in New Issue
Block a user