fraud

package
v0.8.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructModule

func ConstructModule(tp node.Type) fx.Option

func Lifecycle

func Lifecycle(
	startCtx, lifecycleCtx context.Context,
	p fraud.ProofType,
	fraudServ fraud.Service,
	start, stop func(context.Context) error,
) error

Lifecycle controls the lifecycle of service depending on fraud proofs. It starts the service only if no fraud-proof exists and stops the service automatically if a proof arrives after the service was started.

Types

type API added in v0.5.0

type API struct {
	Internal struct {
		Subscribe func(context.Context, fraud.ProofType) (<-chan Proof, error) `perm:"public"`
		Get       func(context.Context, fraud.ProofType) ([]Proof, error)      `perm:"public"`
	}
}

API is a wrapper around Module for the RPC. TODO(@distractedm1nd): These structs need to be autogenerated.

func (*API) Get added in v0.5.0

func (api *API) Get(ctx context.Context, proofType fraud.ProofType) ([]Proof, error)

func (*API) Subscribe added in v0.5.0

func (api *API) Subscribe(ctx context.Context, proofType fraud.ProofType) (<-chan Proof, error)

type Module

type Module interface {
	// Subscribe allows to subscribe on a Proof pub sub topic by its type.
	Subscribe(context.Context, fraud.ProofType) (<-chan Proof, error)
	// Get fetches fraud proofs from the disk by its type.
	Get(context.Context, fraud.ProofType) ([]Proof, error)
}

Module encompasses the behavior necessary to subscribe and broadcast fraud proofs within the network. Any method signature changed here needs to also be changed in the API struct.

type Proof added in v0.5.0

type Proof struct {
	fraud.Proof
}

Proof embeds the fraud.Proof interface type to provide a concrete type for JSON serialization.

func (*Proof) MarshalJSON added in v0.5.0

func (f *Proof) MarshalJSON() ([]byte, error)

func (*Proof) UnmarshalJSON added in v0.5.0

func (f *Proof) UnmarshalJSON(data []byte) error

type Service added in v0.5.0

type Service struct {
	fraud.Service
}

Service is an implementation of Module that uses fraud.Service as a backend. It is used to provide fraud proofs as a non-interface type to the API, and wrap fraud.Subscriber with a channel of Proofs.

func (*Service) Get added in v0.5.0

func (s *Service) Get(ctx context.Context, proofType fraud.ProofType) ([]Proof, error)

func (*Service) Subscribe added in v0.5.0

func (s *Service) Subscribe(ctx context.Context, proofType fraud.ProofType) (<-chan Proof, error)

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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