common

package
v1.3.3-rc.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2025 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, namespace string, 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)

	// BulkOperationUpdates is a synchronous way to update multiple operations and will return when the updates have been committed to the database or there has been an error
	// An insertion ordering guarantee is only provided when this code is called on a single goroutine inside of the connector.
	// It is the responsibility of the connector code to allocate that routine, and ensure that there is only one.
	// Note: onComplete at each update level is not called, as this is a bulk operation and should be reponsibility of the caller to manage if needed.
	BulkOperationUpdates(ctx context.Context, namespace string, updates []*core.OperationUpdate) error

	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