session

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Unlicense Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

type Session struct {
	nonce.ID
	*node.Node
	Remaining                 uint64
	HeaderPub, PayloadPub     *pub.Key
	HeaderBytes, PayloadBytes pub.Bytes
	HeaderPrv, PayloadPrv     *prv.Key
	Deadline                  time.Time
}

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, rem uint64, deadline time.Duration) (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 uint64)

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

func (*Session) SubtractBytes

func (s *Session) SubtractBytes(b uint64) 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

func (Sessions) Add

func (s Sessions) Add(se *Session) Sessions

func (Sessions) Delete

func (s Sessions) Delete(se *Session) Sessions

func (Sessions) Find

func (s Sessions) Find(t nonce.ID) (se *Session)

func (Sessions) FindPub

func (s Sessions) FindPub(pubKey *pub.Key) (se *Session)

func (Sessions) Len

func (s Sessions) Len() int

Jump to

Keyboard shortcuts

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