internal

package
v0.0.0-...-08b0609 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextStore

type ContextStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ContextStore keeps track of which stub belongs to which channel ID + transaction ID context

func NewContextStore

func NewContextStore() *ContextStore

NewContextStore returns a new store for keeping track of transaction context stubs

func (*ContextStore) Get

Get returns the specified stub from the context store

func (*ContextStore) Put

func (store *ContextStore) Put(channelID string, txID string, stub shim.ChaincodeStubInterface) error

Put stores the passed stub in the context store

func (*ContextStore) Remove

func (store *ContextStore) Remove(channelID string, txID string) error

Remove removes the specified stub from the context store

type FabricProxy

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

FabricProxy routes calls from Wasm contract to the correct Fabric stub

func NewFabricProxy

func NewFabricProxy(contextStore *ContextStore) *FabricProxy

NewFabricProxy returns a new proxy to handle calls to the Fabric contract API

func (*FabricProxy) FabricCall

func (proxy *FabricProxy) FabricCall(ctx context.Context, binding, namespace, operation string, payload []byte) (result []byte, err error)

FabricCall is the waPC HostCall function for interacting with the ledger

type WasmContract

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

WasmContract provides the Init and Invoke functions required by Fabric and represents a smart contract in Wasm.

func NewWasmContract

func NewWasmContract(contextStore *ContextStore, invoker WasmGuestInvoker) *WasmContract

NewWasmContract returns a new smart contract to invoke Wasm transactions

func (*WasmContract) Init

Init does nothing

func (*WasmContract) Invoke

func (wc *WasmContract) Invoke(APIstub shim.ChaincodeStubInterface) pb.Response

Invoke calls a Wasm transaction

type WasmGuest

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

WasmGuest encapsulates external dependencies required to invoke operations in Wasm guest code. Currently this uses a pool of waPC instances.

func NewWasmGuest

func NewWasmGuest(wasmFile string, proxy *FabricProxy) (*WasmGuest, error)

NewWasmGuest returns a new WasmGuest capable of invoking Wasm operations

func (*WasmGuest) Close

func (wg *WasmGuest) Close()

Close closes the WasmGuest, rendering it unusable for invoking further operations

func (*WasmGuest) InvokeWasmOperation

func (wg *WasmGuest) InvokeWasmOperation(operation string, payload []byte) (result []byte, err error)

InvokeWasmOperation invoke a Wasm guest operation

type WasmGuestInvoker

type WasmGuestInvoker interface {
	InvokeWasmOperation(operation string, payload []byte) ([]byte, error)
}

WasmGuestInvoker is the interface that wraps the InvokeWasmOperation method.

Jump to

Keyboard shortcuts

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