Documentation
¶
Index ¶
- Constants
- Variables
- type JSONError
- type Jail
- func (jail *Jail) BaseJS(js string)
- func (jail *Jail) Call(chatID string, path string, args string) string
- func (jail *Jail) JailCellVM(chatID string) (*otto.Otto, error)
- func (jail *Jail) NewJailCell(id string) common.JailCell
- func (jail *Jail) Parse(chatID string, js string) string
- func (jail *Jail) Send(chatID string, call otto.FunctionCall) (response otto.Value)
- type JailCell
- type LocalStorageSetEvent
- type RPCCall
- type RequestManager
- func (m *RequestManager) PostProcessRequest(vm *otto.Otto, req RPCCall, messageID string)
- func (m *RequestManager) PreProcessRequest(vm *otto.Otto, req RPCCall) (string, error)
- func (m *RequestManager) ProcessSendTransactionRequest(vm *otto.Otto, req RPCCall) (gethcommon.Hash, error)
- func (m *RequestManager) RPCClient() (*rpc.Client, error)
Constants ¶
const ( // EventLocalStorageSet is triggered when set request is sent to local storage EventLocalStorageSet = "local_storage.set" // LocalStorageMaxDataLen is maximum length of data that you can store in local storage LocalStorageMaxDataLen = 256 )
const (
// JailCellRequestTimeout seconds before jailed request times out
JailCellRequestTimeout = 60
)
const (
// SendTransactionRequest is triggered on send transaction request
SendTransactionRequest = "eth_sendTransaction"
)
Variables ¶
var (
ErrInvalidJail = errors.New("jail environment is not properly initialized")
)
errors
Functions ¶
This section is empty.
Types ¶
type JSONError ¶
type JSONError struct {
Error string `json:"error"`
}
JSONError is wrapper around errors, that are sent upwards
type Jail ¶
Jail represents jailed environment inside of which we hold multiple cells. Each cell is a separate JavaScript VM.
func (*Jail) Call ¶
Call executes given JavaScript function w/i a jail cell context identified by the chatID. Jail cell is clonned before call is executed i.e. all calls execute w/i their own contexts.
func (*Jail) JailCellVM ¶
JailCellVM returns instance of Otto VM (which is persisted w/i jail cell) by chatID
func (*Jail) NewJailCell ¶
NewJailCell initializes and returns jail cell
type JailCell ¶
type JailCell struct {
// contains filtered or unexported fields
}
JailCell represents single jail cell, which is basically a JavaScript VM.
type LocalStorageSetEvent ¶
LocalStorageSetEvent is a signal sent whenever local storage Set method is called
type RequestManager ¶
type RequestManager struct {
// contains filtered or unexported fields
}
RequestManager represents interface to manage jailed requests. Whenever some request passed to a Jail, needs to be pre/post processed, request manager is the right place for that.
func NewRequestManager ¶
func NewRequestManager(nodeManager common.NodeManager) *RequestManager
func (*RequestManager) PostProcessRequest ¶
func (m *RequestManager) PostProcessRequest(vm *otto.Otto, req RPCCall, messageID string)
PostProcessRequest post-processes a given RPC call to a given Otto VM
func (*RequestManager) PreProcessRequest ¶
PreProcessRequest pre-processes a given RPC call to a given Otto VM
func (*RequestManager) ProcessSendTransactionRequest ¶
func (m *RequestManager) ProcessSendTransactionRequest(vm *otto.Otto, req RPCCall) (gethcommon.Hash, error)
ProcessSendTransactionRequest processes send transaction request. Both pre and post processing happens within this function. Pre-processing happens before transaction is send to backend, and post processing occurs when backend notifies that transaction sending is complete (either successfully or with error)