vm

package
v0.0.0-...-837776e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ReceiveMessageMethod = "agvm.ReceiveMessage"

ReceiveMessageMethod is the name of the method we call in order to have the VM receive a Message.

Variables

This section is empty.

Functions

func ProtoJSONMarshal

func ProtoJSONMarshal(val interface{}) ([]byte, error)

func ProtoJSONMarshalSlice

func ProtoJSONMarshalSlice(vals []interface{}) ([]byte, error)

ProtoJSONMarshalSlice marshals a slice of proto messages and non-proto values to a single JSON byte slice.

func SetActionHeaderFromContext

func SetActionHeaderFromContext(ctx sdk.Context, actionType string, ah *ActionHeader)

SetActionHeaderFromContext provides defaults to an ActionHeader.

Types

type Action

type Action interface {
	GetActionHeader() *ActionHeader
}

func PopulateAction

func PopulateAction(ctx sdk.Context, action Action) Action

PopulateAction returns a clone of action in which empty/zero-valued fields in its embedded ActionHeader have been populated using the corresponding `actionType:"..."` tag and the provided ctx, and its own empty/zero-valued fields have been populated as specified by their `default:"..."` tags.

type ActionHeader

type ActionHeader struct {
	// Type defaults to the `actionType:"..."` tag of the embedder's ActionHeader field.
	Type string `json:"type,omitempty"`
	// BlockHeight defaults to sdk.Context.BlockHeight().
	BlockHeight int64 `json:"blockHeight,omitempty"`
	// BlockTime defaults to sdk.Context.BlockTime().Unix().
	BlockTime int64 `json:"blockTime,omitempty"`
}

ActionHeader should be embedded in all actions. It is populated by PopulateAction.

func (*ActionHeader) GetActionHeader

func (ah *ActionHeader) GetActionHeader() *ActionHeader

type ActionPusher

type ActionPusher func(ctx sdk.Context, action Action) error

ActionPusher enqueues data for later consumption by the controller.

type AgdServer

type AgdServer struct {
	// contains filtered or unexported fields
}

AgdServer manages communication from the VM to the ABCI app. The structure is mutable and the mutex must be held to read or write any field.

func NewAgdServer

func NewAgdServer() *AgdServer

NewAgdServer returns a pointer to a new AgdServer with empty context and port mappings.

func (*AgdServer) GetPort

func (s *AgdServer) GetPort(name string) int

GetPort returns the port number for the given port name, or 0 if the name is not registered.

func (*AgdServer) MustRegisterPortHandler

func (s *AgdServer) MustRegisterPortHandler(name string, portHandler PortHandler) int

MustRegisterPortHandler attempts to RegisterPortHandler, panicing on error.

func (*AgdServer) ReceiveMessage

func (s *AgdServer) ReceiveMessage(msg *Message, reply *string) error

ReceiveMessage is the method the VM calls in order to have agd receive a Message.

func (*AgdServer) RegisterPortHandler

func (s *AgdServer) RegisterPortHandler(name string, portHandler PortHandler) (int, error)

RegisterPortHandler registers the handler to a new port number, then maps the name to it, returning the port number. If the name was previously in use, an error is returned.

func (*AgdServer) SetControllerContext

func (s *AgdServer) SetControllerContext(ctx sdk.Context) func()

SetControllerContext sets the context to the given argument and returns a function which will reset the context to an empty context (not the old context).

func (*AgdServer) UnregisterPortHandler

func (s *AgdServer) UnregisterPortHandler(portNum int) error

UnregisterPortHandler unregisters the handler and name mappings for this port number, and the reverse mapping for its name, if any of these exist. If portNum is not registered, return an error.

type ArbitraryCoreProposal

type ArbitraryCoreProposal struct {
	Json json.RawMessage
}

func NewArbitraryCoreProposal

func NewArbitraryCoreProposal(jsonStr string) *ArbitraryCoreProposal

type ClientCodec

type ClientCodec struct {
	// contains filtered or unexported fields
}

ClientCodec implements a net/rpc ClientCodec for the "bridge" between the Go runtime and the VM in the single-process dual-runtime configuration.

We expect to call it via the legacy API with signature:

sendToController func(needsReply bool, msg string) (string, error)

where msg and the returned string are JSON-encoded values.

Note that the net/rpc framework cannot express a call that does not expect a response, so we'll note such calls by sending with a reply port of 0 and having the WriteRequest() method fabricate a Receive() call to clear the rpc state.

func NewClientCodec

func NewClientCodec(ctx context.Context, send func(int, int, string)) *ClientCodec

NewClientCodec creates a new ClientCodec.

func (*ClientCodec) Close

func (cc *ClientCodec) Close() error

func (*ClientCodec) ReadResponseBody

func (cc *ClientCodec) ReadResponseBody(body interface{}) error

ReadResponseBody decodes a response body (currently just string) from the VM.

func (*ClientCodec) ReadResponseHeader

func (cc *ClientCodec) ReadResponseHeader(r *rpc.Response) error

ReadResponseHeader decodes a response header from the VM.

func (*ClientCodec) Receive

func (cc *ClientCodec) Receive(rPort int, isError bool, data string) error

Receive is called by the VM to send a response to the client.

func (*ClientCodec) WriteRequest

func (cc *ClientCodec) WriteRequest(r *rpc.Request, body interface{}) error

WriteRequest sends a request to the VM.

type ControllerAdmissionMsg

type ControllerAdmissionMsg interface {
	sdk.Msg
	CheckAdmissibility(sdk.Context, interface{}) error

	// GetInboundMsgCount returns the number of Swingset messages which will
	// be added to the inboundQueue.
	GetInboundMsgCount() int32

	// IsHighPriority returns whether the message should be considered for
	// high priority processing, including bypass of some inbound checks
	// and queueing on higher priority queues.
	IsHighPriority(sdk.Context, interface{}) (bool, error)
}

type CoreProposalStep

type CoreProposalStep []Jsonable

CoreProposalStep is a set of core proposal configs which are executed concurrently

func CoreProposalStepForModules

func CoreProposalStepForModules(modules ...Jsonable) CoreProposalStep

CoreProposalStepForModules generates a single core proposal step from the given modules, which will be executed concurrently during that step

type CoreProposals

type CoreProposals struct {
	Steps []CoreProposalStep `json:"steps"`
}

CoreProposals is one possible shape for core proposals expressed as a series of sequential steps see SequentialCoreProposals in packages/deploy-script-support/src/extract-proposal.js

func CoreProposalsFromSteps

func CoreProposalsFromSteps(steps ...CoreProposalStep) *CoreProposals

CoreProposalsFromSteps returns a CoreProposals from the given steps

type Jsonable

type Jsonable interface{}

Jsonable is a value, j, that can be passed through json.Marshal(j).

type Message

type Message struct {
	Port       int
	Data       string
	NeedsReply bool
}

Message is what we send to the VM.

type PortHandler

type PortHandler interface {
	Receive(context.Context, string) (string, error)
}

func NewProtectedPortHandler

func NewProtectedPortHandler(inner PortHandler) PortHandler

type Sender

type Sender func(ctx context.Context, needReply bool, jsonRequest string) (jsonReply string, err error)

Sender makes a request of our associated VM.

Directories

Path Synopsis
Package jsonrpcconn provides a way to multiplex an io stream into two streams where incoming JSON-RPC requests go to one stream and incoming JSON-RPC responses go to another.
Package jsonrpcconn provides a way to multiplex an io stream into two streams where incoming JSON-RPC requests go to one stream and incoming JSON-RPC responses go to another.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL