protocol

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultInterval = 30 * time.Second
	DefaultTimeout  = 10 * time.Second
)
View Source
const (
	DefaultPingerCheckInterval = time.Second
	DefaultPingerPingInterval  = 5 * time.Second
	DefaultPingerTimeout       = 30 * time.Second
)
View Source
const (
	DefaultSyncerTreeBaseResTimeout = 10 * time.Second
	DefaultSyncerSectorResTimeout   = 15 * time.Second
)
View Source
const (
	BanListUpdateInterval = 7 * 24 * time.Hour
)
View Source
const (
	CurrentBanListVersion = 1
)
View Source
const (
	MaxSentPeerCount = math.MaxUint8
)

Variables

View Source
var (
	ErrPingTimeout    = errors.New("ping timeout")
	ErrPingPeerClosed = errors.New("peer closed")
)
View Source
var (
	ErrNoTreeBaseCandidates = errors.New("no tree base candidates")
	ErrSyncerNoProgress     = errors.New("sync not progressing")
	ErrSyncerMaxAttempts    = errors.New("reached max sync attempts")
)
View Source
var (
	ErrUpdateQueueMaxLen             = errors.New("update queue is at max length")
	ErrUpdateQueueIdenticalTimestamp = errors.New("timestamp is identical to stored")
	ErrUpdateQueueThrottled          = errors.New("update is throttled")
	ErrUpdateQueueStaleTimestamp     = errors.New("update is stale")
	ErrUpdateQueueSpltBrain          = errors.New("split brain")
	ErrInitialImportIncomplete       = errors.New("initial import incomplete")
)
View Source
var (
	ErrUpdaterAlreadySynchronized = errors.New("updater already synchronized")
	ErrUpdaterMerkleRootMismatch  = errors.New("updater merkle root mismatch")
	ErrNameLocked                 = errors.New("name is locked")
	ErrInsufficientTimebank       = errors.New("insufficient timebank")
)
View Source
var (
	ErrNameSyncerSyncResponseTimeout = errors.New("sync timed out")
)

Functions

func CheckTimebank

func CheckTimebank(params *TimebankParams, prevUpdateTime time.Time, prevTimebank int, sectorsNeeded int) int

func FetchListFile

func FetchListFile(url string) ([]string, error)

func IngestBanLists

func IngestBanLists(db *leveldb.DB, bs blob.Store, lists []string) error

func ParseBanListVersion

func ParseBanListVersion(line string) (int, error)

func ParseDDRPKeyRecord

func ParseDDRPKeyRecord(record string) (*btcec.PublicKey, error)

func PingPeer

func PingPeer(ctx context.Context, cfg *PingConfig) error

func ReadBanList

func ReadBanList(r io.Reader) ([]string, error)

func SyncSectors

func SyncSectors(opts *SyncSectorsOpts) error

func SyncTreeBases

func SyncTreeBases(opts *SyncTreeBasesOpts) (blob.MerkleBase, error)

func UpdateBlob

func UpdateBlob(cfg *UpdateConfig) error

Types

type DDRPKeyRecord

type DDRPKeyRecord struct {
	NameHash  string
	PublicKey *btcec.PublicKey
}

func ExtractTXTRecordsBlock

func ExtractTXTRecordsBlock(block *primitives.Block) []*DDRPKeyRecord

func ExtractTXTRecordsTx

func ExtractTXTRecordsTx(tx *primitives.Transaction) []*DDRPKeyRecord

type HNSName

type HNSName struct {
	Name      string
	PublicKey *btcec.PublicKey
}

type Heartbeat

type Heartbeat struct {
	Moniker   string      `json:"moniker"`
	PeerID    crypto.Hash `json:"peer_id"`
	UserAgent string      `json:"user_agent"`
}

type Heartbeater

type Heartbeater struct {
	Interval time.Duration
	Timeout  time.Duration
	// contains filtered or unexported fields
}

func NewHeartbeater

func NewHeartbeater(url string, moniker string, peerID crypto.Hash) *Heartbeater

func (*Heartbeater) Start

func (s *Heartbeater) Start() error

func (*Heartbeater) Stop

func (s *Heartbeater) Stop() error

type NameImporter

type NameImporter struct {
	ConfirmationDepth     int
	CheckInterval         time.Duration
	Workers               int
	VerificationThreshold float64
	// contains filtered or unexported fields
}

func NewNameImporter

func NewNameImporter(client *client.Client, db *leveldb.DB) *NameImporter

func (*NameImporter) Start

func (n *NameImporter) Start() error

func (*NameImporter) Stop

func (n *NameImporter) Stop() error

type NameSyncer

type NameSyncer struct {
	Workers               int
	SampleSize            int
	UpdateResponseTimeout time.Duration
	Interval              time.Duration
	SyncResponseTimeout   time.Duration
	// contains filtered or unexported fields
}

func NewNameSyncer

func NewNameSyncer(mux *p2p.PeerMuxer, db *leveldb.DB, nameLocker util.MultiLocker, updater *Updater) *NameSyncer

func (*NameSyncer) OnJobComplete

func (ns *NameSyncer) OnJobComplete(cb func(count int)) util.Unsubscriber

func (*NameSyncer) OnNameComplete

func (ns *NameSyncer) OnNameComplete(cb func(name string, receiptCount int)) util.Unsubscriber

func (*NameSyncer) OnSyncError

func (ns *NameSyncer) OnSyncError(cb func(name string, err error)) util.Unsubscriber

func (*NameSyncer) Start

func (ns *NameSyncer) Start() error

func (*NameSyncer) Stop

func (ns *NameSyncer) Stop() error

type PeerExchanger

type PeerExchanger struct {
	SampleSize      int
	ResponseTimeout time.Duration
	RequestInterval time.Duration
	// contains filtered or unexported fields
}

func NewPeerExchanger

func NewPeerExchanger(dialer p2p.PeerDialer, mux *p2p.PeerMuxer, db *leveldb.DB) *PeerExchanger

func (*PeerExchanger) Start

func (pe *PeerExchanger) Start() error

func (*PeerExchanger) Stop

func (pe *PeerExchanger) Stop() error

type PeerSet

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

func NewPeerSet

func NewPeerSet(initialPeers []crypto.Hash) *PeerSet

func (*PeerSet) Add

func (ps *PeerSet) Add(peerID crypto.Hash)

func (*PeerSet) Has

func (ps *PeerSet) Has(peerID crypto.Hash) bool

func (*PeerSet) Iterator

func (ps *PeerSet) Iterator() func() (crypto.Hash, bool)

func (*PeerSet) Len

func (ps *PeerSet) Len() int

type PingConfig

type PingConfig struct {
	CheckInterval time.Duration
	PingInterval  time.Duration
	Timeout       time.Duration
	PeerID        crypto.Hash
	Mux           *p2p.PeerMuxer
}

type Pinger

type Pinger struct {
	CheckInterval time.Duration
	PingInterval  time.Duration
	Timeout       time.Duration
	// contains filtered or unexported fields
}

func NewPinger

func NewPinger(mux *p2p.PeerMuxer) *Pinger

func (*Pinger) Start

func (p *Pinger) Start() error

func (*Pinger) Stop

func (p *Pinger) Stop() error

type SectorServer

type SectorServer struct {
	CacheExpiry time.Duration
	// contains filtered or unexported fields
}

func NewSectorServer

func NewSectorServer(mux *p2p.PeerMuxer, db *leveldb.DB, bs blob.Store, nameLocker util.MultiLocker) *SectorServer

func (*SectorServer) Start

func (s *SectorServer) Start() error

func (*SectorServer) Stop

func (s *SectorServer) Stop() error

type SyncSectorsOpts

type SyncSectorsOpts struct {
	Timeout       time.Duration
	Mux           *p2p.PeerMuxer
	Tx            blob.Transaction
	Peers         *PeerSet
	MerkleBase    blob.MerkleBase
	SectorsNeeded []uint8
	Name          string
}

type SyncTreeBasesOpts

type SyncTreeBasesOpts struct {
	Timeout    time.Duration
	Mux        *p2p.PeerMuxer
	Peers      *PeerSet
	MerkleRoot crypto.Hash
	Name       string
}

type TimebankParams

type TimebankParams struct {
	TimebankDuration     time.Duration
	MinUpdateInterval    time.Duration
	FullUpdatesPerPeriod int
}

type UpdateConfig

type UpdateConfig struct {
	Mux        *p2p.PeerMuxer
	DB         *leveldb.DB
	NameLocker util.MultiLocker
	BlobStore  blob.Store
	Item       *UpdateQueueItem
}

type UpdateQueue

type UpdateQueue struct {
	MaxLen            int32
	MinUpdateInterval time.Duration
	// contains filtered or unexported fields
}

func NewUpdateQueue

func NewUpdateQueue(mux *p2p.PeerMuxer, db *leveldb.DB) *UpdateQueue

func (*UpdateQueue) Dequeue

func (u *UpdateQueue) Dequeue() *UpdateQueueItem

func (*UpdateQueue) Enqueue

func (u *UpdateQueue) Enqueue(peerID crypto.Hash, update *wire.Update) error

func (*UpdateQueue) Start

func (u *UpdateQueue) Start() error

func (*UpdateQueue) Stop

func (u *UpdateQueue) Stop() error

type UpdateQueueItem

type UpdateQueueItem struct {
	PeerIDs      *PeerSet
	Name         string
	Timestamp    time.Time
	MerkleRoot   crypto.Hash
	ReservedRoot crypto.Hash
	Signature    crypto.Signature
	Pub          *btcec.PublicKey
	Height       int
	Disposed     int32
}

func (*UpdateQueueItem) Dispose

func (u *UpdateQueueItem) Dispose()

type UpdateServer

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

func NewUpdateServer

func NewUpdateServer(mux *p2p.PeerMuxer, db *leveldb.DB, nameLocker util.MultiLocker) *UpdateServer

func (*UpdateServer) Start

func (u *UpdateServer) Start() error

func (*UpdateServer) Stop

func (u *UpdateServer) Stop() error

func (*UpdateServer) UpdateReqHandler

func (u *UpdateServer) UpdateReqHandler(peerID crypto.Hash, envelope *wire.Envelope)

type Updater

type Updater struct {
	PollInterval time.Duration
	Workers      int
	// contains filtered or unexported fields
}

func NewUpdater

func NewUpdater(mux *p2p.PeerMuxer, db *leveldb.DB, queue *UpdateQueue, nameLocker util.MultiLocker, bs blob.Store) *Updater

func (*Updater) OnUpdateProcessed

func (u *Updater) OnUpdateProcessed(hdlr func(item *UpdateQueueItem, err error)) util.Unsubscriber

func (*Updater) Start

func (u *Updater) Start() error

func (*Updater) Stop

func (u *Updater) Stop() error

Jump to

Keyboard shortcuts

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