Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( //ErrPartsDonAddToOne is returned when the partials don't add up to 1 ErrPartsDonAddToOne = errors.New("α, β, γ don't add together to 1.0") //ErrL1AtLeast is returns if l1 was too low ErrL1AtLeast = errors.New("l1 must be at least " + strconv.Itoa(minL1)) //ErrL2AtLeast is returned when l2 is too low ErrL2AtLeast = errors.New("l2 must be at least 1" + strconv.Itoa(minL2)) )
var MaxSampleRank = SampleRank{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
}
MaxSampleRank is the maximum rank a sample can reach
Functions ¶
This section is empty.
Types ¶
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core keeps the state of a node in the gossip network
func (*Core) Deactivate ¶
func (c *Core) Deactivate()
Deactivate clears the view and sets the core to non-active state
func (*Core) ReceiveNode ¶
ReceiveNode gets called when another peer pushes its info
func (*Core) UpdateView ¶
UpdateView runs the algorithm to update the view
func (*Core) ValidateSample ¶
ValidateSample validates if all samples are still responding
type SampleRank ¶
type SampleRank [32]byte
SampleRank describes a rank based on 32 bytes of data as a big number
func (SampleRank) ToInt ¶
func (sr SampleRank) ToInt() *big.Int
ToInt converts the bytes to the big nr
type Sampler ¶
type Sampler struct {
// contains filtered or unexported fields
}
Sampler holds a sample from a node stream such that it is not biased by the nr of times a appears in the stream.
func NewSampler ¶
NewSampler initializes a sampler with the provided source of randomness
func (*Sampler) RecentlyInvalidated ¶
RecentlyInvalidated returns whether a given node was recently invalidated due to a failing probe
type Transport ¶
type Transport interface { Emit(ctx context.Context, c chan<- NID, id NID, msg []byte, to Node) Push(ctx context.Context, self Node, to Node) Pull(ctx context.Context, c chan<- View, from Node) Prober }
Transport describes how a node communicates with its peers
type View ¶
View describes a set of node ids
func Brahms ¶
func Brahms(self *Node, rnd *rand.Rand, p P, to time.Duration, s *Sampler, tr Transport, pushes <-chan Node, v View) View
Brahms implements the gossip protocol and takes an old view 'v' and returns a new view.