sources

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: MIT Imports: 9 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockchainSource

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

BlockchainSource notifies about transactions in the TON blockchain.

func NewBlockchainSource

func NewBlockchainSource(logger *zap.Logger, servers []config.LiteServer) (*BlockchainSource, error)

func (*BlockchainSource) Run

func (*BlockchainSource) SubscribeToTransactions

func (b *BlockchainSource) SubscribeToTransactions(ctx context.Context, deliverFn DeliveryFn, opts SubscribeToTransactionsOptions) CancelFn

type CancelFn

type CancelFn func()

CancelFn has to be called to unsubscribe.

type DeliveryFn

type DeliveryFn func(eventData []byte)

DeliveryFn describes a callback that will be triggered once an event happens.

type MemPool

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

MemPool implements "MemPoolSource" interface and provides a method to subscribe to pending inbound messages.

func NewMemPool

func NewMemPool(logger *zap.Logger) *MemPool

func (*MemPool) Run

func (m *MemPool) Run(ctx context.Context) chan []byte

Run runs a goroutine with a fan-out event-loop that resends an incoming payload to all subscribers.

func (*MemPool) SubscribeToMessages

func (m *MemPool) SubscribeToMessages(ctx context.Context, deliveryFn DeliveryFn) (CancelFn, error)

type MemPoolSource

type MemPoolSource interface {
	SubscribeToMessages(ctx context.Context, deliveryFn DeliveryFn) (CancelFn, error)
}

MemPoolSource provides a method to subscribe to notifications about pending inbound messages.

type MessageEventData

type MessageEventData struct {
	BOC []byte `json:"boc"`
}

MessageEventData represents a notification about a new pending inbound message. This is part of our API contract with subscribers.

type SubscribeToTransactionsOptions

type SubscribeToTransactionsOptions struct {
	AllAccounts bool
	Accounts    []tongo.AccountID
}

type TransactionDispatcher

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

TransactionDispatcher implements the fan-out pattern reading a TransactionEvent from a single channel and delivering it to multiple subscribers.

func NewTransactionDispatcher

func NewTransactionDispatcher(logger *zap.Logger) *TransactionDispatcher

func (*TransactionDispatcher) RegisterSubscriber

func (disp *TransactionDispatcher) RegisterSubscriber(fn DeliveryFn, options SubscribeToTransactionsOptions) CancelFn

func (*TransactionDispatcher) Run

Run runs a dispatching loop in a dedicated goroutine and returns a channel to be used to communicate with this dispatcher.

type TransactionEvent

type TransactionEvent struct {
	AccountID tongo.AccountID
	Lt        uint64
	TxHash    string
}

TransactionEvent is a notification event about a new transaction between a TransactionSource instance and a dispatcher.

type TransactionEventData

type TransactionEventData struct {
	AccountID tongo.AccountID `json:"account_id"`
	Lt        uint64          `json:"lt"`
	TxHash    string          `json:"tx_hash"`
}

TransactionEventData represents a notification about a new transaction. This is part of our API contract with subscribers.

type TransactionSource

type TransactionSource interface {
	SubscribeToTransactions(ctx context.Context, deliveryFn DeliveryFn, opts SubscribeToTransactionsOptions) CancelFn
}

TransactionSource provides a method to subscribe to notifications about new transactions from the blockchain.

Jump to

Keyboard shortcuts

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