graph

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 InitRedisClient added in v0.3.0

func InitRedisClient(client *redis.Client) error

InitRedisClient - Initializing redis client handle, so that all subscriptions can be done using this client

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, pubsub *redis.PubSub, 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

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) (*redis.PubSub, 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) (*redis.PubSub, 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) (*redis.PubSub, error)

SubscribeToPendingTxEntry - Subscribe to topic where new pending tx(s) are published

func SubscribeToPendingTxExit added in v0.3.0

func SubscribeToPendingTxExit(ctx context.Context) (*redis.PubSub, 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) (*redis.PubSub, 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) (*redis.PubSub, error)

SubscribeToQueuedTxEntry - Subscribe to topic where new queued tx(s) are published

func SubscribeToQueuedTxExit added in v0.3.0

func SubscribeToQueuedTxExit(ctx context.Context) (*redis.PubSub, 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) (*redis.PubSub, error)

SubscribeToTopic - Subscribes to Redis topic(s), with context of caller while waiting for subscription confirmation

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

func UnsubscribeFromTopic added in v0.3.0

func UnsubscribeFromTopic(ctx context.Context, pubsub *redis.PubSub, topic ...string)

UnsubscribeFromTopic - Given topic name to which client is already subscribed to, attempts to unsubscribe from

Types

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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