sessions

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Unlicense Imports: 8 Imported by: 0

Documentation

Overview

Package sessions defines some key data structures relating to the data for sessions, imported by sess package for reading and writing session and circuit metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Circuit

type Circuit [5]*Data

A Circuit is the generic fixed-length path used for most messages.

func (Circuit) String

func (c Circuit) String() (o string)

String is a stringer for Circuits that attempts to make them readable as like a table.

type Data

type Data struct {

	// ID is the internal reference used by other data structures referring to this
	// one.
	ID nonce.ID

	// Node is the node.Node that is providing the relaying service.
	Node *node.Node

	// Remaining is the current balance on the session.
	Remaining lnwire.MilliSatoshi

	// Header and Payload are the two key sets used for data relayed for this
	// session. Header keys are embedded in the 3 layer RoutingHeader, and Payload
	// keys are only used to derive the secrets used with the given public sender key
	// that enables the Exit and Hidden Service to encrypt replies that then get
	// unwrapped successively on the return path.
	Header, Payload *crypto.Keys

	// Preimage is essentially the hash of the bytes of the Header and Payload keys.
	// This enables the relay to associate a payment with a session key pair and thus
	// to be able to account the client's usage.
	Preimage sha256.Hash

	// Hop is the position at which this session is used, private and secret to the
	// client. Sessions are prescribed to be used at a given position only, in order
	// to prevent any cross correlations being visible.
	Hop byte
}

A Data 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 NewSessionData

func NewSessionData(
	id nonce.ID,
	node *node.Node,
	rem lnwire.MilliSatoshi,
	hdr, pld *crypto.Keys,
	hop byte,
) (s *Data)

NewSessionData creates a new Data, generating cached public key bytes and preimage.

func (*Data) DecSats

func (s *Data) DecSats(sats lnwire.MilliSatoshi, sender bool,
	typ string) bool

DecSats 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.

func (*Data) IncSats

func (s *Data) IncSats(sats lnwire.MilliSatoshi, sender bool, typ string)

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

func (*Data) String

func (s *Data) String() string

type Sessions

type Sessions []*Data

Sessions are arbitrary length lists of Data.

Jump to

Keyboard shortcuts

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