v0.9.5 Latest Latest

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

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 12 Imported by: 0




This section is empty.


This section is empty.


func CheckFromAddress added in v0.3.0

func CheckFromAddress(m *data.MemPoolTx, params ...interface{}) bool

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

func CheckToAddress(m *data.MemPoolTx, params ...interface{}) bool

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

func InitMemPool(pool *data.MemPool) error

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

func InitParentContext(ctx context.Context)

InitParentContext - Initializing parent context, to be listened by all graphQL subscribers so that graceful shutdown can be done

func LinkedTx added in v0.4.0

func LinkedTx(m *data.MemPoolTx, params ...interface{}) bool

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 *subscriber.Subscriber, 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

func NoCriteria(*data.MemPoolTx, ...interface{}) bool

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) (*subscriber.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) (*subscriber.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) (*subscriber.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) (*subscriber.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) (*subscriber.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) (*subscriber.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) (*subscriber.Subscriber, error)

SubscribeToQueuedTxExit - Subscribe to topic where queued tx(s), getting unstuck are published

func SubscribeToTopic added in v0.3.0

func SubscribeToTopic(ctx context.Context, topic ...string) (*subscriber.Subscriber, error)

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

func UnmarshalPubSubMessage(message []byte) *data.MemPoolTx

UnmarshalPubSubMessage - Attempts to unmarshal message pack serialized pubsub message as structured tx data, which is to be sent to subscriber


type PublishingCriteria added in v0.3.0

type PublishingCriteria func(*data.MemPoolTx, ...interface{}) bool

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.


Path Synopsis

Jump to

Keyboard shortcuts

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