substratepluginshare

package
v0.0.0-...-351d00c Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2020 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithTransactionID

func ContextWithTransactionID(ctx context.Context) context.Context

ContextWithTransactionID adds a unique value to a context for storing a transaction ID

func GetContextTransactionID

func GetContextTransactionID(ctx context.Context) string

GetContextTransactionID gets the transaction ID from a context value if present

func SetContextTransactionID

func SetContextTransactionID(ctx context.Context, txID string)

SetContextTransactionID sets the transaction ID in a context value that has been initialized using ContextWithTransactionID

Types

type Block

type Block interface {
	Hash() string
	Transactions() []Transaction
}

Block is a wrapper for summary information about a block.

type Config

type Config func(*RequestOptions)

Config is a type for a function that can mutate a requestOptions object.

func WithAuthToken

func WithAuthToken(token string) Config

WithAuthToken passes authorization for the transaction issuer with a request

func WithCCFetchURLDowngrade

func WithCCFetchURLDowngrade(downgrade bool) Config

WithCCFetchURLDowngrade allows controlling https -> http downgrade, typically useful before proxying for ccfetchurl library.

func WithCCFetchURLProxy

func WithCCFetchURLProxy(proxy string) Config

WithCCFetchURLProxy sets the proxy for ccfetchurl library.

func WithConditionalDependentTxID

func WithConditionalDependentTxID(txID string) Config

WithConditionalDependentTxID allows specifying a conditional dependency on a transaction ID when polling is disabled or transaction dependencies are already enabled. This is intended for use with chained sequential calls that have a critical dependency.

func WithContext

func WithContext(ctx context.Context) Config

WithContext allows specifying the context to use.

func WithCreator

func WithCreator(creator string) Config

WithCreator allows specifying the creator. Only has effect in mock mode. Also works in gateway mock mode.

func WithDependentTxID

func WithDependentTxID(txID string) Config

WithDependentTxID allows specifying a dependency on a transaction ID. If set, the client will poll for the presence of that transaction before simulating the request on the peer with the transaction.

func WithDisableWritePolling

func WithDisableWritePolling(disable bool) Config

WithDisableWritePolling allows disabling polling for full consensus after a write is committed.

func WithEndpoint

func WithEndpoint(endpoint string) Config

WithEndpoint allows specifying the endpoint to target. The RPC implementation will not work if an endpoint is not specified.

func WithHeader

func WithHeader(key string, value string) Config

WithHeader allows specifying an additional HTTP header.

func WithID

func WithID(id string) Config

WithID allows specifying the request ID. If the request ID is not specified, a randomly-generated UUID will be used.

func WithLog

func WithLog(log *logrus.Logger) Config

WithLog allows specifying the logger to use.

func WithLogField

func WithLogField(key string, value interface{}) Config

WithLogField allows specifying a log field to be included.

func WithLogrusFields

func WithLogrusFields(fields logrus.Fields) Config

WithLogrusFields allows specifying multiple log fields to be included.

func WithMSPFilter

func WithMSPFilter(mspFilter []string) Config

WithMSPFilter allows specifying the MSP filter. Has no effect in mock mode.

func WithMinEndorsers

func WithMinEndorsers(minEndorsers int) Config

WithMinEndorsers allows specifying the minimum number of endorsing peers. Has no effect in mock mode.

func WithParams

func WithParams(params interface{}) Config

WithParams allows specifying the phylum "parameters" argument. This must be set to something that json.Marshal accepts.

func WithResponse

func WithResponse(target *interface{}) Config

WithResponse allows capturing the RPC response for futher analysis.

func WithTimestampGenerator

func WithTimestampGenerator(timestampGenerator func(context.Context) string) Config

WithTimestampGenerator allows specifying a function that will be invoked at every Upgrade, Init, and Call whose output is used to set the substrate "now" timestamp in mock mode. Has no effect outside of mock mode.

func WithTransientData

func WithTransientData(key string, val []byte) Config

WithTransientData allows specifying a single "transient data" key-value pair.

func WithTransientDataMap

func WithTransientDataMap(data map[string][]byte) Config

WithTransientDataMap allows specifying multiple "transient data" key-value pairs.

type Handle

type Handle struct {
	Index int
}

Handle represents a handle to a shiroclient instance.

type RequestOptions

type RequestOptions struct {
	Log                 *logrus.Logger
	LogFields           logrus.Fields
	Headers             map[string]string
	Endpoint            string
	ID                  string
	AuthToken           string
	Params              interface{}
	Transient           map[string][]byte
	Target              *interface{}
	TimestampGenerator  func(context.Context) string
	MSPFilter           []string
	MinEndorsers        int
	Creator             string
	Ctx                 context.Context
	DependentTxID       string
	DisableWritePolling bool
	CCFetchURLDowngrade bool
	CCFetchURLProxy     string
}

RequestOptions are operated on by the Config functions generated by the With* functions. There is no need for a consumer of this library to directly manipulate objects of this type, but this type and its fields are public to allow substrateplugin to convert them to shiroclient options.

type Response

type Response struct {
	ResultJSON    []byte
	HasError      bool
	ErrorCode     int
	ErrorMessage  string
	ErrorJSON     []byte
	TransactionID string
}

Response represents a shiroclient response.

func (*Response) UnmarshalTo

func (s *Response) UnmarshalTo(dst interface{}) error

UnmarshalTo allows unmarshalling a Response to an interface{}.

type Transaction

type Transaction interface {
	ID() string
	Reason() string
	Event() []byte
	ChaincodeID() string
}

Transaction is a wrapper for summary information about a transaction.

Jump to

Keyboard shortcuts

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