sess

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: Unlicense Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StandardCircuit

func StandardCircuit() []byte

StandardCircuit is a slice defining a standard circuit (5 is the return session).

Types

type CircuitCache

type CircuitCache map[nonce.ID]*sessions.Circuit

A CircuitCache stores each of the 5 hops of a peer node.

func (CircuitCache) Add

type Data

type Data struct {
	B        slice.Bytes
	Sessions sessions.Sessions
	Billable []crypto.PubBytes
	Ret      crypto.PubBytes
	ID       nonce.ID
	Port     uint16
	PostAcct []func()
}

type Manager

type Manager struct {
	PendingPayments payments.PendingPayments
	sessions.Sessions
	CircuitCache
	sync.Mutex
	// contains filtered or unexported fields
}

Manager is a session manager for Indra, handling sessions and services.

func NewSessionManager

func NewSessionManager() *Manager

NewSessionManager creates a new session manager.

func (*Manager) AddNodes

func (sm *Manager) AddNodes(nn ...*node.Node)

AddNodes adds a Node to a Nodes.

func (*Manager) AddPendingPayment

func (sm *Manager) AddPendingPayment(np *payments.Payment)

AddPendingPayment adds a received incoming payment message to await the session keys.

func (*Manager) AddServiceToLocalNode

func (sm *Manager) AddServiceToLocalNode(s *services.Service) (e error)

AddServiceToLocalNode adds a service to the local node.

func (*Manager) AddSession

func (sm *Manager) AddSession(s *sessions.Data)

AddSession adds a session to the session cache.

func (*Manager) ClearPendingPayments

func (sm *Manager) ClearPendingPayments()

ClearPendingPayments is used only for debugging, removing all pending payments, making the engine forget about payments it received.

func (*Manager) ClearSessions

func (sm *Manager) ClearSessions()

ClearSessions is used only for debugging, removing all but the first session, which is the engine's initial return session.

func (*Manager) DecSession

func (sm *Manager) DecSession(id crypto.PubBytes, msats int, sender bool,
	typ string) bool

DecSession decrements credit (mSat) on a session.

func (*Manager) DeleteNodeAndSessions

func (sm *Manager) DeleteNodeAndSessions(id nonce.ID)

DeleteNodeAndSessions deletes a node and all the sessions for it.

func (*Manager) DeleteNodeByAddrPort

func (sm *Manager) DeleteNodeByAddrPort(ip *netip.AddrPort) (e error)

DeleteNodeByAddrPort deletes a node identified by a netip.AddrPort.

func (*Manager) DeleteNodeByID

func (sm *Manager) DeleteNodeByID(ii nonce.ID) (e error)

DeleteNodeByID deletes a node identified by an Keys.

func (*Manager) DeletePendingPayment

func (sm *Manager) DeletePendingPayment(preimage sha256.Hash)

DeletePendingPayment deletes a pending payment by the preimage hash.

func (*Manager) DeleteSession

func (sm *Manager) DeleteSession(id crypto.PubBytes)

func (*Manager) FindCloaked

func (sm *Manager) FindCloaked(clk crypto.CloakedPubKey) (hdr *crypto.Prv,
	pld *crypto.Prv, sess *sessions.Data, identity bool)

FindCloaked searches the client identity key and the sessions for a match. It returns the session as well, though not all users of this function will need this.

func (*Manager) FindNodeByAddrPort

func (sm *Manager) FindNodeByAddrPort(id *netip.AddrPort) (no *node.Node)

FindNodeByAddrPort searches for a Node by netip.AddrPort.

func (*Manager) FindNodeByID

func (sm *Manager) FindNodeByID(i nonce.ID) (no *node.Node)

FindNodeByID searches for a Node by Keys.

func (*Manager) FindNodeByIdentity

func (sm *Manager) FindNodeByIdentity(id *crypto.Pub) (no *node.Node)

FindNodeByIdentity searches for a Node by netip.AddrPort.

func (*Manager) FindNodeByIndex

func (sm *Manager) FindNodeByIndex(i int) (no *node.Node)

FindNodeByIndex returns the node at a given position in the array.

func (*Manager) FindPendingPayment

func (sm *Manager) FindPendingPayment(id nonce.ID) (pp *payments.Payment)

FindPendingPayment searches for a pending payment with the matching ID.

func (*Manager) FindPendingPreimage

func (sm *Manager) FindPendingPreimage(pi sha256.Hash) (pp *payments.Payment)

FindPendingPreimage searches for a pending payment with e matching preimage.

func (*Manager) FindSessionByHeader

func (sm *Manager) FindSessionByHeader(prvKey *crypto.Prv) *sessions.Data

FindSessionByHeader searches for a session with a matching header private key.

func (*Manager) FindSessionByHeaderPub

func (sm *Manager) FindSessionByHeaderPub(pubKey *crypto.Pub) *sessions.Data

FindSessionByHeaderPub searches for a session with a matching header public key.

func (*Manager) FindSessionByPubkey

func (sm *Manager) FindSessionByPubkey(id crypto.PubBytes) *sessions.Data

FindSessionByPubkey searches for a session with a matching public key.

func (*Manager) FindSessionPreimage

func (sm *Manager) FindSessionPreimage(pr sha256.Hash) *sessions.Data

FindSessionPreimage searches for a session with a matching preimage hash.

func (*Manager) ForEachNode

func (sm *Manager) ForEachNode(fn func(n *node.Node) bool)

ForEachNode runs a function over the slice of nodes with the mutex locked, and terminates when the function returns true.

Do not call any Manager methods above inside this function or there will be a mutex double locking panic, except GetLocalNode.

func (*Manager) GetLocalNode

func (sm *Manager) GetLocalNode() *node.Node

GetLocalNode returns the engine's local Node.

func (*Manager) GetLocalNodeAddress

func (sm *Manager) GetLocalNodeAddress() (addr *netip.AddrPort)

GetLocalNodeAddress returns the AddrPort of the local node.

func (*Manager) GetLocalNodeAddressString

func (sm *Manager) GetLocalNodeAddressString() (s string)

GetLocalNodeAddressString returns the string form of the local node address.

func (*Manager) GetLocalNodeIdentityBytes

func (sm *Manager) GetLocalNodeIdentityBytes() (ident crypto.PubBytes)

GetLocalNodeIdentityBytes returns the public key bytes of the local node.

func (*Manager) GetLocalNodeIdentityPrv

func (sm *Manager) GetLocalNodeIdentityPrv() (ident *crypto.Prv)

GetLocalNodeIdentityPrv returns the identity private key of the local node.

func (*Manager) GetLocalNodePaymentChan

func (sm *Manager) GetLocalNodePaymentChan() payments.PayChan

GetLocalNodePaymentChan returns the engine's local Node PayChan.

func (*Manager) GetLocalNodeRelayRate

func (sm *Manager) GetLocalNodeRelayRate() (rate uint32)

GetLocalNodeRelayRate returns the relay rate for the local node.

func (*Manager) GetNodeCircuit

func (sm *Manager) GetNodeCircuit(id nonce.ID) (sce *sessions.Circuit,
	exists bool)

GetNodeCircuit gets the set of 5 sessions associated with a node with a given ID.

func (*Manager) GetSessionByIndex

func (sm *Manager) GetSessionByIndex(i int) (s *sessions.Data)

GetSessionByIndex returns the session with the given index in the main session cache.

func (*Manager) GetSessionsAtHop

func (sm *Manager) GetSessionsAtHop(hop byte) (s sessions.Sessions)

GetSessionsAtHop returns all of the sessions designated for a given hop in the circuit.

func (*Manager) IncSession

func (sm *Manager) IncSession(id crypto.PubBytes, msats lnwire.MilliSatoshi,
	sender bool, typ string)

IncSession adds an amount of mSat to the balance of a session.

func (*Manager) IterateSessionCache

func (sm *Manager) IterateSessionCache(fn func(n *node.Node,
	c *sessions.Circuit) bool)

IterateSessionCache calls a function for each entry in the CircuitCache that provides also access to the related node.

Do not call Manager methods within this function.

func (*Manager) IterateSessions

func (sm *Manager) IterateSessions(fn func(s *sessions.Data) bool)

IterateSessions calls a function for each entry in the Sessions slice.

Do not call Manager methods within this function.

func (*Manager) NodesLen

func (sm *Manager) NodesLen() int

NodesLen returns the length of a Nodes.

func (*Manager) ReceiveToLocalNode

func (sm *Manager) ReceiveToLocalNode() <-chan slice.Bytes

ReceiveToLocalNode returns a channel that will receive messages for the local node, that arrived from the internet.

func (*Manager) SelectHops

func (sm *Manager) SelectHops(hops []byte, alreadyHave sessions.Sessions,
	note string) (so sessions.Sessions)

SelectHops picks out a set of sessions to use in a circuit.

func (*Manager) SelectUnusedCircuit

func (sm *Manager) SelectUnusedCircuit() (c [5]*node.Node)

SelectUnusedCircuit accepts an array of 5 Node entries where all or some are empty and picks nodes for the remainder that do not have a hop at that position.

func (*Manager) Send

func (sm *Manager) Send(addr *netip.AddrPort, s *splice.Splice)

Send a message to a peer via their AddrPort.

func (*Manager) SendFromLocalNode

func (sm *Manager) SendFromLocalNode(port uint16,
	b slice.Bytes) (e error)

SendFromLocalNode delivers a message to a local service.

func (*Manager) SendWithOneHook

func (sm *Manager) SendWithOneHook(ap *netip.AddrPort,
	res *Data, responseHook responses.Callback, p *responses.Pending)

SendWithOneHook is used for onions with only one confirmation hook. Usually as returned from PostAcctOnion this is the last, confirmation or response layer in an onion.Skins.

func (*Manager) SetLocalNode

func (sm *Manager) SetLocalNode(n *node.Node)

SetLocalNode sets the engine's local Node.

func (*Manager) SetLocalNodeAddress

func (sm *Manager) SetLocalNodeAddress(addr *netip.AddrPort)

SetLocalNodeAddress changes the local node address.

func (*Manager) UpdateSessionCache

func (sm *Manager) UpdateSessionCache()

UpdateSessionCache reads the main Sessions cache and populates the CircuitCache where circuits are aggregated.

Jump to

Keyboard shortcuts

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