sources

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 20 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block added in v1.2.0

type Block struct {
	Workchain int32  `json:"workchain"`
	Shard     string `json:"shard"`
	Seqno     uint32 `json:"seqno"`
	RootHash  string `json:"root_hash"`
	FileHash  string `json:"file_hash"`
	Raw       []byte `json:"raw"`
}

type BlockDispatcher added in v1.2.0

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

BlockDispatcher tracks all subscribers and works as a fan-out queue: on receiving a new block, BlockDispatcher sends a notification about it to all subscribers.

func NewBlockDispatcher added in v1.2.0

func NewBlockDispatcher(logger *zap.Logger) *BlockDispatcher

func (*BlockDispatcher) RegisterSubscriber added in v1.2.0

func (disp *BlockDispatcher) RegisterSubscriber(fn DeliveryFn, opts SubscribeToBlockHeadersOptions) CancelFn

func (*BlockDispatcher) Run added in v1.2.0

func (disp *BlockDispatcher) Run(ctx context.Context) chan BlockEvent

type BlockEvent added in v1.2.0

type BlockEvent struct {
	Workchain int32  `json:"workchain"`
	Shard     string `json:"shard"`
	Seqno     uint32 `json:"seqno"`
	RootHash  string `json:"root_hash"`
	FileHash  string `json:"file_hash"`
}

BlockEvent represents a notification about a new block. This is part of our API contract with subscribers.

func (BlockEvent) String added in v1.2.0

func (e BlockEvent) String() string

type BlockHeadersSource added in v1.2.0

type BlockHeadersSource interface {
	SubscribeToBlockHeaders(ctx context.Context, deliveryFn DeliveryFn, opts SubscribeToBlockHeadersOptions) CancelFn
}

BlockHeadersSource provides a method to subscribe to notifications about new blocks in the TON network.

type BlockSource added in v1.2.0

type BlockSource interface {
	SubscribeToBlocks(ctx context.Context, deliveryFn DeliveryFn, opts SubscribeToBlocksOptions) (CancelFn, error)
}

type BlockchainSliceEvent added in v1.2.0

type BlockchainSliceEvent struct {
	MasterchainSeqno uint32 `json:"masterchain_seqno"`
	// Blocks contains one masterchain block and all blocks from the basechain created since the previous blockchain slice.
	Blocks []Block `json:"blocks"`
}

BlockchainSliceEvent represents a notification about a new bunch of blocks in the blockchain.

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, cli *liteapi.Client) *BlockchainSource

func (*BlockchainSource) Run

func (*BlockchainSource) SubscribeToBlockHeaders added in v1.2.0

func (b *BlockchainSource) SubscribeToBlockHeaders(ctx context.Context, deliveryFn DeliveryFn, opts SubscribeToBlockHeadersOptions) CancelFn

func (*BlockchainSource) SubscribeToTransactions

func (b *BlockchainSource) SubscribeToTransactions(ctx context.Context, deliveryFn 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 EmulationMessageEventData added in v1.2.0

type EmulationMessageEventData struct {
	BOC []byte `json:"boc"`
	// InvolvedAccounts is a list of accounts that are involved in the corresponding trace of the message.
	// The trace is a result of emulation.
	InvolvedAccounts []tongo.AccountID `json:"involved_accounts"`
}

EmulationMessageEventData represents a notification about a new pending inbound message. After opentonapi receives a message, it emulates what happens when the message lands on the blockchain. Then it sends the message and the emulation results to subscribers. This is part of our API contract with subscribers.

type MemPool

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

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

MemPool supports two types of subscribers: regular and emulation. Regular subscriber receives a message payload once it lands in mempool. Emulation subscriber receives a message payload and additional emulation results with a short delay required to emulate a trace.

func NewMemPool

func NewMemPool(logger *zap.Logger) *MemPool

func (*MemPool) Run

func (m *MemPool) Run(ctx context.Context) chan blockchain.ExtInMsgCopy

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, opts SubscribeToMempoolOptions) (CancelFn, error)

type MemPoolSource

type MemPoolSource interface {
	SubscribeToMessages(ctx context.Context, deliveryFn DeliveryFn, opts SubscribeToMempoolOptions) (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 SubscribeToBlockHeadersOptions added in v1.2.0

type SubscribeToBlockHeadersOptions struct {
	// Workchain, if set, opentonapi will filter out blocks that are not from the specified workchain.
	Workchain *int `json:"workchain,omitempty"`
}

SubscribeToBlockHeadersOptions configures subscription to block events.

type SubscribeToBlocksOptions added in v1.2.0

type SubscribeToBlocksOptions struct {
	MasterchainSeqno uint32 `json:"masterchain_seqno,omitempty"`
	// RateLimit defines the rate limit (KB/sec) for the block streaming.
	RateLimit int
}

type SubscribeToMempoolOptions added in v1.2.0

type SubscribeToMempoolOptions struct {
	// Emulation if set, opentonapi will send a message payload and additionally a list of accounts
	// that are involved in the corresponding trace.
	Accounts []tongo.AccountID
}

SubscribeToMempoolOptions configures subscription to mempool events.

type SubscribeToTraceOptions added in v1.2.0

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

type SubscribeToTransactionsOptions

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

type TraceDispatcher added in v1.2.0

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

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

func NewTraceDispatcher added in v1.2.0

func NewTraceDispatcher(logger *zap.Logger) *TraceDispatcher

NewTraceDispatcher creates a new instance of TraceDispatcher.

type TraceEventData added in v1.2.0

type TraceEventData struct {
	AccountIDs []tongo.AccountID `json:"accounts"`
	Hash       string            `json:"hash"`
}

TraceEventData represents a notification about a completed trace. This is part of our API contract with subscribers.

type TraceSource added in v1.2.0

type TraceSource interface {
	SubscribeToTraces(ctx context.Context, deliveryFn DeliveryFn, opts SubscribeToTraceOptions) CancelFn
}

type Tracer added in v1.2.0

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

func NewTracer added in v1.2.0

func NewTracer(logger *zap.Logger, storage storage, source TransactionSource) *Tracer

func (*Tracer) Run added in v1.2.0

func (t *Tracer) Run(ctx context.Context)

func (*Tracer) SubscribeToTraces added in v1.2.0

func (t *Tracer) SubscribeToTraces(ctx context.Context, deliveryFn DeliveryFn, opts SubscribeToTraceOptions) CancelFn

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
	// MsgOpName is an operation name taken from the first 4 bytes of tx.InMsg.Body.
	MsgOpName *abi.MsgOpName
	// MsgOpCode is an operation code taken from the first 4 bytes of tx.InMsg.Body.
	MsgOpCode *uint32
}

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