Documentation ¶
Index ¶
- func GetRelevantTopics() []common.Hash
- type Config
- type Watcher
- func (w *Watcher) Cleanup(ctx context.Context, lastUpdatedBuffer time.Duration) error
- func (w *Watcher) RevalidateOrdersForMissingEvents(ctx context.Context) error
- func (w *Watcher) Subscribe(sink chan<- []*zeroex.OrderEvent) event.Subscription
- func (w *Watcher) ValidateAndStoreValidOrders(ctx context.Context, orders []*zeroex.SignedOrder, pinned bool, chainID int) (*ordervalidator.ValidationResults, error)
- func (w *Watcher) WaitForAtLeastOneBlockToBeProcessed(ctx context.Context) error
- func (w *Watcher) Watch(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRelevantTopics ¶
GetRelevantTopics returns the OrderWatcher-relevant topics that should be used when filtering the logs retrieved for Ethereum blocks
Types ¶
type Config ¶
type Config struct { DB *db.DB BlockWatcher *blockwatch.Watcher OrderValidator *ordervalidator.OrderValidator ChainID int ContractAddresses ethereum.ContractAddresses MaxOrders int }
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher watches all order-relevant state and handles the state transitions
func (*Watcher) Cleanup ¶
Cleanup re-validates all orders in DB which haven't been re-validated in `lastUpdatedBuffer` time to make sure all orders are still up-to-date
func (*Watcher) RevalidateOrdersForMissingEvents ¶
RevalidateOrdersForMissingEvents checks all of the orders in the database for any events in the miniheaders table that may have been missed. This should only be used on startup, as there is a different mechanism that serves this purpose during normal operation.
NOTE(jalextowle): This function can miss block events if the blockwatcher was behind by more than db.MaxMiniHeaders when `handleBlockEvents` was last called. This is extremely unlikely, so we have decided not to implement more costly mechanisms to prevent from this possibility from occurring.
func (*Watcher) Subscribe ¶
func (w *Watcher) Subscribe(sink chan<- []*zeroex.OrderEvent) event.Subscription
Subscribe allows one to subscribe to the order events emitted by the OrderWatcher. To unsubscribe, simply call `Unsubscribe` on the returned subscription. The sink channel should have ample buffer space to avoid blocking other subscribers. Slow subscribers are not dropped.
func (*Watcher) ValidateAndStoreValidOrders ¶
func (w *Watcher) ValidateAndStoreValidOrders(ctx context.Context, orders []*zeroex.SignedOrder, pinned bool, chainID int) (*ordervalidator.ValidationResults, error)
ValidateAndStoreValidOrders applies general 0x validation and Mesh-specific validation to the given orders and if they are valid, adds them to the OrderWatcher
func (*Watcher) WaitForAtLeastOneBlockToBeProcessed ¶
WaitForAtLeastOneBlockToBeProcessed waits until the OrderWatcher has processed its first block