Documentation ¶
Index ¶
- Variables
- func OnProof(ctx context.Context, subscriber Subscriber, p ProofType, ...)
- func PubsubTopicID(fraudType, networkID string) string
- func Register(p Proof)
- func WithMetrics(store Getter)
- type Broadcaster
- type DummyService
- type ErrFraudExists
- type Getter
- type Proof
- type ProofService
- func (f *ProofService) Broadcast(ctx context.Context, p Proof) error
- func (f *ProofService) Get(ctx context.Context, proofType ProofType) ([]Proof, error)
- func (f *ProofService) Start(context.Context) error
- func (f *ProofService) Stop(context.Context) error
- func (f *ProofService) Subscribe(proofType ProofType) (_ Subscription, err error)
- type ProofType
- type ProofUnmarshaler
- type Service
- type Subscriber
- type Subscription
Constants ¶
This section is empty.
Variables ¶
var GossibSubScore = pubsub.TopicScoreParams{ SkipAtomicValidation: true, TopicWeight: 0.1, TimeInMeshWeight: 0.0002778, TimeInMeshQuantum: time.Second, TimeInMeshCap: 1, FirstMessageDeliveriesWeight: 50, FirstMessageDeliveriesDecay: pubsub.ScoreParameterDecay(10 * time.Hour), FirstMessageDeliveriesCap: math.MaxFloat64, InvalidMessageDeliveriesWeight: 0, }
GossibSubScore provides a set of recommended parameters for header GossipSub topic, a.k.a FraudSub. TODO(@Wondertan): We should disable mesh on publish for this topic to minimize chances of censoring FPs by eclipsing nodes producing them.
Functions ¶
func OnProof ¶
func OnProof(ctx context.Context, subscriber Subscriber, p ProofType, handle func(proof Proof))
OnProof subscribes to the given Fraud Proof topic via the given Subscriber. In case a Fraud Proof is received, then the given handle function will be invoked.
func PubsubTopicID ¶
func Register ¶
func Register(p Proof)
Register adds a string representation and unmarshaller for the provided ProofType.
func WithMetrics ¶
func WithMetrics(store Getter)
WithMetrics enables metrics to monitor fraud proofs.
Types ¶
type Broadcaster ¶
type Broadcaster interface { // Broadcast takes a fraud `Proof` data structure that implements standard BinaryMarshal // interface and broadcasts it to all subscribed peers. Broadcast(context.Context, Proof) error }
Broadcaster is a generic interface that sends a `Proof` to all nodes subscribed on the Broadcaster's topic.
type DummyService ¶
type DummyService struct { }
func (*DummyService) Subscribe ¶
func (d *DummyService) Subscribe(ProofType) (Subscription, error)
type ErrFraudExists ¶
type ErrFraudExists struct {
Proof []Proof
}
func (*ErrFraudExists) Error ¶
func (e *ErrFraudExists) Error() string
type Getter ¶
type Getter interface { // Get fetches fraud proofs from the disk by its type. Get(context.Context, ProofType) ([]Proof, error) }
Getter encompasses the behavior to fetch stored fraud proofs.
type Proof ¶
type Proof interface { // Type returns the exact type of fraud proof. Type() ProofType // HeaderHash returns the block hash. HeaderHash() []byte // Height returns the block height corresponding to the Proof. Height() uint64 // Validate check the validity of fraud proof. // Validate throws an error if some conditions don't pass and thus fraud proof is not valid. // NOTE: header.ExtendedHeader should pass basic validation otherwise it will panic if it's // malformed. Validate(header.Header) error encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
Proof is a generic interface that will be used for all types of fraud proofs in the network.
type ProofService ¶
type ProofService struct {
// contains filtered or unexported fields
}
ProofService is responsible for validating and propagating Fraud Proofs. It implements the Service interface.
func CreateTestService ¶
func CreateTestService(t *testing.T, enabledSyncer bool) (*ProofService, *mockStore)
func NewProofService ¶
func (*ProofService) Broadcast ¶
func (f *ProofService) Broadcast(ctx context.Context, p Proof) error
func (*ProofService) Start ¶
func (f *ProofService) Start(context.Context) error
Start joins fraud proofs topics, sets the stream handler for fraudProtocolID and starts syncing if syncer is enabled.
func (*ProofService) Stop ¶
func (f *ProofService) Stop(context.Context) error
Stop removes the stream handler and cancels the underlying ProofService
func (*ProofService) Subscribe ¶
func (f *ProofService) Subscribe(proofType ProofType) (_ Subscription, err error)
type ProofType ¶
type ProofType string
ProofType type defines a unique proof type string.
func Registered ¶
func Registered() []ProofType
Registered reports a set of registered proof types by Register.
type ProofUnmarshaler ¶
ProofUnmarshaler aliases a function that parses data to `Proof`.
type Service ¶
type Service interface { Subscriber Broadcaster Getter }
Service encompasses the behavior necessary to subscribe and broadcast fraud proofs within the network.
type Subscriber ¶
type Subscriber interface { // Subscribe allows to subscribe on a Proof pub sub topic by its type. Subscribe(ProofType) (Subscription, error) }
Subscriber encompasses the behavior necessary to subscribe/unsubscribe from new FraudProof events from the network.