state_stream

package
v0.37.12 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: AGPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// CoreEventAccountCreated is emitted when a new account gets created
	CoreEventAccountCreated = "flow.AccountCreated"

	// CoreEventAccountKeyAdded is emitted when a key gets added to an account
	CoreEventAccountKeyAdded = "flow.AccountKeyAdded"

	// CoreEventAccountKeyRemoved is emitted when a key gets removed from an account
	CoreEventAccountKeyRemoved = "flow.AccountKeyRemoved"

	// CoreEventAccountContractAdded is emitted when a contract gets deployed to an account
	CoreEventAccountContractAdded = "flow.AccountContractAdded"

	// CoreEventAccountContractUpdated is emitted when a contract gets updated on an account
	CoreEventAccountContractUpdated = "flow.AccountContractUpdated"

	// CoreEventAccountContractRemoved is emitted when a contract gets removed from an account
	CoreEventAccountContractRemoved = "flow.AccountContractRemoved"

	// CoreEventInboxValuePublished is emitted when a Capability is published from an account
	CoreEventInboxValuePublished = "flow.InboxValuePublished"

	// CoreEventInboxValueUnpublished is emitted when a Capability is unpublished from an account
	CoreEventInboxValueUnpublished = "flow.InboxValueUnpublished"

	// CoreEventInboxValueClaimed is emitted when a Capability is claimed by an account
	CoreEventInboxValueClaimed = "flow.InboxValueClaimed"
)

Core event types based on documentation https://cadence-lang.org/docs/language/core-events

View Source
const (
	// DefaultMaxEventTypes is the default maximum number of event types that can be specified in a filter
	DefaultMaxEventTypes = 1000

	// DefaultMaxAddresses is the default maximum number of addresses that can be specified in a filter
	DefaultMaxAddresses = 1000

	// DefaultMaxContracts is the default maximum number of contracts that can be specified in a filter
	DefaultMaxContracts = 1000

	// DefaultMaxAccountAddresses specifies limitation for possible number of accounts that could be used in filter
	DefaultMaxAccountAddresses = 100
)
View Source
const (
	// DefaultRegisterIDsRequestLimit defines the default limit of register IDs for a single request to the get register endpoint
	DefaultRegisterIDsRequestLimit = 100
)

Variables

DefaultCoreEvents is an array containing all default core event types.

View Source
var DefaultEventFilterConfig = EventFilterConfig{
	MaxEventTypes:     DefaultMaxEventTypes,
	MaxAddresses:      DefaultMaxAddresses,
	MaxContracts:      DefaultMaxContracts,
	MaxAccountAddress: DefaultMaxAccountAddresses,
}

DefaultEventFilterConfig is the default configuration for EventFilters

Functions

This section is empty.

Types

type API

type API interface {
	// GetExecutionDataByBlockID retrieves execution data for a specific block by its block ID.
	GetExecutionDataByBlockID(ctx context.Context, blockID flow.Identifier) (*execution_data.BlockExecutionData, error)
	// SubscribeExecutionData is deprecated and will be removed in future versions.
	// Use SubscribeExecutionDataFromStartBlockID, SubscribeExecutionDataFromStartBlockHeight or SubscribeExecutionDataFromLatest.
	//
	// SubscribeExecutionData subscribes to execution data starting from a specific block ID and block height.
	SubscribeExecutionData(ctx context.Context, startBlockID flow.Identifier, startBlockHeight uint64) subscription.Subscription
	// SubscribeExecutionDataFromStartBlockID subscribes to execution data starting from a specific block id.
	SubscribeExecutionDataFromStartBlockID(ctx context.Context, startBlockID flow.Identifier) subscription.Subscription
	// SubscribeExecutionDataFromStartBlockHeight subscribes to execution data starting from a specific block height.
	SubscribeExecutionDataFromStartBlockHeight(ctx context.Context, startBlockHeight uint64) subscription.Subscription
	// SubscribeExecutionDataFromLatest subscribes to execution data starting from latest block.
	SubscribeExecutionDataFromLatest(ctx context.Context) subscription.Subscription
	// SubscribeEvents is deprecated and will be removed in a future version.
	// Use SubscribeEventsFromStartBlockID, SubscribeEventsFromStartHeight or SubscribeEventsFromLatest.
	//
	// SubscribeEvents streams events for all blocks starting at the specified block ID or block height
	// up until the latest available block. Once the latest is
	// reached, the stream will remain open and responses are sent for each new
	// block as it becomes available.
	//
	// Only one of startBlockID and startHeight may be set. If neither startBlockID nor startHeight is provided,
	// the latest sealed block is used.
	//
	// Events within each block are filtered by the provided EventFilter, and only
	// those events that match the filter are returned. If no filter is provided,
	// all events are returned.
	//
	// Parameters:
	// - ctx: Context for the operation.
	// - startBlockID: The identifier of the starting block. If provided, startHeight should be 0.
	// - startHeight: The height of the starting block. If provided, startBlockID should be flow.ZeroID.
	// - filter: The event filter used to filter events.
	//
	// If invalid parameters will be supplied SubscribeEvents will return a failed subscription.
	SubscribeEvents(ctx context.Context, startBlockID flow.Identifier, startHeight uint64, filter EventFilter) subscription.Subscription
	// SubscribeEventsFromStartBlockID streams events starting at the specified block ID,
	// up until the latest available block. Once the latest is
	// reached, the stream will remain open and responses are sent for each new
	// block as it becomes available.
	//
	// Events within each block are filtered by the provided EventFilter, and only
	// those events that match the filter are returned. If no filter is provided,
	// all events are returned.
	//
	// Parameters:
	// - ctx: Context for the operation.
	// - startBlockID: The identifier of the starting block.
	// - filter: The event filter used to filter events.
	//
	// If invalid parameters will be supplied SubscribeEventsFromStartBlockID will return a failed subscription.
	SubscribeEventsFromStartBlockID(ctx context.Context, startBlockID flow.Identifier, filter EventFilter) subscription.Subscription
	// SubscribeEventsFromStartHeight streams events starting at the specified block height,
	// up until the latest available block. Once the latest is
	// reached, the stream will remain open and responses are sent for each new
	// block as it becomes available.
	//
	// Events within each block are filtered by the provided EventFilter, and only
	// those events that match the filter are returned. If no filter is provided,
	// all events are returned.
	//
	// Parameters:
	// - ctx: Context for the operation.
	// - startHeight: The height of the starting block.
	// - filter: The event filter used to filter events.
	//
	// If invalid parameters will be supplied SubscribeEventsFromStartHeight will return a failed subscription.
	SubscribeEventsFromStartHeight(ctx context.Context, startHeight uint64, filter EventFilter) subscription.Subscription
	// SubscribeEventsFromLatest subscribes to events starting at the latest sealed block,
	// up until the latest available block. Once the latest is
	// reached, the stream will remain open and responses are sent for each new
	// block as it becomes available.
	//
	// Events within each block are filtered by the provided EventFilter, and only
	// those events that match the filter are returned. If no filter is provided,
	// all events are returned.
	//
	// Parameters:
	// - ctx: Context for the operation.
	// - filter: The event filter used to filter events.
	//
	// If invalid parameters will be supplied SubscribeEventsFromLatest will return a failed subscription.
	SubscribeEventsFromLatest(ctx context.Context, filter EventFilter) subscription.Subscription
	// GetRegisterValues returns register values for a set of register IDs at the provided block height.
	GetRegisterValues(registerIDs flow.RegisterIDs, height uint64) ([]flow.RegisterValue, error)
	// SubscribeAccountStatusesFromStartBlockID subscribes to the streaming of account status changes starting from
	// a specific block ID with an optional status filter.
	SubscribeAccountStatusesFromStartBlockID(ctx context.Context, startBlockID flow.Identifier, filter AccountStatusFilter) subscription.Subscription
	// SubscribeAccountStatusesFromStartHeight subscribes to the streaming of account status changes starting from
	// a specific block height, with an optional status filter.
	SubscribeAccountStatusesFromStartHeight(ctx context.Context, startHeight uint64, filter AccountStatusFilter) subscription.Subscription
	// SubscribeAccountStatusesFromLatestBlock subscribes to the streaming of account status changes starting from a
	// latest sealed block, with an optional status filter.
	SubscribeAccountStatusesFromLatestBlock(ctx context.Context, filter AccountStatusFilter) subscription.Subscription
}

API represents an interface that defines methods for interacting with a blockchain's execution data and events.

type AccountStatusFilter added in v0.33.30

type AccountStatusFilter struct {
	*EventFilter
}

AccountStatusFilter defines a specific filter for account statuses. It embeds the EventFilter type to inherit its functionality.

func NewAccountStatusFilter added in v0.33.30

func NewAccountStatusFilter(
	config EventFilterConfig,
	chain flow.Chain,
	eventTypes []string,
	accountAddresses []string,
) (AccountStatusFilter, error)

NewAccountStatusFilter creates a new AccountStatusFilter based on the provided configuration. Expected errors: - error: An error, if any, encountered during core event type validating, check for max account addresses or validating account addresses.

func (*AccountStatusFilter) GroupCoreEventsByAccountAddress added in v0.33.30

func (f *AccountStatusFilter) GroupCoreEventsByAccountAddress(events flow.EventsList, log zerolog.Logger) map[string]flow.EventsList

GroupCoreEventsByAccountAddress extracts account-related core events from the provided list of events. It filters events based on the account field specified by the event type and organizes them by account address. Parameters: - events: The list of events to extract account-related core events from. - log: The logger to log errors encountered during event decoding and processing. Returns:

  • A map[string]flow.EventsList: A map where the key is the account address and the value is a list of account-related core events associated with that address.

type EventFilter added in v0.30.2

type EventFilter struct {
	EventTypes        map[flow.EventType]struct{}
	Addresses         map[string]struct{}
	Contracts         map[string]struct{}
	EventFieldFilters map[flow.EventType]FieldFilter
	// contains filtered or unexported fields
}

EventFilter represents a filter applied to events for a given subscription

func NewEventFilter added in v0.30.2

func NewEventFilter(
	config EventFilterConfig,
	chain flow.Chain,
	eventTypes []string,
	addresses []string,
	contracts []string,
) (EventFilter, error)

func (*EventFilter) Filter added in v0.30.2

func (f *EventFilter) Filter(events flow.EventsList) flow.EventsList

Filter applies the all filters on the provided list of events, and returns a list of events that match

func (*EventFilter) Match added in v0.30.2

func (f *EventFilter) Match(event flow.Event) bool

Match applies all filters to a specific event, and returns true if the event matches

type EventFilterConfig added in v0.30.2

type EventFilterConfig struct {
	MaxEventTypes     int
	MaxAddresses      int
	MaxContracts      int
	MaxAccountAddress int
}

EventFilterConfig is used to configure the limits for EventFilters

type FieldFilter added in v0.33.30

type FieldFilter map[string]map[string]struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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