utils

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr2Peers

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

Active peers

func NewAddr2Peers

func NewAddr2Peers() *Addr2Peers

func (*Addr2Peers) Add

func (a *Addr2Peers) Add(address string, peer peer.Peer)

add address to known list

func (*Addr2Peers) Addresses

func (a *Addr2Peers) Addresses() []string

get all known addresses

func (*Addr2Peers) Delete

func (a *Addr2Peers) Delete(p peer.Peer)

delete address

func (*Addr2Peers) Each

func (a *Addr2Peers) Each(f func(p peer.Peer))

execute function with each address

func (*Addr2Peers) Exists

func (a *Addr2Peers) Exists(address string) bool

check address already exists

func (*Addr2Peers) Get

func (a *Addr2Peers) Get(p peer.Peer) peer.Peer

returns *PeerInfo by address, nil if not found

type ByTime

type ByTime []Response

func (ByTime) Len

func (a ByTime) Len() int

func (ByTime) Less

func (a ByTime) Less(i, j int) bool

func (ByTime) Swap

func (a ByTime) Swap(i, j int)

type Count

type Count struct {
	UniqueTransaction uint64
	TransactionsSend  uint64
}

type Counter

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

func NewCounter

func NewCounter() *Counter

func (*Counter) Get

func (a *Counter) Get() []Response

func (*Counter) IncEachTransaction

func (a *Counter) IncEachTransaction()

collect how many transaction we send (or tried to send) in an hour

func (*Counter) IncUniqueTransaction

func (a *Counter) IncUniqueTransaction()

collect how many unique transaction we received

func (*Counter) Stop

func (a *Counter) Stop()

type FileBasedStorage

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

func NewFileBasedStorage

func NewFileBasedStorage(fs afero.Fs, pathToFile string) (*FileBasedStorage, error)

func (*FileBasedStorage) Close

func (a *FileBasedStorage) Close()

func (*FileBasedStorage) Read

func (a *FileBasedStorage) Read() ([]byte, error)

func (*FileBasedStorage) Save

func (a *FileBasedStorage) Save(b []byte) error

type JsonKnowPeerRow

type JsonKnowPeerRow struct {
	Addr    string
	Version proto.Version
}

type KnownPeers

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

func NewKnownPeers

func NewKnownPeers(storage Storage) (*KnownPeers, error)

func NewKnownPeersInterval

func NewKnownPeersInterval(storage Storage, saveInterval time.Duration) (*KnownPeers, error)

func (*KnownPeers) Add

func (a *KnownPeers) Add(declAddr proto.TCPAddr, version proto.Version)

func (*KnownPeers) Addresses

func (a *KnownPeers) Addresses() []proto.PeerInfo

func (*KnownPeers) GetAll

func (a *KnownPeers) GetAll() []string

func (*KnownPeers) Stop

func (a *KnownPeers) Stop()

type NoOnStorage

type NoOnStorage struct{}

func (NoOnStorage) Close

func (a NoOnStorage) Close()

func (NoOnStorage) Read

func (a NoOnStorage) Read() ([]byte, error)

func (NoOnStorage) Save

func (a NoOnStorage) Save(_ []byte) error

type Response

type Response struct {
	Time  string
	Value Count
}

type SpawnedPeers

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

func NewSpawnedPeers

func NewSpawnedPeers() *SpawnedPeers

func (*SpawnedPeers) Add

func (a *SpawnedPeers) Add(addr string)

func (*SpawnedPeers) Delete

func (a *SpawnedPeers) Delete(addr string)

func (*SpawnedPeers) Exists

func (a *SpawnedPeers) Exists(addr string) bool

func (*SpawnedPeers) GetAll

func (a *SpawnedPeers) GetAll() []string

type Storage

type Storage interface {
	Save([]byte) error
	Read() ([]byte, error)
	Close()
}

Jump to

Keyboard shortcuts

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