peerdb

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicSlice

type AtomicSlice[PT ptrValue[T], T any] atomic.Pointer[[]PT]

func (*AtomicSlice[PT, T]) Copy

func (s *AtomicSlice[PT, T]) Copy() *AtomicSlice[PT, T]

func (*AtomicSlice[PT, T]) Equal

func (s *AtomicSlice[PT, T]) Equal(t *AtomicSlice[PT, T]) bool

func (*AtomicSlice[PT, T]) Get

func (s *AtomicSlice[PT, T]) Get(target PT) (PT, bool)

func (*AtomicSlice[PT, T]) Insert

func (s *AtomicSlice[PT, T]) Insert(target PT) PT

func (*AtomicSlice[PT, T]) Load

func (s *AtomicSlice[PT, T]) Load() []PT

func (*AtomicSlice[PT, T]) MarshalJSON

func (s *AtomicSlice[PT, T]) MarshalJSON() ([]byte, error)

func (*AtomicSlice[PT, T]) Store

func (s *AtomicSlice[PT, T]) Store(v []PT)

func (*AtomicSlice[PT, T]) UnmarshalJSON

func (s *AtomicSlice[PT, T]) UnmarshalJSON(b []byte) error

type AtomicUint

type AtomicUint atomic.Uint64

func (*AtomicUint) Add

func (v *AtomicUint) Add(delta uint64)

func (*AtomicUint) Copy

func (v *AtomicUint) Copy() *AtomicUint

func (*AtomicUint) Equal

func (v *AtomicUint) Equal(u *AtomicUint) bool

func (*AtomicUint) Load

func (v *AtomicUint) Load() uint64

func (*AtomicUint) MarshalJSON

func (v *AtomicUint) MarshalJSON() ([]byte, error)

func (*AtomicUint) Store

func (v *AtomicUint) Store(u uint64)

func (*AtomicUint) UnmarshalJSON

func (v *AtomicUint) UnmarshalJSON(b []byte) error

type DB

type DB struct {
	LastScan *time.Time                            `json:"lastScan,omitempty" form:"lastScan" query:"lastScan" validate:"required"`
	Peers    *AtomicSlice[*PeerStatus, PeerStatus] `json:"peers,omitempty" form:"peers" query:"peers" validate:"required"`
}

func LoadFile

func LoadFile(file string) (*DB, error)

func New

func New() *DB

func (*DB) Copy

func (v *DB) Copy() *DB

func (*DB) CopyAsInterface

func (v *DB) CopyAsInterface() interface{}

func (*DB) Equal

func (v *DB) Equal(u *DB) bool

func (*DB) Load

func (db *DB) Load(rd io.Reader) error

func (*DB) Peer

func (db *DB) Peer(id peer.ID) *PeerStatus

func (*DB) Store

func (db *DB) Store(wr io.Writer) error

func (*DB) StoreFile

func (db *DB) StoreFile(file string) error

type LastStatus

type LastStatus struct {
	Success *time.Time  `json:"success,omitempty" form:"success" query:"success" validate:"required"`
	Attempt *time.Time  `json:"attempt,omitempty" form:"attempt" query:"attempt" validate:"required"`
	Failed  *AtomicUint `json:"failed,omitempty" form:"failed" query:"failed" validate:"required"`
}

func (*LastStatus) Copy

func (v *LastStatus) Copy() *LastStatus

func (*LastStatus) CopyAsInterface

func (v *LastStatus) CopyAsInterface() interface{}

func (*LastStatus) DidAttempt

func (l *LastStatus) DidAttempt()

func (*LastStatus) DidSucceed

func (l *LastStatus) DidSucceed()

func (*LastStatus) Equal

func (v *LastStatus) Equal(u *LastStatus) bool

func (*LastStatus) SinceAttempt

func (l *LastStatus) SinceAttempt() time.Duration

func (*LastStatus) SinceSuccess

func (l *LastStatus) SinceSuccess() time.Duration

func (*LastStatus) UnmarshalJSON

func (s *LastStatus) UnmarshalJSON(b []byte) error

type PeerAddressStatus

type PeerAddressStatus struct {
	Address p2p.Multiaddr `json:"address,omitempty" form:"address" query:"address" validate:"required"`
	Last    LastStatus    `json:"last,omitempty" form:"last" query:"last" validate:"required"`
}

func (*PeerAddressStatus) Compare

func (s *PeerAddressStatus) Compare(b *PeerAddressStatus) int

func (*PeerAddressStatus) Copy

func (*PeerAddressStatus) CopyAsInterface

func (v *PeerAddressStatus) CopyAsInterface() interface{}

func (*PeerAddressStatus) Equal

func (*PeerAddressStatus) MarshalJSON

func (v *PeerAddressStatus) MarshalJSON() ([]byte, error)

func (*PeerAddressStatus) UnmarshalJSON

func (v *PeerAddressStatus) UnmarshalJSON(data []byte) error

type PeerNetworkStatus

type PeerNetworkStatus struct {
	Name     string                                              `json:"name,omitempty" form:"name" query:"name" validate:"required"`
	Services *AtomicSlice[*PeerServiceStatus, PeerServiceStatus] `json:"services,omitempty" form:"services" query:"services" validate:"required"`
}

func (*PeerNetworkStatus) Compare

func (s *PeerNetworkStatus) Compare(b *PeerNetworkStatus) int

func (*PeerNetworkStatus) Copy

func (*PeerNetworkStatus) CopyAsInterface

func (v *PeerNetworkStatus) CopyAsInterface() interface{}

func (*PeerNetworkStatus) Equal

func (*PeerNetworkStatus) Service

func (p *PeerNetworkStatus) Service(addr *api.ServiceAddress) *PeerServiceStatus

func (*PeerNetworkStatus) UnmarshalJSON

func (s *PeerNetworkStatus) UnmarshalJSON(b []byte) error

type PeerServiceStatus

type PeerServiceStatus struct {
	Address *api.ServiceAddress `json:"address,omitempty" form:"address" query:"address" validate:"required"`
	Last    LastStatus          `json:"last,omitempty" form:"last" query:"last" validate:"required"`
}

func (*PeerServiceStatus) Compare

func (s *PeerServiceStatus) Compare(q *PeerServiceStatus) int

func (*PeerServiceStatus) Copy

func (*PeerServiceStatus) CopyAsInterface

func (v *PeerServiceStatus) CopyAsInterface() interface{}

func (*PeerServiceStatus) Equal

type PeerStatus

type PeerStatus struct {
	ID        p2p.PeerID
	Addresses *AtomicSlice[*PeerAddressStatus, PeerAddressStatus] `json:"addresses,omitempty" form:"addresses" query:"addresses" validate:"required"`
	Networks  *AtomicSlice[*PeerNetworkStatus, PeerNetworkStatus] `json:"networks,omitempty" form:"networks" query:"networks" validate:"required"`
}

func (*PeerStatus) Address

func (p *PeerStatus) Address(addr multiaddr.Multiaddr) *PeerAddressStatus

func (*PeerStatus) Compare

func (s *PeerStatus) Compare(q *PeerStatus) int

func (*PeerStatus) Copy

func (v *PeerStatus) Copy() *PeerStatus

func (*PeerStatus) CopyAsInterface

func (v *PeerStatus) CopyAsInterface() interface{}

func (*PeerStatus) Equal

func (v *PeerStatus) Equal(u *PeerStatus) bool

func (*PeerStatus) Network

func (p *PeerStatus) Network(name string) *PeerNetworkStatus

func (*PeerStatus) UnmarshalJSON

func (s *PeerStatus) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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