book

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address = ma.Multiaddr

type Book

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

func New

func New(opts ...Opt) *Book

func (*Book) Add

func (b *Book) Add(src, id ID, raw Address)

func (*Book) DrainQueue

func (b *Book) DrainQueue(n int) []Address

func (*Book) Persist

func (b *Book) Persist(w io.Writer) error

func (*Book) Recover

func (b *Book) Recover(r io.Reader) error

func (*Book) Stats

func (b *Book) Stats() Stats

func (*Book) TakeShareable

func (b *Book) TakeShareable(src ID, n int) []Address

func (*Book) Update

func (b *Book) Update(id ID, events ...Event)

type Event

type Event int
const (
	Protect Event = iota
	Connected
	Disconnected
	Success
	Fail
)

type ID

type ID = string
const SELF ID = "SELF"

type Opt

type Opt func(*Book)

func WithLimit

func WithLimit(limit int) Opt

WithLimit updates default book limit.

func WithRand

func WithRand(seed int64) Opt

WithRand overwrites default seed for determinism in tests.

type Stats

type Stats struct {
	Total     int
	Connected int

	Public  int
	Private int

	Stale   int
	Learned int
	Stable  int
}

Jump to

Keyboard shortcuts

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