-
Notifications
You must be signed in to change notification settings - Fork 2
/
callable.go
37 lines (30 loc) · 878 Bytes
/
callable.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package engine
import (
"math/big"
"time"
"github.com/klyed/hivesmartchain/crypto"
"github.com/klyed/hivesmartchain/execution/exec"
)
type Blockchain interface {
LastBlockHeight() uint64
LastBlockTime() time.Time
BlockHash(height uint64) ([]byte, error)
ChainID() string
}
type CallParams struct {
CallType exec.CallType
Origin crypto.Address
Caller crypto.Address
Callee crypto.Address
Input []byte
Value big.Int
Gas *big.Int
}
// Effectively a contract, but can either represent a single function or a contract with multiple functions and a selector
type Callable interface {
Call(state State, params CallParams) (output []byte, err error)
}
type CallableFunc func(st State, params CallParams) (output []byte, err error)
func (c CallableFunc) Call(state State, params CallParams) (output []byte, err error) {
return c(state, params)
}