Documentation ¶
Index ¶
- type Block
- type BlockDispatcher
- type BlockEvent
- type BlockHeadersSource
- type BlockSource
- type BlockchainSliceEvent
- type BlockchainSource
- type CancelFn
- type DeliveryFn
- type EmulationMessageEventData
- type MemPool
- type MemPoolSource
- type MessageEventData
- type SubscribeToBlockHeadersOptions
- type SubscribeToBlocksOptions
- type SubscribeToMempoolOptions
- type SubscribeToTraceOptions
- type SubscribeToTransactionsOptions
- type TraceDispatcher
- type TraceEventData
- type TraceSource
- type Tracer
- type TransactionDispatcher
- type TransactionEvent
- type TransactionEventData
- type TransactionSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockDispatcher ¶
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 ¶
func NewBlockDispatcher(logger *zap.Logger) *BlockDispatcher
func (*BlockDispatcher) RegisterSubscriber ¶
func (disp *BlockDispatcher) RegisterSubscriber(fn DeliveryFn, opts SubscribeToBlockHeadersOptions) CancelFn
func (*BlockDispatcher) Run ¶
func (disp *BlockDispatcher) Run(ctx context.Context) chan BlockEvent
type BlockEvent ¶
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 ¶
func (e BlockEvent) String() string
type BlockHeadersSource ¶
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 ¶
type BlockSource interface {
SubscribeToBlocks(ctx context.Context, deliveryFn DeliveryFn, opts SubscribeToBlocksOptions) (CancelFn, error)
}
type BlockchainSliceEvent ¶
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 (b *BlockchainSource) Run(ctx context.Context) chan indexer.IDandBlock
func (*BlockchainSource) SubscribeToBlockHeaders ¶
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 DeliveryFn ¶
type DeliveryFn func(eventData []byte)
DeliveryFn describes a callback that will be triggered once an event happens.
type EmulationMessageEventData ¶
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 (*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 ¶
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 SubscribeToMempoolOptions ¶
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 ¶
type TraceDispatcher ¶
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 ¶
func NewTraceDispatcher(logger *zap.Logger) *TraceDispatcher
NewTraceDispatcher creates a new instance of TraceDispatcher.
func (*TraceDispatcher) Dispatch ¶
func (disp *TraceDispatcher) Dispatch(accountIDs []tongo.AccountID, event []byte)
func (*TraceDispatcher) RegisterSubscriber ¶
func (disp *TraceDispatcher) RegisterSubscriber(fn DeliveryFn, options SubscribeToTraceOptions) CancelFn
type TraceEventData ¶
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 ¶
type TraceSource interface {
SubscribeToTraces(ctx context.Context, deliveryFn DeliveryFn, opts SubscribeToTraceOptions) CancelFn
}
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
func NewTracer ¶
func NewTracer(logger *zap.Logger, storage storage, source TransactionSource) *Tracer
func (*Tracer) SubscribeToTraces ¶
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 ¶
func (disp *TransactionDispatcher) Run(ctx context.Context) chan TransactionEvent
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.