mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-23 06:35:07 +01:00
Merge pull request #7046 from C-Otto/watchtower-docu-fixes
watchtower: docu fixes
This commit is contained in:
commit
db42e63ab7
6 changed files with 26 additions and 29 deletions
|
@ -266,9 +266,9 @@ type TowerClient struct {
|
||||||
var _ Client = (*TowerClient)(nil)
|
var _ Client = (*TowerClient)(nil)
|
||||||
|
|
||||||
// New initializes a new TowerClient from the provide Config. An error is
|
// New initializes a new TowerClient from the provide Config. An error is
|
||||||
// returned if the client could not initialized.
|
// returned if the client could not be initialized.
|
||||||
func New(config *Config) (*TowerClient, error) {
|
func New(config *Config) (*TowerClient, error) {
|
||||||
// Copy the config to prevent side-effects from modifying both the
|
// Copy the config to prevent side effects from modifying both the
|
||||||
// internal and external version of the Config.
|
// internal and external version of the Config.
|
||||||
cfg := new(Config)
|
cfg := new(Config)
|
||||||
*cfg = *config
|
*cfg = *config
|
||||||
|
@ -739,7 +739,7 @@ func (c *TowerClient) nextSessionQueue() (*sessionQueue, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the session queue and spin it up so it can begin handling
|
// Initialize the session queue and spin it up, so it can begin handling
|
||||||
// updates. If the queue was already made active on startup, this will
|
// updates. If the queue was already made active on startup, this will
|
||||||
// simply return the existing session queue from the set.
|
// simply return the existing session queue from the set.
|
||||||
return c.getOrInitActiveQueue(candidateSession, updates), nil
|
return c.getOrInitActiveQueue(candidateSession, updates), nil
|
||||||
|
@ -934,7 +934,7 @@ func (c *TowerClient) taskAccepted(task *backupTask, newStatus reserveStatus) {
|
||||||
c.log.Debugf("Session %s exhausted", c.sessionQueue.ID())
|
c.log.Debugf("Session %s exhausted", c.sessionQueue.ID())
|
||||||
|
|
||||||
// This task left the session exhausted, set it to nil and
|
// This task left the session exhausted, set it to nil and
|
||||||
// proceed to the next loop so we can consume another
|
// proceed to the next loop, so we can consume another
|
||||||
// pre-negotiated session or request another.
|
// pre-negotiated session or request another.
|
||||||
c.sessionQueue = nil
|
c.sessionQueue = nil
|
||||||
}
|
}
|
||||||
|
@ -1088,7 +1088,7 @@ func (c *TowerClient) newSessionQueue(s *wtdb.ClientSession,
|
||||||
|
|
||||||
// getOrInitActiveQueue checks the activeSessions set for a sessionQueue for the
|
// getOrInitActiveQueue checks the activeSessions set for a sessionQueue for the
|
||||||
// passed ClientSession. If it exists, the active sessionQueue is returned.
|
// passed ClientSession. If it exists, the active sessionQueue is returned.
|
||||||
// Otherwise a new sessionQueue is initialized and added to the set.
|
// Otherwise, a new sessionQueue is initialized and added to the set.
|
||||||
func (c *TowerClient) getOrInitActiveQueue(s *wtdb.ClientSession,
|
func (c *TowerClient) getOrInitActiveQueue(s *wtdb.ClientSession,
|
||||||
updates []wtdb.CommittedUpdate) *sessionQueue {
|
updates []wtdb.CommittedUpdate) *sessionQueue {
|
||||||
|
|
||||||
|
@ -1106,8 +1106,8 @@ func (c *TowerClient) getOrInitActiveQueue(s *wtdb.ClientSession,
|
||||||
func (c *TowerClient) initActiveQueue(s *wtdb.ClientSession,
|
func (c *TowerClient) initActiveQueue(s *wtdb.ClientSession,
|
||||||
updates []wtdb.CommittedUpdate) *sessionQueue {
|
updates []wtdb.CommittedUpdate) *sessionQueue {
|
||||||
|
|
||||||
// Initialize the session queue, providing it with all of the resources
|
// Initialize the session queue, providing it with all the resources it
|
||||||
// it requires from the client instance.
|
// requires from the client instance.
|
||||||
sq := c.newSessionQueue(s, updates)
|
sq := c.newSessionQueue(s, updates)
|
||||||
|
|
||||||
// Add the session queue as an active session so that we remember to
|
// Add the session queue as an active session so that we remember to
|
||||||
|
|
|
@ -57,11 +57,9 @@ type DB interface {
|
||||||
// restarts.
|
// restarts.
|
||||||
CreateClientSession(*wtdb.ClientSession) error
|
CreateClientSession(*wtdb.ClientSession) error
|
||||||
|
|
||||||
// ListClientSessions returns all sessions that have not yet been
|
// ListClientSessions returns the set of all client sessions known to
|
||||||
// exhausted. This is used on startup to find any sessions which may
|
// the db. An optional tower ID can be used to filter out any client
|
||||||
// still be able to accept state updates. An optional tower ID can be
|
// sessions in the response that do not correspond to this tower.
|
||||||
// used to filter out any client sessions in the response that do not
|
|
||||||
// correspond to this tower.
|
|
||||||
ListClientSessions(*wtdb.TowerID, ...wtdb.ClientSessionListOption) (
|
ListClientSessions(*wtdb.TowerID, ...wtdb.ClientSessionListOption) (
|
||||||
map[wtdb.SessionID]*wtdb.ClientSession, error)
|
map[wtdb.SessionID]*wtdb.ClientSession, error)
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ type sessionQueue struct {
|
||||||
shutdown chan struct{}
|
shutdown chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// newSessionQueue intiializes a fresh sessionQueue.
|
// newSessionQueue initializes a fresh sessionQueue.
|
||||||
func newSessionQueue(cfg *sessionQueueConfig,
|
func newSessionQueue(cfg *sessionQueueConfig,
|
||||||
updates []wtdb.CommittedUpdate) *sessionQueue {
|
updates []wtdb.CommittedUpdate) *sessionQueue {
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ func (q *sessionQueue) sessionManager() {
|
||||||
}
|
}
|
||||||
q.queueCond.L.Unlock()
|
q.queueCond.L.Unlock()
|
||||||
|
|
||||||
// Exit immediately if a force quit has been requested. If the
|
// Exit immediately if a force quit has been requested. If
|
||||||
// either of the queues still has state updates to send to the
|
// either of the queues still has state updates to send to the
|
||||||
// tower, we may never exit in the above case if we are unable
|
// tower, we may never exit in the above case if we are unable
|
||||||
// to reach the tower for some reason.
|
// to reach the tower for some reason.
|
||||||
|
@ -314,7 +314,7 @@ func (q *sessionQueue) drainBackups() {
|
||||||
// Init.
|
// Init.
|
||||||
for sendInit := true; ; sendInit = false {
|
for sendInit := true; ; sendInit = false {
|
||||||
// Generate the next state update to upload to the tower. This
|
// Generate the next state update to upload to the tower. This
|
||||||
// method will first proceed in dequeueing committed updates
|
// method will first proceed in dequeuing committed updates
|
||||||
// before attempting to dequeue any pending updates.
|
// before attempting to dequeue any pending updates.
|
||||||
stateUpdate, isPending, backupID, err := q.nextStateUpdate()
|
stateUpdate, isPending, backupID, err := q.nextStateUpdate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -480,8 +480,8 @@ func (q *sessionQueue) nextStateUpdate() (*wtwire.StateUpdate, bool,
|
||||||
// the ACK before returning. If sendInit is true, this method will first send
|
// the ACK before returning. If sendInit is true, this method will first send
|
||||||
// the localInit message and verify that the tower supports our required feature
|
// the localInit message and verify that the tower supports our required feature
|
||||||
// bits. And error is returned if any part of the send fails. The boolean return
|
// bits. And error is returned if any part of the send fails. The boolean return
|
||||||
// variable indicates whether or not we should back off before attempting to
|
// variable indicates whether we should back off before attempting to send the
|
||||||
// send the next state update.
|
// next state update.
|
||||||
func (q *sessionQueue) sendStateUpdate(conn wtserver.Peer,
|
func (q *sessionQueue) sendStateUpdate(conn wtserver.Peer,
|
||||||
stateUpdate *wtwire.StateUpdate, localInit *wtwire.Init,
|
stateUpdate *wtwire.StateUpdate, localInit *wtwire.Init,
|
||||||
sendInit, isPending bool) error {
|
sendInit, isPending bool) error {
|
||||||
|
@ -598,10 +598,10 @@ func (q *sessionQueue) sendStateUpdate(conn wtserver.Peer,
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// reserveStatus returns a reserveStatus indicating whether or not the
|
// reserveStatus returns a reserveStatus indicating whether the sessionQueue can
|
||||||
// sessionQueue can accept another task. reserveAvailable is returned when a
|
// accept another task. reserveAvailable is returned when a task can be
|
||||||
// task can be accepted, and reserveExhausted is returned if the all slots in
|
// accepted, and reserveExhausted is returned if the all slots in the session
|
||||||
// the session have been allocated.
|
// have been allocated.
|
||||||
//
|
//
|
||||||
// NOTE: This method MUST be called with queueCond's exclusive lock held.
|
// NOTE: This method MUST be called with queueCond's exclusive lock held.
|
||||||
func (q *sessionQueue) reserveStatus() reserveStatus {
|
func (q *sessionQueue) reserveStatus() reserveStatus {
|
||||||
|
|
|
@ -31,7 +31,7 @@ type ClientStats struct {
|
||||||
NumSessionsExhausted int
|
NumSessionsExhausted int
|
||||||
}
|
}
|
||||||
|
|
||||||
// taskReceived increments the number to backup requests the client has received
|
// taskReceived increments the number of backup requests the client has received
|
||||||
// from active channels.
|
// from active channels.
|
||||||
func (s *ClientStats) taskReceived() {
|
func (s *ClientStats) taskReceived() {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
|
@ -74,7 +74,7 @@ func (s *ClientStats) sessionExhausted() {
|
||||||
s.NumSessionsExhausted++
|
s.NumSessionsExhausted++
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns a human readable summary of the client's metrics.
|
// String returns a human-readable summary of the client's metrics.
|
||||||
func (s *ClientStats) String() string {
|
func (s *ClientStats) String() string {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
defer s.mu.Unlock()
|
||||||
|
|
|
@ -1147,7 +1147,7 @@ func (c *ClientDB) AckUpdate(id *SessionID, seqNum uint16,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that the session acks sub-bucket is initialized so we
|
// Ensure that the session acks sub-bucket is initialized, so we
|
||||||
// can insert an entry.
|
// can insert an entry.
|
||||||
sessionAcks, err := sessionBkt.CreateBucketIfNotExists(
|
sessionAcks, err := sessionBkt.CreateBucketIfNotExists(
|
||||||
cSessionAcks,
|
cSessionAcks,
|
||||||
|
|
|
@ -15,8 +15,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// DeleteSessionReply is a message sent in response to a client's DeleteSession
|
// DeleteSessionReply is a message sent in response to a client's DeleteSession
|
||||||
// request. The message indicates whether or not the deletion was a success or
|
// request. The message indicates whether the deletion was a success or failure.
|
||||||
// failure.
|
|
||||||
type DeleteSessionReply struct {
|
type DeleteSessionReply struct {
|
||||||
// Code will be non-zero if the watchtower was not able to delete the
|
// Code will be non-zero if the watchtower was not able to delete the
|
||||||
// requested session.
|
// requested session.
|
||||||
|
|
Loading…
Add table
Reference in a new issue