builtinfilters

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: Apache-2.0, BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidPOWDifficultly is returned when the nonce of a message does not fulfill the PoW difficulty.
	ErrInvalidPOWDifficultly = errors.New("invalid PoW")
	// ErrMessageTooSmall is returned when the message does not contain enough data for the PoW.
	ErrMessageTooSmall = errors.New("message too small")
)
View Source
var ErrInvalidSignature = fmt.Errorf("invalid signature")

ErrInvalidSignature is returned when a message contains an invalid signature.

View Source
var ErrReceivedDuplicateBytes = fmt.Errorf("received duplicate bytes")

ErrReceivedDuplicateBytes is returned when duplicated bytes are rejected.

Functions

This section is empty.

Types

type MessageSignatureFilter

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

MessageSignatureFilter filters messages based on whether their signatures are valid.

func NewMessageSignatureFilter

func NewMessageSignatureFilter() *MessageSignatureFilter

NewMessageSignatureFilter creates a new message signature filter.

func (*MessageSignatureFilter) Filter

func (filter *MessageSignatureFilter) Filter(msg *message.Message, peer *peer.Peer)

Filter filters up on the given bytes and peer and calls the acceptance callback if the input passes or the rejection callback if the input is rejected.

func (*MessageSignatureFilter) OnAccept

func (filter *MessageSignatureFilter) OnAccept(callback func(msg *message.Message, peer *peer.Peer))

OnAccept registers the given callback as the acceptance function of the filter.

func (*MessageSignatureFilter) OnReject

func (filter *MessageSignatureFilter) OnReject(callback func(msg *message.Message, err error, peer *peer.Peer))

OnReject registers the given callback as the rejection function of the filter.

type PowFilter

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

PowFilter is a message bytes filter validating the PoW nonce.

func NewPowFilter

func NewPowFilter(worker *pow.Worker, difficulty int) *PowFilter

NewPowFilter creates a new PoW bytes filter.

func (*PowFilter) Filter

func (f *PowFilter) Filter(msgBytes []byte, p *peer.Peer)

Filter checks whether the given bytes pass the PoW validation and calls the corresponding callback.

func (*PowFilter) OnAccept

func (f *PowFilter) OnAccept(callback func([]byte, *peer.Peer))

OnAccept registers the given callback as the acceptance function of the filter.

func (*PowFilter) OnReject

func (f *PowFilter) OnReject(callback func([]byte, error, *peer.Peer))

OnReject registers the given callback as the rejection function of the filter.

type RecentlySeenBytesFilter

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

RecentlySeenBytesFilter filters so that bytes which were recently seen don't pass the filter.

func NewRecentlySeenBytesFilter

func NewRecentlySeenBytesFilter() *RecentlySeenBytesFilter

NewRecentlySeenBytesFilter creates a new recently seen bytes filter.

func (*RecentlySeenBytesFilter) Filter

func (filter *RecentlySeenBytesFilter) Filter(bytes []byte, peer *peer.Peer)

Filter filters up on the given bytes and peer and calls the acceptance callback if the input passes or the rejection callback if the input is rejected.

func (*RecentlySeenBytesFilter) OnAccept

func (filter *RecentlySeenBytesFilter) OnAccept(callback func(bytes []byte, peer *peer.Peer))

OnAccept registers the given callback as the acceptance function of the filter.

func (*RecentlySeenBytesFilter) OnReject

func (filter *RecentlySeenBytesFilter) OnReject(callback func(bytes []byte, err error, peer *peer.Peer))

OnReject registers the given callback as the rejection function of the filter.

Jump to

Keyboard shortcuts

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