Documentation ¶
Index ¶
- func CheckFromAddress(m *data.MemPoolTx, params ...interface{}) bool
- func CheckToAddress(m *data.MemPoolTx, params ...interface{}) bool
- func InitMemPool(pool *data.MemPool) error
- func InitParentContext(ctx context.Context)
- func InitPubSub(client *pubsub.PubSub) error
- func LinkedTx(m *data.MemPoolTx, params ...interface{}) bool
- func ListenToMessages(ctx context.Context, subscriber *pubsub.Subscriber, topics []string, ...)
- func NoCriteria(*data.MemPoolTx, ...interface{}) bool
- func SubscribeToMemPool(ctx context.Context) (*pubsub.Subscriber, error)
- func SubscribeToPendingPool(ctx context.Context) (*pubsub.Subscriber, error)
- func SubscribeToPendingTxEntry(ctx context.Context) (*pubsub.Subscriber, error)
- func SubscribeToPendingTxExit(ctx context.Context) (*pubsub.Subscriber, error)
- func SubscribeToQueuedPool(ctx context.Context) (*pubsub.Subscriber, error)
- func SubscribeToQueuedTxEntry(ctx context.Context) (*pubsub.Subscriber, error)
- func SubscribeToQueuedTxExit(ctx context.Context) (*pubsub.Subscriber, error)
- func SubscribeToTopic(ctx context.Context, topic ...string) (*pubsub.Subscriber, error)
- func UnmarshalPubSubMessage(message []byte) *data.MemPoolTx
- func UnsubscribeFromTopic(ctx context.Context, subscriber *pubsub.Subscriber)
- type PublishingCriteria
- type Resolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckFromAddress ¶ added in v0.3.0
CheckFromAddress - Just checks `from` address of tx, so that client is only notified when tx from that address is detected to be entering/ leaving mempool
func CheckToAddress ¶ added in v0.3.0
CheckToAddress - Just checks `to` address of tx, so that client is only notified when tx `to` that address is detected to be entering/ leaving mempool
func InitMemPool ¶
InitMemPool - Initializing mempool handle, in this module so that it can be used before responding back to graphql queries
func InitParentContext ¶ added in v0.3.0
InitParentContext - Initializing parent context, to be listened by all graphQL subscribers so that graceful shutdown can be done
func InitPubSub ¶ added in v0.9.3
InitPubSub - Initializing pubsub handle, for managing subscriptions
func LinkedTx ¶ added in v0.4.0
LinkedTx - Given a tx in mempool, which we're tracking, will be matched against before deciding whether just received tx is somehow associated with it or not
For checking whether linked or not, we can do ¶
- First see if this tx is what we've as txHash [ LINKED ] - If tx is duplicate of it [ LINKED ]
Duplicate consideration is done by matching sender address & nonce when both of those fields same for a pair of tx(s), considered to be duplicate
func ListenToMessages ¶ added in v0.3.0
func ListenToMessages(ctx context.Context, subscriber *pubsub.Subscriber, topics []string, comm chan<- *model.MemPoolTx, pubCriteria PublishingCriteria, params ...interface{})
ListenToMessages - Attempts to listen to messages being published on topic to which graphQL client has subscribed to over websocket transport
This can be run as a seperate go routine ¶
Before publishing any message to channel, on which graphQL client is listening, one publishing criteria check to be performed, which must return `true` for this tx to be eligible for publishing to client
You can always blindly return `true` in your `evaluationCriteria` function, so that you get to receive any tx being published on topic of your interest
func NoCriteria ¶ added in v0.3.0
NoCriteria - When you want to listen to any tx being published on your topic of interest simply pass this function to `ListenToMessages` so that all criteria check always returns `true` & graphQL client receives all tx(s)
func SubscribeToMemPool ¶ added in v0.3.0
func SubscribeToMemPool(ctx context.Context) (*pubsub.Subscriber, error)
SubscribeToMemPool - Subscribes to any changes happening in mempool
As mempool has two segments i.e. 1. Pending Pool 2. Queued Pool
It'll subscribe to all 4 topics for listening to tx(s) entering/ leaving any portion of mempool
func SubscribeToPendingPool ¶ added in v0.3.0
func SubscribeToPendingPool(ctx context.Context) (*pubsub.Subscriber, error)
SubscribeToPendingPool - Subscribes to both topics, associated with changes happening in pending tx pool
When tx joins/ leaves pending pool, subscribers will receive notification
func SubscribeToPendingTxEntry ¶ added in v0.3.0
func SubscribeToPendingTxEntry(ctx context.Context) (*pubsub.Subscriber, error)
SubscribeToPendingTxEntry - Subscribe to topic where new pending tx(s) are published
func SubscribeToPendingTxExit ¶ added in v0.3.0
func SubscribeToPendingTxExit(ctx context.Context) (*pubsub.Subscriber, error)
SubscribeToPendingTxExit - Subscribe to topic where pending tx(s), getting confirmed are published
func SubscribeToQueuedPool ¶ added in v0.3.0
func SubscribeToQueuedPool(ctx context.Context) (*pubsub.Subscriber, error)
SubscribeToQueuedPool - Subscribes to both topics, associated with changes happening in queued tx pool
When tx joins/ leaves queued pool, subscribers will receive notification
@note Tx(s) generally join queued pool, when there's nonce gap & this tx can't be processed until some lower nonce tx(s) get(s) processed
func SubscribeToQueuedTxEntry ¶ added in v0.3.0
func SubscribeToQueuedTxEntry(ctx context.Context) (*pubsub.Subscriber, error)
SubscribeToQueuedTxEntry - Subscribe to topic where new queued tx(s) are published
func SubscribeToQueuedTxExit ¶ added in v0.3.0
func SubscribeToQueuedTxExit(ctx context.Context) (*pubsub.Subscriber, error)
SubscribeToQueuedTxExit - Subscribe to topic where queued tx(s), getting unstuck are published
func SubscribeToTopic ¶ added in v0.3.0
SubscribeToTopic - Subscribes to PubSub topic(s), while configuring subscription such that at max 256 messages can be kept in buffer at a time. If client is consuming slowly buffer size will be extended.
func UnmarshalPubSubMessage ¶ added in v0.3.0
UnmarshalPubSubMessage - Attempts to unmarshal message pack serialized pubsub message as structured tx data, which is to be sent to subscriber
func UnsubscribeFromTopic ¶ added in v0.3.0
func UnsubscribeFromTopic(ctx context.Context, subscriber *pubsub.Subscriber)
UnsubscribeFromTopic - Unsubscribes subscriber from all topics
Types ¶
type PublishingCriteria ¶ added in v0.3.0
PublishingCriteria - Message publishing criteria is expected in this form, which is to be invoked, everytime new message is received in any topic client is subscribed to
type Resolver ¶
type Resolver struct{}
func (*Resolver) Query ¶
func (r *Resolver) Query() generated.QueryResolver
Query returns generated.QueryResolver implementation.
func (*Resolver) Subscription ¶ added in v0.3.0
func (r *Resolver) Subscription() generated.SubscriptionResolver
Subscription returns generated.SubscriptionResolver implementation.