Plugins and AccountCaches
This commit is contained in:
+7
-1
@@ -40,5 +40,11 @@ type AccountGetter interface {
|
||||
|
||||
type AccountGetterSetter interface {
|
||||
GetAccount(addr []byte) *Account
|
||||
SetAccount(acc *Account)
|
||||
SetAccount(addr []byte, acc *Account)
|
||||
}
|
||||
|
||||
type AccountCacher interface {
|
||||
GetAccount(addr []byte) *Account
|
||||
SetAccount(addr []byte, acc *Account)
|
||||
Sync()
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
package types
|
||||
|
||||
type Plugin func(ags AccountGetterSetter,
|
||||
caller *Account,
|
||||
input []byte,
|
||||
gas *int64) (result []byte, err error)
|
||||
@@ -0,0 +1,28 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
tmsp "github.com/tendermint/tmsp/types"
|
||||
)
|
||||
|
||||
// Value is any floating value. It must be given to someone.
|
||||
// Gas is a pointer to remainig gas. Decrement as you go,
|
||||
// if any gas is left the user is
|
||||
type Plugin interface {
|
||||
CallTx(ctx CallContext, txBytes []byte) tmsp.Result
|
||||
}
|
||||
|
||||
type CallContext struct {
|
||||
Cache AccountCacher
|
||||
Caller *Account
|
||||
Value int64
|
||||
Gas *int64
|
||||
}
|
||||
|
||||
func NewCallContext(cache AccountCacher, caller *Account, value int64, gas *int64) CallContext {
|
||||
return CallContext{
|
||||
Cache: cache,
|
||||
Caller: caller,
|
||||
Value: value,
|
||||
Gas: gas,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user