event

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deduplicator

type Deduplicator struct {
	// contains filtered or unexported fields
}

Deduplicator decides whether the given event should be handled by the client or not.

Event subscription may emit the same event two or more times. The same event can be emitted right after it's been emitted for the first time. The same event can also be emitted a long time after it's been emitted for the first time. It is deduplicator's responsibility to decide whether the given event is a duplicate and should be ignored or if it is not a duplicate and should be handled.

Four events are supported: - key generation request for a new keep, - signature request for a keep, - keep close request, - keep terminate request.

func NewDeduplicator

func NewDeduplicator(
	keepRegistry keepRegistry,
	chain chain.Handle,
) *Deduplicator

NewDeduplicator is a Deduplicator constructor

func (*Deduplicator) NotifyClosingCompleted

func (d *Deduplicator) NotifyClosingCompleted(keepID chain.ID)

NotifyClosingCompleted should be called once client completed closing the keep, no matter if the execution succeeded or failed.

func (*Deduplicator) NotifyClosingStarted

func (d *Deduplicator) NotifyClosingStarted(keepID chain.ID) bool

NotifyClosingStarted notifies the client wants to close a keep upon receiving an event. It returns boolean indicating whether the client should proceed with the execution or ignore the event as a duplicate.

In case the client proceeds with closing the keep, it should call NotifyClosingCompleted once the protocol completes, no matter if it failed or succeeded.

func (*Deduplicator) NotifyKeyGenCompleted

func (d *Deduplicator) NotifyKeyGenCompleted(keepID chain.ID)

NotifyKeyGenCompleted should be called once client completed key generation protocol, no matter if it succeeded or not.

func (*Deduplicator) NotifyKeyGenStarted

func (d *Deduplicator) NotifyKeyGenStarted(keepID chain.ID) bool

NotifyKeyGenStarted notifies the client wants to start key generation for a keep upon receiving an event. It returns boolean indicating whether the client should proceed with the execution or ignore the event as a duplicate.

In case the client proceeds with the key generation, it should call NotifyKeyGenCompleted once the protocol completes, no matter if it failed or succeeded.

func (*Deduplicator) NotifySigningCompleted

func (d *Deduplicator) NotifySigningCompleted(
	keepID chain.ID,
	digest [32]byte,
)

NotifySigningCompleted should be called once client completed signature generation for the given keep and digest, no matter if the protocol succeeded or not.

func (*Deduplicator) NotifySigningStarted

func (d *Deduplicator) NotifySigningStarted(
	timeout time.Duration,
	keep chain.BondedECDSAKeepHandle,
	digest [32]byte,
) (bool, error)

NotifySigningStarted notifies the client wants to start signature generation for the given keep and digest upon receiving an event. It returns boolean indicating whether the client should proceed with the execution or ignore the event as a duplicate.

An important part of making the decision about approving the event or not is to check on-chain if keep is really awaiting for a signature. This check is repeated with a timeout specified as a parameter to address problems with minor chain reorgs or chain clients state not being synced yet at the moment or receiving an event.

In case the client proceeds with signing, it should call NotifySigningCompleted once the protocol completes, no matter if it failed or succeeded.

func (*Deduplicator) NotifyTerminatingCompleted

func (d *Deduplicator) NotifyTerminatingCompleted(keepID chain.ID)

NotifyTerminatingCompleted should be called once client completed terminating the keep, no matter if the execution succeeded or failed.

func (*Deduplicator) NotifyTerminatingStarted

func (d *Deduplicator) NotifyTerminatingStarted(keepID chain.ID) bool

NotifyTerminatingStarted notifies the client wants to terminate a keep upon receiving an event. It returns boolean indicating whether the client should proceed with the execution or ignore the event as a duplicate.

In case the client proceeds with terminating the keep, it should call NotifyTerminatingCompleted once the protocol completes, no matter if it failed or succeeded.

Jump to

Keyboard shortcuts

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