traffic

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Circuit

type Circuit [5]*Session

type PaymentChan

type PaymentChan chan *payment.Payment

type Payments

type Payments struct {
	Sessions Sessions
	PaymentChan
	sync.Mutex
	// contains filtered or unexported fields
}

func NewPayments

func NewPayments() *Payments

func (*Payments) AddPendingPayment

func (n *Payments) AddPendingPayment(
	np *payment.Payment)

func (*Payments) AddSession

func (n *Payments) AddSession(s *Session)

func (*Payments) DeletePendingPayment

func (n *Payments) DeletePendingPayment(
	preimage sha256.Hash)

func (*Payments) DeleteSession

func (n *Payments) DeleteSession(id nonce.ID)

func (*Payments) FindPendingPayment

func (n *Payments) FindPendingPayment(
	id nonce.ID) (pp *payment.Payment)

func (*Payments) FindPendingPreimage

func (n *Payments) FindPendingPreimage(
	pi sha256.Hash) (pp *payment.Payment)

func (*Payments) FindSession

func (n *Payments) FindSession(id nonce.ID) *Session

func (*Payments) GetSessionByIndex

func (n *Payments) GetSessionByIndex(i int) (s *Session)

func (*Payments) GetSessionsAtHop

func (n *Payments) GetSessionsAtHop(hop byte) (s Sessions)

func (*Payments) IterateSessions

func (n *Payments) IterateSessions(fn func(s *Session) bool)

type PendingPayments

type PendingPayments []*payment.Payment

func (PendingPayments) Add

func (PendingPayments) Delete

func (p PendingPayments) Delete(preimage sha256.Hash) (pp PendingPayments)

func (PendingPayments) Find

func (p PendingPayments) Find(id nonce.ID) (pp *payment.Payment)

func (PendingPayments) FindPreimage

func (p PendingPayments) FindPreimage(pi sha256.Hash) (pp *payment.Payment)

type Session

type Session struct {
	ID nonce.ID
	*identity.Peer
	Remaining                 lnwire.MilliSatoshi
	HeaderPrv, PayloadPrv     *prv.Key
	HeaderPub, PayloadPub     *pub.Key
	HeaderBytes, PayloadBytes pub.Bytes
	Preimage                  sha256.Hash
	Hop                       byte
}

A Session keeps track of a connection session. It specifically maintains the account of available bandwidth allocation before it needs to be recharged with new credit, and the current state of the encryption.

func NewSession

func NewSession(
	id nonce.ID,
	node *identity.Peer,
	rem lnwire.MilliSatoshi,
	hdrPrv *prv.Key,
	pldPrv *prv.Key,
	hop byte,
) (s *Session)

NewSession creates a new Session.

Purchasing a session the seller returns a token, based on a requested data allocation.

func (*Session) AddBytes

func (s *Session) AddBytes(b lnwire.MilliSatoshi)

AddBytes adds to the Remaining counter, used when new data allowance has been purchased.

func (*Session) SubtractBytes

func (s *Session) SubtractBytes(b lnwire.MilliSatoshi) bool

SubtractBytes reduces the amount Remaining, if the requested amount would put the total below zero it returns false, signalling that new data allowance needs to be purchased before any further messages can be sent.

type Sessions

type Sessions []*Session

Jump to

Keyboard shortcuts

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