common

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNamespaceFromSubName

func GetNamespaceFromSubName(subName string) string

func HandleReceipt added in v1.1.3

func HandleReceipt(ctx context.Context, plugin core.Named, reply *BlockchainReceiptNotification, callbacks BlockchainCallbacks) error

Common function for handling receipts from blockchain connectors.

func WrapRESTError added in v1.3.0

func WrapRESTError(ctx context.Context, errRes *BlockchainRESTError, res *resty.Response, err error, defMsgKey i18n.ErrorMessageKey) error

Types

type BatchPinParams

type BatchPinParams struct {
	UUIDs      string
	BatchHash  string
	Contexts   []string
	PayloadRef string
	NsOrAction string
}

type BlockchainCallbacks

type BlockchainCallbacks interface {
	SetHandler(namespace string, handler blockchain.Callbacks)
	SetOperationalHandler(namespace string, handler core.OperationCallbacks)

	OperationUpdate(ctx context.Context, plugin core.Named, nsOpID string, status core.OpStatus, blockchainTXID, errorMessage string, opOutput fftypes.JSONObject)
	// Common logic for parsing a BatchPinOrNetworkAction event, and if not discarded to add it to the by-namespace map
	PrepareBatchPinOrNetworkAction(ctx context.Context, events EventsToDispatch, subInfo *SubscriptionInfo, location *fftypes.JSONAny, event *blockchain.Event, signingKey *core.VerifierRef, params *BatchPinParams)
	// Common logic for parsing a BatchPinOrNetworkAction event, and if not discarded to add it to the by-namespace map
	PrepareBlockchainEvent(ctx context.Context, events EventsToDispatch, namespace string, event *blockchain.EventForListener)
	// Dispatch logic, that ensures all the right namespace callbacks get called for the event batch
	DispatchBlockchainEvents(ctx context.Context, events EventsToDispatch) error
}

func NewBlockchainCallbacks

func NewBlockchainCallbacks() BlockchainCallbacks

type BlockchainRESTError added in v1.3.0

type BlockchainRESTError struct {
	Error string `json:"error,omitempty"`
	// See https://github.com/hyperledger/firefly-transaction-manager/blob/main/pkg/ffcapi/submission_error.go
	SubmissionRejected bool `json:"submissionRejected,omitempty"`
}

type BlockchainReceiptHeaders added in v1.1.3

type BlockchainReceiptHeaders struct {
	ReceiptID string `json:"requestId,omitempty"`
	ReplyType string `json:"type,omitempty"`
}

type BlockchainReceiptNotification added in v1.1.3

type BlockchainReceiptNotification struct {
	Headers          BlockchainReceiptHeaders `json:"headers,omitempty"`
	TxHash           string                   `json:"transactionHash,omitempty"`
	Message          string                   `json:"errorMessage,omitempty"`
	ProtocolID       string                   `json:"protocolId,omitempty"`
	ContractLocation *fftypes.JSONAny         `json:"contractLocation,omitempty"`
}

type EventsToDispatch added in v1.3.0

type EventsToDispatch map[string][]*blockchain.EventToDispatch

EventsToDispatch is a by-namespace map of ordered blockchain events. Note there are some old listeners that do not have a namespace on them, and hence are stored under the empty string, and dispatched to all namespaces.

type FireflySubscriptions

type FireflySubscriptions interface {
	AddSubscription(ctx context.Context, namespace *core.Namespace, version int, subID string, extra interface{})
	RemoveSubscription(ctx context.Context, subID string)
	GetSubscription(subID string) *SubscriptionInfo
}

func NewFireflySubscriptions

func NewFireflySubscriptions() FireflySubscriptions

type SubscriptionInfo

type SubscriptionInfo struct {
	Version     int
	V1Namespace map[string][]string
	V2Namespace string
	Extra       interface{}
}

A single subscription on network version 1 may receive events from many remote namespaces, which in turn map to one or more local namespaces. A subscription on network version 2 is always specific to a single local namespace.

Jump to

Keyboard shortcuts

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