id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
129,500
lightningnetwork/lnd
lnwire/onion_error.go
NewAmountBelowMinimum
func NewAmountBelowMinimum(htlcMsat MilliSatoshi, update ChannelUpdate) *FailAmountBelowMinimum { return &FailAmountBelowMinimum{ HtlcMsat: htlcMsat, Update: update, } }
go
func NewAmountBelowMinimum(htlcMsat MilliSatoshi, update ChannelUpdate) *FailAmountBelowMinimum { return &FailAmountBelowMinimum{ HtlcMsat: htlcMsat, Update: update, } }
[ "func", "NewAmountBelowMinimum", "(", "htlcMsat", "MilliSatoshi", ",", "update", "ChannelUpdate", ")", "*", "FailAmountBelowMinimum", "{", "return", "&", "FailAmountBelowMinimum", "{", "HtlcMsat", ":", "htlcMsat", ",", "Update", ":", "update", ",", "}", "\n", "}" ...
// NewAmountBelowMinimum creates new instance of the FailAmountBelowMinimum.
[ "NewAmountBelowMinimum", "creates", "new", "instance", "of", "the", "FailAmountBelowMinimum", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/onion_error.go#L672-L679
129,501
lightningnetwork/lnd
lnwire/onion_error.go
NewFeeInsufficient
func NewFeeInsufficient(htlcMsat MilliSatoshi, update ChannelUpdate) *FailFeeInsufficient { return &FailFeeInsufficient{ HtlcMsat: htlcMsat, Update: update, } }
go
func NewFeeInsufficient(htlcMsat MilliSatoshi, update ChannelUpdate) *FailFeeInsufficient { return &FailFeeInsufficient{ HtlcMsat: htlcMsat, Update: update, } }
[ "func", "NewFeeInsufficient", "(", "htlcMsat", "MilliSatoshi", ",", "update", "ChannelUpdate", ")", "*", "FailFeeInsufficient", "{", "return", "&", "FailFeeInsufficient", "{", "HtlcMsat", ":", "htlcMsat", ",", "Update", ":", "update", ",", "}", "\n", "}" ]
// NewFeeInsufficient creates new instance of the FailFeeInsufficient.
[ "NewFeeInsufficient", "creates", "new", "instance", "of", "the", "FailFeeInsufficient", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/onion_error.go#L741-L747
129,502
lightningnetwork/lnd
lnwire/onion_error.go
NewIncorrectCltvExpiry
func NewIncorrectCltvExpiry(cltvExpiry uint32, update ChannelUpdate) *FailIncorrectCltvExpiry { return &FailIncorrectCltvExpiry{ CltvExpiry: cltvExpiry, Update: update, } }
go
func NewIncorrectCltvExpiry(cltvExpiry uint32, update ChannelUpdate) *FailIncorrectCltvExpiry { return &FailIncorrectCltvExpiry{ CltvExpiry: cltvExpiry, Update: update, } }
[ "func", "NewIncorrectCltvExpiry", "(", "cltvExpiry", "uint32", ",", "update", "ChannelUpdate", ")", "*", "FailIncorrectCltvExpiry", "{", "return", "&", "FailIncorrectCltvExpiry", "{", "CltvExpiry", ":", "cltvExpiry", ",", "Update", ":", "update", ",", "}", "\n", "...
// NewIncorrectCltvExpiry creates new instance of the FailIncorrectCltvExpiry.
[ "NewIncorrectCltvExpiry", "creates", "new", "instance", "of", "the", "FailIncorrectCltvExpiry", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/onion_error.go#L811-L818
129,503
lightningnetwork/lnd
lnwire/onion_error.go
NewChannelDisabled
func NewChannelDisabled(flags uint16, update ChannelUpdate) *FailChannelDisabled { return &FailChannelDisabled{ Flags: flags, Update: update, } }
go
func NewChannelDisabled(flags uint16, update ChannelUpdate) *FailChannelDisabled { return &FailChannelDisabled{ Flags: flags, Update: update, } }
[ "func", "NewChannelDisabled", "(", "flags", "uint16", ",", "update", "ChannelUpdate", ")", "*", "FailChannelDisabled", "{", "return", "&", "FailChannelDisabled", "{", "Flags", ":", "flags", ",", "Update", ":", "update", ",", "}", "\n", "}" ]
// NewChannelDisabled creates new instance of the FailChannelDisabled.
[ "NewChannelDisabled", "creates", "new", "instance", "of", "the", "FailChannelDisabled", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/onion_error.go#L931-L936
129,504
lightningnetwork/lnd
lnwire/onion_error.go
DecodeFailure
func DecodeFailure(r io.Reader, pver uint32) (FailureMessage, error) { // First, we'll parse out the encapsulated failure message itself. This // is a 2 byte length followed by the payload itself. var failureLength uint16 if err := ReadElement(r, &failureLength); err != nil { return nil, fmt.Errorf("unable to rea...
go
func DecodeFailure(r io.Reader, pver uint32) (FailureMessage, error) { // First, we'll parse out the encapsulated failure message itself. This // is a 2 byte length followed by the payload itself. var failureLength uint16 if err := ReadElement(r, &failureLength); err != nil { return nil, fmt.Errorf("unable to rea...
[ "func", "DecodeFailure", "(", "r", "io", ".", "Reader", ",", "pver", "uint32", ")", "(", "FailureMessage", ",", "error", ")", "{", "// First, we'll parse out the encapsulated failure message itself. This", "// is a 2 byte length followed by the payload itself.", "var", "failu...
// DecodeFailure decodes, validates, and parses the lnwire onion failure, for // the provided protocol version.
[ "DecodeFailure", "decodes", "validates", "and", "parses", "the", "lnwire", "onion", "failure", "for", "the", "provided", "protocol", "version", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/onion_error.go#L1097-L1143
129,505
lightningnetwork/lnd
lnwire/onion_error.go
EncodeFailure
func EncodeFailure(w io.Writer, failure FailureMessage, pver uint32) error { var failureMessageBuffer bytes.Buffer // First, we'll write out the error code itself into the failure // buffer. var codeBytes [2]byte code := uint16(failure.Code()) binary.BigEndian.PutUint16(codeBytes[:], code) _, err := failureMess...
go
func EncodeFailure(w io.Writer, failure FailureMessage, pver uint32) error { var failureMessageBuffer bytes.Buffer // First, we'll write out the error code itself into the failure // buffer. var codeBytes [2]byte code := uint16(failure.Code()) binary.BigEndian.PutUint16(codeBytes[:], code) _, err := failureMess...
[ "func", "EncodeFailure", "(", "w", "io", ".", "Writer", ",", "failure", "FailureMessage", ",", "pver", "uint32", ")", "error", "{", "var", "failureMessageBuffer", "bytes", ".", "Buffer", "\n\n", "// First, we'll write out the error code itself into the failure", "// buf...
// EncodeFailure encodes, including the necessary onion failure header // information.
[ "EncodeFailure", "encodes", "including", "the", "necessary", "onion", "failure", "header", "information", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/onion_error.go#L1147-L1188
129,506
lightningnetwork/lnd
lnwire/onion_error.go
makeEmptyOnionError
func makeEmptyOnionError(code FailCode) (FailureMessage, error) { switch code { case CodeInvalidRealm: return &FailInvalidRealm{}, nil case CodeTemporaryNodeFailure: return &FailTemporaryNodeFailure{}, nil case CodePermanentNodeFailure: return &FailPermanentNodeFailure{}, nil case CodeRequiredNodeFeatureM...
go
func makeEmptyOnionError(code FailCode) (FailureMessage, error) { switch code { case CodeInvalidRealm: return &FailInvalidRealm{}, nil case CodeTemporaryNodeFailure: return &FailTemporaryNodeFailure{}, nil case CodePermanentNodeFailure: return &FailPermanentNodeFailure{}, nil case CodeRequiredNodeFeatureM...
[ "func", "makeEmptyOnionError", "(", "code", "FailCode", ")", "(", "FailureMessage", ",", "error", ")", "{", "switch", "code", "{", "case", "CodeInvalidRealm", ":", "return", "&", "FailInvalidRealm", "{", "}", ",", "nil", "\n\n", "case", "CodeTemporaryNodeFailure...
// makeEmptyOnionError creates a new empty onion error of the proper concrete // type based on the passed failure code.
[ "makeEmptyOnionError", "creates", "a", "new", "empty", "onion", "error", "of", "the", "proper", "concrete", "type", "based", "on", "the", "passed", "failure", "code", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/onion_error.go#L1192-L1263
129,507
lightningnetwork/lnd
lnwire/onion_error.go
writeOnionErrorChanUpdate
func writeOnionErrorChanUpdate(w io.Writer, chanUpdate *ChannelUpdate, pver uint32) error { // First, we encode the channel update in a temporary buffer in order // to get the exact serialized size. var b bytes.Buffer if err := chanUpdate.Encode(&b, pver); err != nil { return err } // Now that we know the si...
go
func writeOnionErrorChanUpdate(w io.Writer, chanUpdate *ChannelUpdate, pver uint32) error { // First, we encode the channel update in a temporary buffer in order // to get the exact serialized size. var b bytes.Buffer if err := chanUpdate.Encode(&b, pver); err != nil { return err } // Now that we know the si...
[ "func", "writeOnionErrorChanUpdate", "(", "w", "io", ".", "Writer", ",", "chanUpdate", "*", "ChannelUpdate", ",", "pver", "uint32", ")", "error", "{", "// First, we encode the channel update in a temporary buffer in order", "// to get the exact serialized size.", "var", "b", ...
// writeOnionErrorChanUpdate writes out a ChannelUpdate using the onion error // format. The format is that we first write out the true serialized length of // the channel update, followed by the serialized channel update itself.
[ "writeOnionErrorChanUpdate", "writes", "out", "a", "ChannelUpdate", "using", "the", "onion", "error", "format", ".", "The", "format", "is", "that", "we", "first", "write", "out", "the", "true", "serialized", "length", "of", "the", "channel", "update", "followed"...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/onion_error.go#L1268-L1292
129,508
lightningnetwork/lnd
lnrpc/chainrpc/driver.go
createNewSubServer
func createNewSubServer(configRegistry lnrpc.SubServerConfigDispatcher) ( lnrpc.SubServer, lnrpc.MacaroonPerms, error) { // We'll attempt to look up the config that we expect, according to our // subServerName name. If we can't find this, then we'll exit with an // error, as we're unable to properly initialize our...
go
func createNewSubServer(configRegistry lnrpc.SubServerConfigDispatcher) ( lnrpc.SubServer, lnrpc.MacaroonPerms, error) { // We'll attempt to look up the config that we expect, according to our // subServerName name. If we can't find this, then we'll exit with an // error, as we're unable to properly initialize our...
[ "func", "createNewSubServer", "(", "configRegistry", "lnrpc", ".", "SubServerConfigDispatcher", ")", "(", "lnrpc", ".", "SubServer", ",", "lnrpc", ".", "MacaroonPerms", ",", "error", ")", "{", "// We'll attempt to look up the config that we expect, according to our", "// su...
// createNewSubServer is a helper method that will create the new chain notifier // sub server given the main config dispatcher method. If we're unable to find // the config that is meant for us in the config dispatcher, then we'll exit // with an error.
[ "createNewSubServer", "is", "a", "helper", "method", "that", "will", "create", "the", "new", "chain", "notifier", "sub", "server", "given", "the", "main", "config", "dispatcher", "method", ".", "If", "we", "re", "unable", "to", "find", "the", "config", "that...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnrpc/chainrpc/driver.go#L15-L53
129,509
lightningnetwork/lnd
lnwire/query_short_chan_ids.go
NewQueryShortChanIDs
func NewQueryShortChanIDs(h chainhash.Hash, e ShortChanIDEncoding, s []ShortChannelID) *QueryShortChanIDs { return &QueryShortChanIDs{ ChainHash: h, EncodingType: e, ShortChanIDs: s, } }
go
func NewQueryShortChanIDs(h chainhash.Hash, e ShortChanIDEncoding, s []ShortChannelID) *QueryShortChanIDs { return &QueryShortChanIDs{ ChainHash: h, EncodingType: e, ShortChanIDs: s, } }
[ "func", "NewQueryShortChanIDs", "(", "h", "chainhash", ".", "Hash", ",", "e", "ShortChanIDEncoding", ",", "s", "[", "]", "ShortChannelID", ")", "*", "QueryShortChanIDs", "{", "return", "&", "QueryShortChanIDs", "{", "ChainHash", ":", "h", ",", "EncodingType", ...
// NewQueryShortChanIDs creates a new QueryShortChanIDs message.
[ "NewQueryShortChanIDs", "creates", "a", "new", "QueryShortChanIDs", "message", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/query_short_chan_ids.go#L73-L81
129,510
lightningnetwork/lnd
lnwire/query_short_chan_ids.go
Decode
func (q *QueryShortChanIDs) Decode(r io.Reader, pver uint32) error { err := ReadElements(r, q.ChainHash[:]) if err != nil { return err } q.EncodingType, q.ShortChanIDs, err = decodeShortChanIDs(r) return err }
go
func (q *QueryShortChanIDs) Decode(r io.Reader, pver uint32) error { err := ReadElements(r, q.ChainHash[:]) if err != nil { return err } q.EncodingType, q.ShortChanIDs, err = decodeShortChanIDs(r) return err }
[ "func", "(", "q", "*", "QueryShortChanIDs", ")", "Decode", "(", "r", "io", ".", "Reader", ",", "pver", "uint32", ")", "error", "{", "err", ":=", "ReadElements", "(", "r", ",", "q", ".", "ChainHash", "[", ":", "]", ")", "\n", "if", "err", "!=", "n...
// Decode deserializes a serialized QueryShortChanIDs message stored in the // passed io.Reader observing the specified protocol version. // // This is part of the lnwire.Message interface.
[ "Decode", "deserializes", "a", "serialized", "QueryShortChanIDs", "message", "stored", "in", "the", "passed", "io", ".", "Reader", "observing", "the", "specified", "protocol", "version", ".", "This", "is", "part", "of", "the", "lnwire", ".", "Message", "interfac...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/query_short_chan_ids.go#L91-L100
129,511
lightningnetwork/lnd
lnwire/query_short_chan_ids.go
decodeShortChanIDs
func decodeShortChanIDs(r io.Reader) (ShortChanIDEncoding, []ShortChannelID, error) { // First, we'll attempt to read the number of bytes in the body of the // set of encoded short channel ID's. var numBytesResp uint16 err := ReadElements(r, &numBytesResp) if err != nil { return 0, nil, err } if numBytesResp ...
go
func decodeShortChanIDs(r io.Reader) (ShortChanIDEncoding, []ShortChannelID, error) { // First, we'll attempt to read the number of bytes in the body of the // set of encoded short channel ID's. var numBytesResp uint16 err := ReadElements(r, &numBytesResp) if err != nil { return 0, nil, err } if numBytesResp ...
[ "func", "decodeShortChanIDs", "(", "r", "io", ".", "Reader", ")", "(", "ShortChanIDEncoding", ",", "[", "]", "ShortChannelID", ",", "error", ")", "{", "// First, we'll attempt to read the number of bytes in the body of the", "// set of encoded short channel ID's.", "var", "...
// decodeShortChanIDs decodes a set of short channel ID's that have been // encoded. The first byte of the body details how the short chan ID's were // encoded. We'll use this type to govern exactly how we go about encoding the // set of short channel ID's.
[ "decodeShortChanIDs", "decodes", "a", "set", "of", "short", "channel", "ID", "s", "that", "have", "been", "encoded", ".", "The", "first", "byte", "of", "the", "body", "details", "how", "the", "short", "chan", "ID", "s", "were", "encoded", ".", "We", "ll"...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/query_short_chan_ids.go#L106-L241
129,512
lightningnetwork/lnd
lnwire/query_short_chan_ids.go
Encode
func (q *QueryShortChanIDs) Encode(w io.Writer, pver uint32) error { // First, we'll write out the chain hash. err := WriteElements(w, q.ChainHash[:]) if err != nil { return err } // Base on our encoding type, we'll write out the set of short channel // ID's. return encodeShortChanIDs(w, q.EncodingType, q.Sho...
go
func (q *QueryShortChanIDs) Encode(w io.Writer, pver uint32) error { // First, we'll write out the chain hash. err := WriteElements(w, q.ChainHash[:]) if err != nil { return err } // Base on our encoding type, we'll write out the set of short channel // ID's. return encodeShortChanIDs(w, q.EncodingType, q.Sho...
[ "func", "(", "q", "*", "QueryShortChanIDs", ")", "Encode", "(", "w", "io", ".", "Writer", ",", "pver", "uint32", ")", "error", "{", "// First, we'll write out the chain hash.", "err", ":=", "WriteElements", "(", "w", ",", "q", ".", "ChainHash", "[", ":", "...
// Encode serializes the target QueryShortChanIDs into the passed io.Writer // observing the protocol version specified. // // This is part of the lnwire.Message interface.
[ "Encode", "serializes", "the", "target", "QueryShortChanIDs", "into", "the", "passed", "io", ".", "Writer", "observing", "the", "protocol", "version", "specified", ".", "This", "is", "part", "of", "the", "lnwire", ".", "Message", "interface", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/query_short_chan_ids.go#L247-L257
129,513
lightningnetwork/lnd
lnwire/query_short_chan_ids.go
encodeShortChanIDs
func encodeShortChanIDs(w io.Writer, encodingType ShortChanIDEncoding, shortChanIDs []ShortChannelID) error { // For both of the current encoding types, the channel ID's are to be // sorted in place, so we'll do that now. sort.Slice(shortChanIDs, func(i, j int) bool { return shortChanIDs[i].ToUint64() < short...
go
func encodeShortChanIDs(w io.Writer, encodingType ShortChanIDEncoding, shortChanIDs []ShortChannelID) error { // For both of the current encoding types, the channel ID's are to be // sorted in place, so we'll do that now. sort.Slice(shortChanIDs, func(i, j int) bool { return shortChanIDs[i].ToUint64() < short...
[ "func", "encodeShortChanIDs", "(", "w", "io", ".", "Writer", ",", "encodingType", "ShortChanIDEncoding", ",", "shortChanIDs", "[", "]", "ShortChannelID", ")", "error", "{", "// For both of the current encoding types, the channel ID's are to be", "// sorted in place, so we'll do...
// encodeShortChanIDs encodes the passed short channel ID's into the passed // io.Writer, respecting the specified encoding type.
[ "encodeShortChanIDs", "encodes", "the", "passed", "short", "channel", "ID", "s", "into", "the", "passed", "io", ".", "Writer", "respecting", "the", "specified", "encoding", "type", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/query_short_chan_ids.go#L261-L355
129,514
lightningnetwork/lnd
pool/read.go
NewRead
func NewRead(readBufferPool *ReadBuffer, numWorkers int, workerTimeout time.Duration) *Read { r := &Read{ bufferPool: readBufferPool, } r.workerPool = NewWorker(&WorkerConfig{ NewWorkerState: r.newWorkerState, NumWorkers: numWorkers, WorkerTimeout: workerTimeout, }) return r }
go
func NewRead(readBufferPool *ReadBuffer, numWorkers int, workerTimeout time.Duration) *Read { r := &Read{ bufferPool: readBufferPool, } r.workerPool = NewWorker(&WorkerConfig{ NewWorkerState: r.newWorkerState, NumWorkers: numWorkers, WorkerTimeout: workerTimeout, }) return r }
[ "func", "NewRead", "(", "readBufferPool", "*", "ReadBuffer", ",", "numWorkers", "int", ",", "workerTimeout", "time", ".", "Duration", ")", "*", "Read", "{", "r", ":=", "&", "Read", "{", "bufferPool", ":", "readBufferPool", ",", "}", "\n", "r", ".", "work...
// NewRead creates a new Read pool, using an underlying ReadBuffer pool to // recycle buffer.Read objects across the lifetime of the Read pool's workers.
[ "NewRead", "creates", "a", "new", "Read", "pool", "using", "an", "underlying", "ReadBuffer", "pool", "to", "recycle", "buffer", ".", "Read", "objects", "across", "the", "lifetime", "of", "the", "Read", "pool", "s", "workers", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/pool/read.go#L19-L32
129,515
lightningnetwork/lnd
pool/read.go
Submit
func (r *Read) Submit(inner func(*buffer.Read) error) error { return r.workerPool.Submit(func(s WorkerState) error { state := s.(*readWorkerState) return inner(state.readBuf) }) }
go
func (r *Read) Submit(inner func(*buffer.Read) error) error { return r.workerPool.Submit(func(s WorkerState) error { state := s.(*readWorkerState) return inner(state.readBuf) }) }
[ "func", "(", "r", "*", "Read", ")", "Submit", "(", "inner", "func", "(", "*", "buffer", ".", "Read", ")", "error", ")", "error", "{", "return", "r", ".", "workerPool", ".", "Submit", "(", "func", "(", "s", "WorkerState", ")", "error", "{", "state",...
// Submit accepts a function closure that provides access to the fresh // buffer.Read object. The function's execution will be allocated to one of the // underlying Worker pool's goroutines.
[ "Submit", "accepts", "a", "function", "closure", "that", "provides", "access", "to", "the", "fresh", "buffer", ".", "Read", "object", ".", "The", "function", "s", "execution", "will", "be", "allocated", "to", "one", "of", "the", "underlying", "Worker", "pool...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/pool/read.go#L47-L52
129,516
lightningnetwork/lnd
pool/read.go
newWorkerState
func (r *Read) newWorkerState() WorkerState { return &readWorkerState{ bufferPool: r.bufferPool, readBuf: r.bufferPool.Take(), } }
go
func (r *Read) newWorkerState() WorkerState { return &readWorkerState{ bufferPool: r.bufferPool, readBuf: r.bufferPool.Take(), } }
[ "func", "(", "r", "*", "Read", ")", "newWorkerState", "(", ")", "WorkerState", "{", "return", "&", "readWorkerState", "{", "bufferPool", ":", "r", ".", "bufferPool", ",", "readBuf", ":", "r", ".", "bufferPool", ".", "Take", "(", ")", ",", "}", "\n", ...
// newWorkerState initializes a new readWorkerState, which will be called // whenever a new goroutine is allocated to begin processing read tasks.
[ "newWorkerState", "initializes", "a", "new", "readWorkerState", "which", "will", "be", "called", "whenever", "a", "new", "goroutine", "is", "allocated", "to", "begin", "processing", "read", "tasks", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/pool/read.go#L69-L74
129,517
lightningnetwork/lnd
pool/read.go
Cleanup
func (r *readWorkerState) Cleanup() { r.bufferPool.Return(r.readBuf) r.readBuf = nil }
go
func (r *readWorkerState) Cleanup() { r.bufferPool.Return(r.readBuf) r.readBuf = nil }
[ "func", "(", "r", "*", "readWorkerState", ")", "Cleanup", "(", ")", "{", "r", ".", "bufferPool", ".", "Return", "(", "r", ".", "readBuf", ")", "\n", "r", ".", "readBuf", "=", "nil", "\n", "}" ]
// Cleanup returns the readBuf to the underlying buffer pool, and removes the // goroutine's reference to the readBuf.
[ "Cleanup", "returns", "the", "readBuf", "to", "the", "underlying", "buffer", "pool", "and", "removes", "the", "goroutine", "s", "reference", "to", "the", "readBuf", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/pool/read.go#L78-L81
129,518
lightningnetwork/lnd
zpay32/invoice.go
Amount
func Amount(milliSat lnwire.MilliSatoshi) func(*Invoice) { return func(i *Invoice) { i.MilliSat = &milliSat } }
go
func Amount(milliSat lnwire.MilliSatoshi) func(*Invoice) { return func(i *Invoice) { i.MilliSat = &milliSat } }
[ "func", "Amount", "(", "milliSat", "lnwire", ".", "MilliSatoshi", ")", "func", "(", "*", "Invoice", ")", "{", "return", "func", "(", "i", "*", "Invoice", ")", "{", "i", ".", "MilliSat", "=", "&", "milliSat", "\n", "}", "\n", "}" ]
// Amount is a functional option that allows callers of NewInvoice to set the // amount in millisatoshis that the Invoice should encode.
[ "Amount", "is", "a", "functional", "option", "that", "allows", "callers", "of", "NewInvoice", "to", "set", "the", "amount", "in", "millisatoshis", "that", "the", "Invoice", "should", "encode", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L153-L157
129,519
lightningnetwork/lnd
zpay32/invoice.go
Destination
func Destination(destination *btcec.PublicKey) func(*Invoice) { return func(i *Invoice) { i.Destination = destination } }
go
func Destination(destination *btcec.PublicKey) func(*Invoice) { return func(i *Invoice) { i.Destination = destination } }
[ "func", "Destination", "(", "destination", "*", "btcec", ".", "PublicKey", ")", "func", "(", "*", "Invoice", ")", "{", "return", "func", "(", "i", "*", "Invoice", ")", "{", "i", ".", "Destination", "=", "destination", "\n", "}", "\n", "}" ]
// Destination is a functional option that allows callers of NewInvoice to // explicitly set the pubkey of the Invoice's destination node.
[ "Destination", "is", "a", "functional", "option", "that", "allows", "callers", "of", "NewInvoice", "to", "explicitly", "set", "the", "pubkey", "of", "the", "Invoice", "s", "destination", "node", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L161-L165
129,520
lightningnetwork/lnd
zpay32/invoice.go
Expiry
func Expiry(expiry time.Duration) func(*Invoice) { return func(i *Invoice) { i.expiry = &expiry } }
go
func Expiry(expiry time.Duration) func(*Invoice) { return func(i *Invoice) { i.expiry = &expiry } }
[ "func", "Expiry", "(", "expiry", "time", ".", "Duration", ")", "func", "(", "*", "Invoice", ")", "{", "return", "func", "(", "i", "*", "Invoice", ")", "{", "i", ".", "expiry", "=", "&", "expiry", "\n", "}", "\n", "}" ]
// Expiry is a functional option that allows callers of NewInvoice to set the // expiry of the created Invoice. If not set, a default expiry of 60 min will // be implied.
[ "Expiry", "is", "a", "functional", "option", "that", "allows", "callers", "of", "NewInvoice", "to", "set", "the", "expiry", "of", "the", "created", "Invoice", ".", "If", "not", "set", "a", "default", "expiry", "of", "60", "min", "will", "be", "implied", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L199-L203
129,521
lightningnetwork/lnd
zpay32/invoice.go
FallbackAddr
func FallbackAddr(fallbackAddr btcutil.Address) func(*Invoice) { return func(i *Invoice) { i.FallbackAddr = fallbackAddr } }
go
func FallbackAddr(fallbackAddr btcutil.Address) func(*Invoice) { return func(i *Invoice) { i.FallbackAddr = fallbackAddr } }
[ "func", "FallbackAddr", "(", "fallbackAddr", "btcutil", ".", "Address", ")", "func", "(", "*", "Invoice", ")", "{", "return", "func", "(", "i", "*", "Invoice", ")", "{", "i", ".", "FallbackAddr", "=", "fallbackAddr", "\n", "}", "\n", "}" ]
// FallbackAddr is a functional option that allows callers of NewInvoice to set // the Invoice's fallback on-chain address that can be used for payment in case // the Lightning payment fails
[ "FallbackAddr", "is", "a", "functional", "option", "that", "allows", "callers", "of", "NewInvoice", "to", "set", "the", "Invoice", "s", "fallback", "on", "-", "chain", "address", "that", "can", "be", "used", "for", "payment", "in", "case", "the", "Lightning"...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L208-L212
129,522
lightningnetwork/lnd
zpay32/invoice.go
RouteHint
func RouteHint(routeHint []HopHint) func(*Invoice) { return func(i *Invoice) { i.RouteHints = append(i.RouteHints, routeHint) } }
go
func RouteHint(routeHint []HopHint) func(*Invoice) { return func(i *Invoice) { i.RouteHints = append(i.RouteHints, routeHint) } }
[ "func", "RouteHint", "(", "routeHint", "[", "]", "HopHint", ")", "func", "(", "*", "Invoice", ")", "{", "return", "func", "(", "i", "*", "Invoice", ")", "{", "i", ".", "RouteHints", "=", "append", "(", "i", ".", "RouteHints", ",", "routeHint", ")", ...
// RouteHint is a functional option that allows callers of NewInvoice to add // one or more hop hints that represent a private route to the destination.
[ "RouteHint", "is", "a", "functional", "option", "that", "allows", "callers", "of", "NewInvoice", "to", "add", "one", "or", "more", "hop", "hints", "that", "represent", "a", "private", "route", "to", "the", "destination", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L216-L220
129,523
lightningnetwork/lnd
zpay32/invoice.go
Decode
func Decode(invoice string, net *chaincfg.Params) (*Invoice, error) { decodedInvoice := Invoice{} // Decode the invoice using the modified bech32 decoder. hrp, data, err := decodeBech32(invoice) if err != nil { return nil, err } // We expect the human-readable part to at least have ln + one char // encoding ...
go
func Decode(invoice string, net *chaincfg.Params) (*Invoice, error) { decodedInvoice := Invoice{} // Decode the invoice using the modified bech32 decoder. hrp, data, err := decodeBech32(invoice) if err != nil { return nil, err } // We expect the human-readable part to at least have ln + one char // encoding ...
[ "func", "Decode", "(", "invoice", "string", ",", "net", "*", "chaincfg", ".", "Params", ")", "(", "*", "Invoice", ",", "error", ")", "{", "decodedInvoice", ":=", "Invoice", "{", "}", "\n\n", "// Decode the invoice using the modified bech32 decoder.", "hrp", ",",...
// Decode parses the provided encoded invoice and returns a decoded Invoice if // it is valid by BOLT-0011 and matches the provided active network.
[ "Decode", "parses", "the", "provided", "encoded", "invoice", "and", "returns", "a", "decoded", "Invoice", "if", "it", "is", "valid", "by", "BOLT", "-", "0011", "and", "matches", "the", "provided", "active", "network", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L249-L349
129,524
lightningnetwork/lnd
zpay32/invoice.go
Encode
func (invoice *Invoice) Encode(signer MessageSigner) (string, error) { // First check that this invoice is valid before starting the encoding. if err := validateInvoice(invoice); err != nil { return "", err } // The buffer will encoded the invoice data using 5-bit groups (base32). var bufferBase32 bytes.Buffer ...
go
func (invoice *Invoice) Encode(signer MessageSigner) (string, error) { // First check that this invoice is valid before starting the encoding. if err := validateInvoice(invoice); err != nil { return "", err } // The buffer will encoded the invoice data using 5-bit groups (base32). var bufferBase32 bytes.Buffer ...
[ "func", "(", "invoice", "*", "Invoice", ")", "Encode", "(", "signer", "MessageSigner", ")", "(", "string", ",", "error", ")", "{", "// First check that this invoice is valid before starting the encoding.", "if", "err", ":=", "validateInvoice", "(", "invoice", ")", "...
// Encode takes the given MessageSigner and returns a string encoding this // invoice signed by the node key of the signer.
[ "Encode", "takes", "the", "given", "MessageSigner", "and", "returns", "a", "string", "encoding", "this", "invoice", "signed", "by", "the", "node", "key", "of", "the", "signer", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L353-L457
129,525
lightningnetwork/lnd
zpay32/invoice.go
Expiry
func (invoice *Invoice) Expiry() time.Duration { if invoice.expiry != nil { return *invoice.expiry } // If no expiry is set for this invoice, default is 3600 seconds. return 3600 * time.Second }
go
func (invoice *Invoice) Expiry() time.Duration { if invoice.expiry != nil { return *invoice.expiry } // If no expiry is set for this invoice, default is 3600 seconds. return 3600 * time.Second }
[ "func", "(", "invoice", "*", "Invoice", ")", "Expiry", "(", ")", "time", ".", "Duration", "{", "if", "invoice", ".", "expiry", "!=", "nil", "{", "return", "*", "invoice", ".", "expiry", "\n", "}", "\n\n", "// If no expiry is set for this invoice, default is 36...
// Expiry returns the expiry time for this invoice. If expiry time is not set // explicitly, the default 3600 second expiry will be returned.
[ "Expiry", "returns", "the", "expiry", "time", "for", "this", "invoice", ".", "If", "expiry", "time", "is", "not", "set", "explicitly", "the", "default", "3600", "second", "expiry", "will", "be", "returned", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L461-L468
129,526
lightningnetwork/lnd
zpay32/invoice.go
MinFinalCLTVExpiry
func (invoice *Invoice) MinFinalCLTVExpiry() uint64 { if invoice.minFinalCLTVExpiry != nil { return *invoice.minFinalCLTVExpiry } return DefaultFinalCLTVDelta }
go
func (invoice *Invoice) MinFinalCLTVExpiry() uint64 { if invoice.minFinalCLTVExpiry != nil { return *invoice.minFinalCLTVExpiry } return DefaultFinalCLTVDelta }
[ "func", "(", "invoice", "*", "Invoice", ")", "MinFinalCLTVExpiry", "(", ")", "uint64", "{", "if", "invoice", ".", "minFinalCLTVExpiry", "!=", "nil", "{", "return", "*", "invoice", ".", "minFinalCLTVExpiry", "\n", "}", "\n\n", "return", "DefaultFinalCLTVDelta", ...
// MinFinalCLTVExpiry returns the minimum final CLTV expiry delta as specified // by the creator of the invoice. This value specifies the delta between the // current height and the expiry height of the HTLC extended in the last hop.
[ "MinFinalCLTVExpiry", "returns", "the", "minimum", "final", "CLTV", "expiry", "delta", "as", "specified", "by", "the", "creator", "of", "the", "invoice", ".", "This", "value", "specifies", "the", "delta", "between", "the", "current", "height", "and", "the", "e...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L473-L479
129,527
lightningnetwork/lnd
zpay32/invoice.go
validateInvoice
func validateInvoice(invoice *Invoice) error { // The net must be set. if invoice.Net == nil { return fmt.Errorf("net params not set") } // Ensure that if there is an amount set, it is not negative. if invoice.MilliSat != nil && *invoice.MilliSat < 0 { return fmt.Errorf("negative amount: %v", *invoice.MilliSa...
go
func validateInvoice(invoice *Invoice) error { // The net must be set. if invoice.Net == nil { return fmt.Errorf("net params not set") } // Ensure that if there is an amount set, it is not negative. if invoice.MilliSat != nil && *invoice.MilliSat < 0 { return fmt.Errorf("negative amount: %v", *invoice.MilliSa...
[ "func", "validateInvoice", "(", "invoice", "*", "Invoice", ")", "error", "{", "// The net must be set.", "if", "invoice", ".", "Net", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Ensure that if there is an amou...
// validateInvoice does a sanity check of the provided Invoice, making sure it // has all the necessary fields set for it to be considered valid by BOLT-0011.
[ "validateInvoice", "does", "a", "sanity", "check", "of", "the", "provided", "Invoice", "making", "sure", "it", "has", "all", "the", "necessary", "fields", "set", "for", "it", "to", "be", "considered", "valid", "by", "BOLT", "-", "0011", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L483-L540
129,528
lightningnetwork/lnd
zpay32/invoice.go
parseData
func parseData(invoice *Invoice, data []byte, net *chaincfg.Params) error { // It must contain the timestamp, encoded using 35 bits (7 groups). if len(data) < timestampBase32Len { return fmt.Errorf("data too short: %d", len(data)) } t, err := parseTimestamp(data[:timestampBase32Len]) if err != nil { return er...
go
func parseData(invoice *Invoice, data []byte, net *chaincfg.Params) error { // It must contain the timestamp, encoded using 35 bits (7 groups). if len(data) < timestampBase32Len { return fmt.Errorf("data too short: %d", len(data)) } t, err := parseTimestamp(data[:timestampBase32Len]) if err != nil { return er...
[ "func", "parseData", "(", "invoice", "*", "Invoice", ",", "data", "[", "]", "byte", ",", "net", "*", "chaincfg", ".", "Params", ")", "error", "{", "// It must contain the timestamp, encoded using 35 bits (7 groups).", "if", "len", "(", "data", ")", "<", "timesta...
// parseData parses the data part of the invoice. It expects base32 data // returned from the bech32.Decode method, except signature.
[ "parseData", "parses", "the", "data", "part", "of", "the", "invoice", ".", "It", "expects", "base32", "data", "returned", "from", "the", "bech32", ".", "Decode", "method", "except", "signature", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L544-L559
129,529
lightningnetwork/lnd
zpay32/invoice.go
parseTaggedFields
func parseTaggedFields(invoice *Invoice, fields []byte, net *chaincfg.Params) error { index := 0 for { // If there are less than 3 groups to read, there cannot be more // interesting information, as we need the type (1 group) and // length (2 groups). if len(fields)-index < 3 { break } typ := fields[i...
go
func parseTaggedFields(invoice *Invoice, fields []byte, net *chaincfg.Params) error { index := 0 for { // If there are less than 3 groups to read, there cannot be more // interesting information, as we need the type (1 group) and // length (2 groups). if len(fields)-index < 3 { break } typ := fields[i...
[ "func", "parseTaggedFields", "(", "invoice", "*", "Invoice", ",", "fields", "[", "]", "byte", ",", "net", "*", "chaincfg", ".", "Params", ")", "error", "{", "index", ":=", "0", "\n", "for", "{", "// If there are less than 3 groups to read, there cannot be more", ...
// parseTaggedFields takes the base32 encoded tagged fields of the invoice, and // fills the Invoice struct accordingly.
[ "parseTaggedFields", "takes", "the", "base32", "encoded", "tagged", "fields", "of", "the", "invoice", "and", "fills", "the", "Invoice", "struct", "accordingly", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L573-L678
129,530
lightningnetwork/lnd
zpay32/invoice.go
parseFieldDataLength
func parseFieldDataLength(data []byte) (uint16, error) { if len(data) != 2 { return 0, fmt.Errorf("data length must be 2 bytes, was %d", len(data)) } return uint16(data[0])<<5 | uint16(data[1]), nil }
go
func parseFieldDataLength(data []byte) (uint16, error) { if len(data) != 2 { return 0, fmt.Errorf("data length must be 2 bytes, was %d", len(data)) } return uint16(data[0])<<5 | uint16(data[1]), nil }
[ "func", "parseFieldDataLength", "(", "data", "[", "]", "byte", ")", "(", "uint16", ",", "error", ")", "{", "if", "len", "(", "data", ")", "!=", "2", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "data", ")", "...
// parseFieldDataLength converts the two byte slice into a uint16.
[ "parseFieldDataLength", "converts", "the", "two", "byte", "slice", "into", "a", "uint16", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L681-L688
129,531
lightningnetwork/lnd
zpay32/invoice.go
base32ToUint64
func base32ToUint64(data []byte) (uint64, error) { // Maximum that fits in uint64 is ceil(64 / 5) = 12 groups. if len(data) > 13 { return 0, fmt.Errorf("cannot parse data of length %d as uint64", len(data)) } val := uint64(0) for i := 0; i < len(data); i++ { val = val<<5 | uint64(data[i]) } return val, n...
go
func base32ToUint64(data []byte) (uint64, error) { // Maximum that fits in uint64 is ceil(64 / 5) = 12 groups. if len(data) > 13 { return 0, fmt.Errorf("cannot parse data of length %d as uint64", len(data)) } val := uint64(0) for i := 0; i < len(data); i++ { val = val<<5 | uint64(data[i]) } return val, n...
[ "func", "base32ToUint64", "(", "data", "[", "]", "byte", ")", "(", "uint64", ",", "error", ")", "{", "// Maximum that fits in uint64 is ceil(64 / 5) = 12 groups.", "if", "len", "(", "data", ")", ">", "13", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", ...
// base32ToUint64 converts a base32 encoded number to uint64.
[ "base32ToUint64", "converts", "a", "base32", "encoded", "number", "to", "uint64", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L1064-L1076
129,532
lightningnetwork/lnd
zpay32/invoice.go
uint64ToBase32
func uint64ToBase32(num uint64) []byte { // Return at least one group. if num == 0 { return []byte{0} } // To fit an uint64, we need at most is ceil(64 / 5) = 13 groups. arr := make([]byte, 13) i := 13 for num > 0 { i-- arr[i] = byte(num & uint64(31)) // 0b11111 in binary num = num >> 5 } // We only ...
go
func uint64ToBase32(num uint64) []byte { // Return at least one group. if num == 0 { return []byte{0} } // To fit an uint64, we need at most is ceil(64 / 5) = 13 groups. arr := make([]byte, 13) i := 13 for num > 0 { i-- arr[i] = byte(num & uint64(31)) // 0b11111 in binary num = num >> 5 } // We only ...
[ "func", "uint64ToBase32", "(", "num", "uint64", ")", "[", "]", "byte", "{", "// Return at least one group.", "if", "num", "==", "0", "{", "return", "[", "]", "byte", "{", "0", "}", "\n", "}", "\n\n", "// To fit an uint64, we need at most is ceil(64 / 5) = 13 group...
// uint64ToBase32 converts a uint64 to a base32 encoded integer encoded using // as few 5-bit groups as possible.
[ "uint64ToBase32", "converts", "a", "uint64", "to", "a", "base32", "encoded", "integer", "encoded", "using", "as", "few", "5", "-", "bit", "groups", "as", "possible", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/zpay32/invoice.go#L1080-L1097
129,533
lightningnetwork/lnd
lncfg/caches.go
Validate
func (c *Caches) Validate() error { if c.RejectCacheSize < MinRejectCacheSize { return fmt.Errorf("reject cache size %d is less than min: %d", c.RejectCacheSize, MinRejectCacheSize) } if c.ChannelCacheSize < MinChannelCacheSize { return fmt.Errorf("channel cache size %d is less than min: %d", c.ChannelCach...
go
func (c *Caches) Validate() error { if c.RejectCacheSize < MinRejectCacheSize { return fmt.Errorf("reject cache size %d is less than min: %d", c.RejectCacheSize, MinRejectCacheSize) } if c.ChannelCacheSize < MinChannelCacheSize { return fmt.Errorf("channel cache size %d is less than min: %d", c.ChannelCach...
[ "func", "(", "c", "*", "Caches", ")", "Validate", "(", ")", "error", "{", "if", "c", ".", "RejectCacheSize", "<", "MinRejectCacheSize", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "c", ".", "RejectCacheSize", ",", "MinRejectCacheSize", ")"...
// Validate checks the Caches configuration for values that are too small to be // sane.
[ "Validate", "checks", "the", "Caches", "configuration", "for", "values", "that", "are", "too", "small", "to", "be", "sane", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lncfg/caches.go#L31-L42
129,534
lightningnetwork/lnd
macaroons/store.go
CreateUnlock
func (r *RootKeyStorage) CreateUnlock(password *[]byte) error { // Check if we've already unlocked the store; return an error if so. if r.encKey != nil { return ErrAlreadyUnlocked } // Check if a nil password has been passed; return an error if so. if password == nil { return ErrPasswordRequired } return r...
go
func (r *RootKeyStorage) CreateUnlock(password *[]byte) error { // Check if we've already unlocked the store; return an error if so. if r.encKey != nil { return ErrAlreadyUnlocked } // Check if a nil password has been passed; return an error if so. if password == nil { return ErrPasswordRequired } return r...
[ "func", "(", "r", "*", "RootKeyStorage", ")", "CreateUnlock", "(", "password", "*", "[", "]", "byte", ")", "error", "{", "// Check if we've already unlocked the store; return an error if so.", "if", "r", ".", "encKey", "!=", "nil", "{", "return", "ErrAlreadyUnlocked...
// CreateUnlock sets an encryption key if one is not already set, otherwise it // checks if the password is correct for the stored encryption key.
[ "CreateUnlock", "sets", "an", "encryption", "key", "if", "one", "is", "not", "already", "set", "otherwise", "it", "checks", "if", "the", "password", "is", "correct", "for", "the", "stored", "encryption", "key", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/macaroons/store.go#L72-L119
129,535
lightningnetwork/lnd
macaroons/store.go
Get
func (r *RootKeyStorage) Get(_ context.Context, id []byte) ([]byte, error) { if r.encKey == nil { return nil, ErrStoreLocked } var rootKey []byte err := r.View(func(tx *bbolt.Tx) error { dbKey := tx.Bucket(rootKeyBucketName).Get(id) if len(dbKey) == 0 { return fmt.Errorf("root key with id %s doesn't exist"...
go
func (r *RootKeyStorage) Get(_ context.Context, id []byte) ([]byte, error) { if r.encKey == nil { return nil, ErrStoreLocked } var rootKey []byte err := r.View(func(tx *bbolt.Tx) error { dbKey := tx.Bucket(rootKeyBucketName).Get(id) if len(dbKey) == 0 { return fmt.Errorf("root key with id %s doesn't exist"...
[ "func", "(", "r", "*", "RootKeyStorage", ")", "Get", "(", "_", "context", ".", "Context", ",", "id", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "r", ".", "encKey", "==", "nil", "{", "return", "nil", ",", "ErrSto...
// Get implements the Get method for the bakery.RootKeyStorage interface.
[ "Get", "implements", "the", "Get", "method", "for", "the", "bakery", ".", "RootKeyStorage", "interface", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/macaroons/store.go#L122-L148
129,536
lightningnetwork/lnd
macaroons/store.go
Close
func (r *RootKeyStorage) Close() error { if r.encKey != nil { r.encKey.Zero() } return r.DB.Close() }
go
func (r *RootKeyStorage) Close() error { if r.encKey != nil { r.encKey.Zero() } return r.DB.Close() }
[ "func", "(", "r", "*", "RootKeyStorage", ")", "Close", "(", ")", "error", "{", "if", "r", ".", "encKey", "!=", "nil", "{", "r", ".", "encKey", ".", "Zero", "(", ")", "\n", "}", "\n", "return", "r", ".", "DB", ".", "Close", "(", ")", "\n", "}"...
// Close closes the underlying database and zeroes the encryption key stored // in memory.
[ "Close", "closes", "the", "underlying", "database", "and", "zeroes", "the", "encryption", "key", "stored", "in", "memory", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/macaroons/store.go#L198-L203
129,537
lightningnetwork/lnd
htlcswitch/switch.go
New
func New(cfg Config, currentHeight uint32) (*Switch, error) { circuitMap, err := NewCircuitMap(&CircuitMapConfig{ DB: cfg.DB, ExtractErrorEncrypter: cfg.ExtractErrorEncrypter, }) if err != nil { return nil, err } sequencer, err := NewPersistentSequencer(cfg.DB) if err != nil { return n...
go
func New(cfg Config, currentHeight uint32) (*Switch, error) { circuitMap, err := NewCircuitMap(&CircuitMapConfig{ DB: cfg.DB, ExtractErrorEncrypter: cfg.ExtractErrorEncrypter, }) if err != nil { return nil, err } sequencer, err := NewPersistentSequencer(cfg.DB) if err != nil { return n...
[ "func", "New", "(", "cfg", "Config", ",", "currentHeight", "uint32", ")", "(", "*", "Switch", ",", "error", ")", "{", "circuitMap", ",", "err", ":=", "NewCircuitMap", "(", "&", "CircuitMapConfig", "{", "DB", ":", "cfg", ".", "DB", ",", "ExtractErrorEncry...
// New creates the new instance of htlc switch.
[ "New", "creates", "the", "new", "instance", "of", "htlc", "switch", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L287-L318
129,538
lightningnetwork/lnd
htlcswitch/switch.go
SendHTLC
func (s *Switch) SendHTLC(firstHop lnwire.ShortChannelID, htlc *lnwire.UpdateAddHTLC, deobfuscator ErrorDecrypter) ([sha256.Size]byte, error) { // Before sending, double check that we don't already have 1) an // in-flight payment to this payment hash, or 2) a complete payment for // the same hash. if err := s.co...
go
func (s *Switch) SendHTLC(firstHop lnwire.ShortChannelID, htlc *lnwire.UpdateAddHTLC, deobfuscator ErrorDecrypter) ([sha256.Size]byte, error) { // Before sending, double check that we don't already have 1) an // in-flight payment to this payment hash, or 2) a complete payment for // the same hash. if err := s.co...
[ "func", "(", "s", "*", "Switch", ")", "SendHTLC", "(", "firstHop", "lnwire", ".", "ShortChannelID", ",", "htlc", "*", "lnwire", ".", "UpdateAddHTLC", ",", "deobfuscator", "ErrorDecrypter", ")", "(", "[", "sha256", ".", "Size", "]", "byte", ",", "error", ...
// SendHTLC is used by other subsystems which aren't belong to htlc switch // package in order to send the htlc update.
[ "SendHTLC", "is", "used", "by", "other", "subsystems", "which", "aren", "t", "belong", "to", "htlc", "switch", "package", "in", "order", "to", "send", "the", "htlc", "update", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L358-L426
129,539
lightningnetwork/lnd
htlcswitch/switch.go
forward
func (s *Switch) forward(packet *htlcPacket) error { switch htlc := packet.htlc.(type) { case *lnwire.UpdateAddHTLC: circuit := newPaymentCircuit(&htlc.PaymentHash, packet) actions, err := s.circuits.CommitCircuits(circuit) if err != nil { log.Errorf("unable to commit circuit in switch: %v", err) return e...
go
func (s *Switch) forward(packet *htlcPacket) error { switch htlc := packet.htlc.(type) { case *lnwire.UpdateAddHTLC: circuit := newPaymentCircuit(&htlc.PaymentHash, packet) actions, err := s.circuits.CommitCircuits(circuit) if err != nil { log.Errorf("unable to commit circuit in switch: %v", err) return e...
[ "func", "(", "s", "*", "Switch", ")", "forward", "(", "packet", "*", "htlcPacket", ")", "error", "{", "switch", "htlc", ":=", "packet", ".", "htlc", ".", "(", "type", ")", "{", "case", "*", "lnwire", ".", "UpdateAddHTLC", ":", "circuit", ":=", "newPa...
// forward is used in order to find next channel link and apply htlc update. // Also this function is used by channel links itself in order to forward the // update after it has been included in the channel.
[ "forward", "is", "used", "in", "order", "to", "find", "next", "channel", "link", "and", "apply", "htlc", "update", ".", "Also", "this", "function", "is", "used", "by", "channel", "links", "itself", "in", "order", "to", "forward", "the", "update", "after", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L488-L526
129,540
lightningnetwork/lnd
htlcswitch/switch.go
route
func (s *Switch) route(packet *htlcPacket) error { command := &plexPacket{ pkt: packet, err: make(chan error, 1), } select { case s.htlcPlex <- command: case <-s.quit: return ErrSwitchExiting } select { case err := <-command.err: return err case <-s.quit: return ErrSwitchExiting } }
go
func (s *Switch) route(packet *htlcPacket) error { command := &plexPacket{ pkt: packet, err: make(chan error, 1), } select { case s.htlcPlex <- command: case <-s.quit: return ErrSwitchExiting } select { case err := <-command.err: return err case <-s.quit: return ErrSwitchExiting } }
[ "func", "(", "s", "*", "Switch", ")", "route", "(", "packet", "*", "htlcPacket", ")", "error", "{", "command", ":=", "&", "plexPacket", "{", "pkt", ":", "packet", ",", "err", ":", "make", "(", "chan", "error", ",", "1", ")", ",", "}", "\n\n", "se...
// route sends a single htlcPacket through the switch and synchronously awaits a // response.
[ "route", "sends", "a", "single", "htlcPacket", "through", "the", "switch", "and", "synchronously", "awaits", "a", "response", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L715-L733
129,541
lightningnetwork/lnd
htlcswitch/switch.go
routeAsync
func (s *Switch) routeAsync(packet *htlcPacket, errChan chan error, linkQuit chan struct{}) error { command := &plexPacket{ pkt: packet, err: errChan, } select { case s.htlcPlex <- command: return nil case <-linkQuit: return ErrLinkShuttingDown case <-s.quit: return errors.New("Htlc Switch was stoppe...
go
func (s *Switch) routeAsync(packet *htlcPacket, errChan chan error, linkQuit chan struct{}) error { command := &plexPacket{ pkt: packet, err: errChan, } select { case s.htlcPlex <- command: return nil case <-linkQuit: return ErrLinkShuttingDown case <-s.quit: return errors.New("Htlc Switch was stoppe...
[ "func", "(", "s", "*", "Switch", ")", "routeAsync", "(", "packet", "*", "htlcPacket", ",", "errChan", "chan", "error", ",", "linkQuit", "chan", "struct", "{", "}", ")", "error", "{", "command", ":=", "&", "plexPacket", "{", "pkt", ":", "packet", ",", ...
// routeAsync sends a packet through the htlc switch, using the provided err // chan to propagate errors back to the caller. The link's quit channel is // provided so that the send can be canceled if either the link or the switch // receive a shutdown requuest. This method does not wait for a response from // the htlcF...
[ "routeAsync", "sends", "a", "packet", "through", "the", "htlc", "switch", "using", "the", "provided", "err", "chan", "to", "propagate", "errors", "back", "to", "the", "caller", ".", "The", "link", "s", "quit", "channel", "is", "provided", "so", "that", "th...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L740-L756
129,542
lightningnetwork/lnd
htlcswitch/switch.go
failAddPacket
func (s *Switch) failAddPacket(packet *htlcPacket, failure lnwire.FailureMessage, failErr error) error { // Encrypt the failure so that the sender will be able to read the error // message. Since we failed this packet, we use EncryptFirstHop to // obfuscate the failure for their eyes only. reason, err := packet.o...
go
func (s *Switch) failAddPacket(packet *htlcPacket, failure lnwire.FailureMessage, failErr error) error { // Encrypt the failure so that the sender will be able to read the error // message. Since we failed this packet, we use EncryptFirstHop to // obfuscate the failure for their eyes only. reason, err := packet.o...
[ "func", "(", "s", "*", "Switch", ")", "failAddPacket", "(", "packet", "*", "htlcPacket", ",", "failure", "lnwire", ".", "FailureMessage", ",", "failErr", "error", ")", "error", "{", "// Encrypt the failure so that the sender will be able to read the error", "// message....
// failAddPacket encrypts a fail packet back to an add packet's source. // The ciphertext will be derived from the failure message proivded by context. // This method returns the failErr if all other steps complete successfully.
[ "failAddPacket", "encrypts", "a", "fail", "packet", "back", "to", "an", "add", "packet", "s", "source", ".", "The", "ciphertext", "will", "be", "derived", "from", "the", "failure", "message", "proivded", "by", "context", ".", "This", "method", "returns", "th...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L1226-L1263
129,543
lightningnetwork/lnd
htlcswitch/switch.go
teardownCircuit
func (s *Switch) teardownCircuit(pkt *htlcPacket) error { var pktType string switch htlc := pkt.htlc.(type) { case *lnwire.UpdateFulfillHTLC: pktType = "SETTLE" case *lnwire.UpdateFailHTLC: pktType = "FAIL" default: err := fmt.Errorf("cannot tear down packet of type: %T", htlc) log.Errorf(err.Error()) re...
go
func (s *Switch) teardownCircuit(pkt *htlcPacket) error { var pktType string switch htlc := pkt.htlc.(type) { case *lnwire.UpdateFulfillHTLC: pktType = "SETTLE" case *lnwire.UpdateFailHTLC: pktType = "FAIL" default: err := fmt.Errorf("cannot tear down packet of type: %T", htlc) log.Errorf(err.Error()) re...
[ "func", "(", "s", "*", "Switch", ")", "teardownCircuit", "(", "pkt", "*", "htlcPacket", ")", "error", "{", "var", "pktType", "string", "\n", "switch", "htlc", ":=", "pkt", ".", "htlc", ".", "(", "type", ")", "{", "case", "*", "lnwire", ".", "UpdateFu...
// teardownCircuit removes a pending or open circuit from the switch's circuit // map and prints useful logging statements regarding the outcome.
[ "teardownCircuit", "removes", "a", "pending", "or", "open", "circuit", "from", "the", "switch", "s", "circuit", "map", "and", "prints", "useful", "logging", "statements", "regarding", "the", "outcome", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L1365-L1416
129,544
lightningnetwork/lnd
htlcswitch/switch.go
CloseLink
func (s *Switch) CloseLink(chanPoint *wire.OutPoint, closeType ChannelCloseType, targetFeePerKw lnwallet.SatPerKWeight) (chan interface{}, chan error) { // TODO(roasbeef) abstract out the close updates. updateChan := make(chan interface{}, 2) errChan := make(chan error, 1) command := &ChanClose{ CloseType: ...
go
func (s *Switch) CloseLink(chanPoint *wire.OutPoint, closeType ChannelCloseType, targetFeePerKw lnwallet.SatPerKWeight) (chan interface{}, chan error) { // TODO(roasbeef) abstract out the close updates. updateChan := make(chan interface{}, 2) errChan := make(chan error, 1) command := &ChanClose{ CloseType: ...
[ "func", "(", "s", "*", "Switch", ")", "CloseLink", "(", "chanPoint", "*", "wire", ".", "OutPoint", ",", "closeType", "ChannelCloseType", ",", "targetFeePerKw", "lnwallet", ".", "SatPerKWeight", ")", "(", "chan", "interface", "{", "}", ",", "chan", "error", ...
// CloseLink creates and sends the close channel command to the target link // directing the specified closure type. If the closure type if CloseRegular, // then the last parameter should be the ideal fee-per-kw that will be used as // a starting point for close negotiation.
[ "CloseLink", "creates", "and", "sends", "the", "close", "channel", "command", "to", "the", "target", "link", "directing", "the", "specified", "closure", "type", ".", "If", "the", "closure", "type", "if", "CloseRegular", "then", "the", "last", "parameter", "sho...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L1422-L1447
129,545
lightningnetwork/lnd
htlcswitch/switch.go
Start
func (s *Switch) Start() error { if !atomic.CompareAndSwapInt32(&s.started, 0, 1) { log.Warn("Htlc Switch already started") return errors.New("htlc switch already started") } log.Infof("Starting HTLC Switch") blockEpochStream, err := s.cfg.Notifier.RegisterBlockEpochNtfn(nil) if err != nil { return err } ...
go
func (s *Switch) Start() error { if !atomic.CompareAndSwapInt32(&s.started, 0, 1) { log.Warn("Htlc Switch already started") return errors.New("htlc switch already started") } log.Infof("Starting HTLC Switch") blockEpochStream, err := s.cfg.Notifier.RegisterBlockEpochNtfn(nil) if err != nil { return err } ...
[ "func", "(", "s", "*", "Switch", ")", "Start", "(", ")", "error", "{", "if", "!", "atomic", ".", "CompareAndSwapInt32", "(", "&", "s", ".", "started", ",", "0", ",", "1", ")", "{", "log", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "erro...
// Start starts all helper goroutines required for the operation of the switch.
[ "Start", "starts", "all", "helper", "goroutines", "required", "for", "the", "operation", "of", "the", "switch", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L1695-L1719
129,546
lightningnetwork/lnd
htlcswitch/switch.go
reforwardResponses
func (s *Switch) reforwardResponses() error { openChannels, err := s.cfg.DB.FetchAllOpenChannels() if err != nil { return err } for _, openChannel := range openChannels { shortChanID := openChannel.ShortChanID() // Locally-initiated payments never need reforwarding. if shortChanID == sourceHop { contin...
go
func (s *Switch) reforwardResponses() error { openChannels, err := s.cfg.DB.FetchAllOpenChannels() if err != nil { return err } for _, openChannel := range openChannels { shortChanID := openChannel.ShortChanID() // Locally-initiated payments never need reforwarding. if shortChanID == sourceHop { contin...
[ "func", "(", "s", "*", "Switch", ")", "reforwardResponses", "(", ")", "error", "{", "openChannels", ",", "err", ":=", "s", ".", "cfg", ".", "DB", ".", "FetchAllOpenChannels", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", ...
// reforwardResponses for every known, non-pending channel, loads all associated // forwarding packages and reforwards any Settle or Fail HTLCs found. This is // used to resurrect the switch's mailboxes after a restart.
[ "reforwardResponses", "for", "every", "known", "non", "-", "pending", "channel", "loads", "all", "associated", "forwarding", "packages", "and", "reforwards", "any", "Settle", "or", "Fail", "HTLCs", "found", ".", "This", "is", "used", "to", "resurrect", "the", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L1724-L1761
129,547
lightningnetwork/lnd
htlcswitch/switch.go
loadChannelFwdPkgs
func (s *Switch) loadChannelFwdPkgs(source lnwire.ShortChannelID) ([]*channeldb.FwdPkg, error) { var fwdPkgs []*channeldb.FwdPkg if err := s.cfg.DB.Update(func(tx *bbolt.Tx) error { var err error fwdPkgs, err = s.cfg.SwitchPackager.LoadChannelFwdPkgs( tx, source, ) return err }); err != nil { return ni...
go
func (s *Switch) loadChannelFwdPkgs(source lnwire.ShortChannelID) ([]*channeldb.FwdPkg, error) { var fwdPkgs []*channeldb.FwdPkg if err := s.cfg.DB.Update(func(tx *bbolt.Tx) error { var err error fwdPkgs, err = s.cfg.SwitchPackager.LoadChannelFwdPkgs( tx, source, ) return err }); err != nil { return ni...
[ "func", "(", "s", "*", "Switch", ")", "loadChannelFwdPkgs", "(", "source", "lnwire", ".", "ShortChannelID", ")", "(", "[", "]", "*", "channeldb", ".", "FwdPkg", ",", "error", ")", "{", "var", "fwdPkgs", "[", "]", "*", "channeldb", ".", "FwdPkg", "\n", ...
// loadChannelFwdPkgs loads all forwarding packages owned by the `source` short // channel identifier.
[ "loadChannelFwdPkgs", "loads", "all", "forwarding", "packages", "owned", "by", "the", "source", "short", "channel", "identifier", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L1765-L1779
129,548
lightningnetwork/lnd
htlcswitch/switch.go
Stop
func (s *Switch) Stop() error { if !atomic.CompareAndSwapInt32(&s.shutdown, 0, 1) { log.Warn("Htlc Switch already stopped") return errors.New("htlc switch already shutdown") } log.Infof("HTLC Switch shutting down") close(s.quit) s.wg.Wait() // Wait until all active goroutines have finished exiting before ...
go
func (s *Switch) Stop() error { if !atomic.CompareAndSwapInt32(&s.shutdown, 0, 1) { log.Warn("Htlc Switch already stopped") return errors.New("htlc switch already shutdown") } log.Infof("HTLC Switch shutting down") close(s.quit) s.wg.Wait() // Wait until all active goroutines have finished exiting before ...
[ "func", "(", "s", "*", "Switch", ")", "Stop", "(", ")", "error", "{", "if", "!", "atomic", ".", "CompareAndSwapInt32", "(", "&", "s", ".", "shutdown", ",", "0", ",", "1", ")", "{", "log", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "erro...
// Stop gracefully stops all active helper goroutines, then waits until they've // exited.
[ "Stop", "gracefully", "stops", "all", "active", "helper", "goroutines", "then", "waits", "until", "they", "ve", "exited", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L1883-L1901
129,549
lightningnetwork/lnd
htlcswitch/switch.go
AddLink
func (s *Switch) AddLink(link ChannelLink) error { s.indexMtx.Lock() defer s.indexMtx.Unlock() chanID := link.ChanID() // First, ensure that this link is not already active in the switch. _, err := s.getLink(chanID) if err == nil { return fmt.Errorf("unable to add ChannelLink(%v), already "+ "active", chan...
go
func (s *Switch) AddLink(link ChannelLink) error { s.indexMtx.Lock() defer s.indexMtx.Unlock() chanID := link.ChanID() // First, ensure that this link is not already active in the switch. _, err := s.getLink(chanID) if err == nil { return fmt.Errorf("unable to add ChannelLink(%v), already "+ "active", chan...
[ "func", "(", "s", "*", "Switch", ")", "AddLink", "(", "link", "ChannelLink", ")", "error", "{", "s", ".", "indexMtx", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "indexMtx", ".", "Unlock", "(", ")", "\n\n", "chanID", ":=", "link", ".", "ChanID"...
// AddLink is used to initiate the handling of the add link command. The // request will be propagated and handled in the main goroutine.
[ "AddLink", "is", "used", "to", "initiate", "the", "handling", "of", "the", "add", "link", "command", ".", "The", "request", "will", "be", "propagated", "and", "handled", "in", "the", "main", "goroutine", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L1905-L1946
129,550
lightningnetwork/lnd
htlcswitch/switch.go
addLiveLink
func (s *Switch) addLiveLink(link ChannelLink) { // We'll add the link to the linkIndex which lets us quickly // look up a channel when we need to close or register it, and // the forwarding index which'll be used when forwarding HTLC's // in the multi-hop setting. s.linkIndex[link.ChanID()] = link s.forwardingIn...
go
func (s *Switch) addLiveLink(link ChannelLink) { // We'll add the link to the linkIndex which lets us quickly // look up a channel when we need to close or register it, and // the forwarding index which'll be used when forwarding HTLC's // in the multi-hop setting. s.linkIndex[link.ChanID()] = link s.forwardingIn...
[ "func", "(", "s", "*", "Switch", ")", "addLiveLink", "(", "link", "ChannelLink", ")", "{", "// We'll add the link to the linkIndex which lets us quickly", "// look up a channel when we need to close or register it, and", "// the forwarding index which'll be used when forwarding HTLC's", ...
// addLiveLink adds a link to all associated forwarding index, this makes it a // candidate for forwarding HTLCs.
[ "addLiveLink", "adds", "a", "link", "to", "all", "associated", "forwarding", "index", "this", "makes", "it", "a", "candidate", "for", "forwarding", "HTLCs", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L1950-L1970
129,551
lightningnetwork/lnd
htlcswitch/switch.go
getLink
func (s *Switch) getLink(chanID lnwire.ChannelID) (ChannelLink, error) { link, ok := s.linkIndex[chanID] if !ok { link, ok = s.pendingLinkIndex[chanID] if !ok { return nil, ErrChannelLinkNotFound } } return link, nil }
go
func (s *Switch) getLink(chanID lnwire.ChannelID) (ChannelLink, error) { link, ok := s.linkIndex[chanID] if !ok { link, ok = s.pendingLinkIndex[chanID] if !ok { return nil, ErrChannelLinkNotFound } } return link, nil }
[ "func", "(", "s", "*", "Switch", ")", "getLink", "(", "chanID", "lnwire", ".", "ChannelID", ")", "(", "ChannelLink", ",", "error", ")", "{", "link", ",", "ok", ":=", "s", ".", "linkIndex", "[", "chanID", "]", "\n", "if", "!", "ok", "{", "link", "...
// getLink returns the link stored in either the pending index or the live // lindex.
[ "getLink", "returns", "the", "link", "stored", "in", "either", "the", "pending", "index", "or", "the", "live", "lindex", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L1983-L1993
129,552
lightningnetwork/lnd
htlcswitch/switch.go
HasActiveLink
func (s *Switch) HasActiveLink(chanID lnwire.ChannelID) bool { s.indexMtx.RLock() defer s.indexMtx.RUnlock() if link, ok := s.linkIndex[chanID]; ok { return link.EligibleToForward() } return false }
go
func (s *Switch) HasActiveLink(chanID lnwire.ChannelID) bool { s.indexMtx.RLock() defer s.indexMtx.RUnlock() if link, ok := s.linkIndex[chanID]; ok { return link.EligibleToForward() } return false }
[ "func", "(", "s", "*", "Switch", ")", "HasActiveLink", "(", "chanID", "lnwire", ".", "ChannelID", ")", "bool", "{", "s", ".", "indexMtx", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "indexMtx", ".", "RUnlock", "(", ")", "\n\n", "if", "link", "...
// HasActiveLink returns true if the given channel ID has a link in the link // index AND the link is eligible to forward.
[ "HasActiveLink", "returns", "true", "if", "the", "given", "channel", "ID", "has", "a", "link", "in", "the", "link", "index", "AND", "the", "link", "is", "eligible", "to", "forward", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L2010-L2019
129,553
lightningnetwork/lnd
htlcswitch/switch.go
RemoveLink
func (s *Switch) RemoveLink(chanID lnwire.ChannelID) { s.indexMtx.Lock() link := s.removeLink(chanID) s.indexMtx.Unlock() if link != nil { link.Stop() } }
go
func (s *Switch) RemoveLink(chanID lnwire.ChannelID) { s.indexMtx.Lock() link := s.removeLink(chanID) s.indexMtx.Unlock() if link != nil { link.Stop() } }
[ "func", "(", "s", "*", "Switch", ")", "RemoveLink", "(", "chanID", "lnwire", ".", "ChannelID", ")", "{", "s", ".", "indexMtx", ".", "Lock", "(", ")", "\n", "link", ":=", "s", ".", "removeLink", "(", "chanID", ")", "\n", "s", ".", "indexMtx", ".", ...
// RemoveLink purges the switch of any link associated with chanID. If a pending // or active link is not found, this method does nothing. Otherwise, the method // returns after the link has been completely shutdown.
[ "RemoveLink", "purges", "the", "switch", "of", "any", "link", "associated", "with", "chanID", ".", "If", "a", "pending", "or", "active", "link", "is", "not", "found", "this", "method", "does", "nothing", ".", "Otherwise", "the", "method", "returns", "after",...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L2024-L2032
129,554
lightningnetwork/lnd
htlcswitch/switch.go
UpdateShortChanID
func (s *Switch) UpdateShortChanID(chanID lnwire.ChannelID) error { s.indexMtx.Lock() defer s.indexMtx.Unlock() // Locate the target link in the pending link index. If no such link // exists, then we will ignore the request. link, ok := s.pendingLinkIndex[chanID] if !ok { return fmt.Errorf("link %v not found",...
go
func (s *Switch) UpdateShortChanID(chanID lnwire.ChannelID) error { s.indexMtx.Lock() defer s.indexMtx.Unlock() // Locate the target link in the pending link index. If no such link // exists, then we will ignore the request. link, ok := s.pendingLinkIndex[chanID] if !ok { return fmt.Errorf("link %v not found",...
[ "func", "(", "s", "*", "Switch", ")", "UpdateShortChanID", "(", "chanID", "lnwire", ".", "ChannelID", ")", "error", "{", "s", ".", "indexMtx", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "indexMtx", ".", "Unlock", "(", ")", "\n\n", "// Locate the t...
// UpdateShortChanID updates the short chan ID for an existing channel. This is // required in the case of a re-org and re-confirmation or a channel, or in the // case that a link was added to the switch before its short chan ID was known.
[ "UpdateShortChanID", "updates", "the", "short", "chan", "ID", "for", "an", "existing", "channel", ".", "This", "is", "required", "in", "the", "case", "of", "a", "re", "-", "org", "and", "re", "-", "confirmation", "or", "a", "channel", "or", "in", "the", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L2072-L2115
129,555
lightningnetwork/lnd
htlcswitch/switch.go
GetLinksByInterface
func (s *Switch) GetLinksByInterface(hop [33]byte) ([]ChannelLink, error) { s.indexMtx.RLock() defer s.indexMtx.RUnlock() return s.getLinks(hop) }
go
func (s *Switch) GetLinksByInterface(hop [33]byte) ([]ChannelLink, error) { s.indexMtx.RLock() defer s.indexMtx.RUnlock() return s.getLinks(hop) }
[ "func", "(", "s", "*", "Switch", ")", "GetLinksByInterface", "(", "hop", "[", "33", "]", "byte", ")", "(", "[", "]", "ChannelLink", ",", "error", ")", "{", "s", ".", "indexMtx", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "indexMtx", ".", "R...
// GetLinksByInterface fetches all the links connected to a particular node // identified by the serialized compressed form of its public key.
[ "GetLinksByInterface", "fetches", "all", "the", "links", "connected", "to", "a", "particular", "node", "identified", "by", "the", "serialized", "compressed", "form", "of", "its", "public", "key", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L2119-L2124
129,556
lightningnetwork/lnd
htlcswitch/switch.go
removePendingPayment
func (s *Switch) removePendingPayment(paymentID uint64) { s.pendingMutex.Lock() defer s.pendingMutex.Unlock() delete(s.pendingPayments, paymentID) }
go
func (s *Switch) removePendingPayment(paymentID uint64) { s.pendingMutex.Lock() defer s.pendingMutex.Unlock() delete(s.pendingPayments, paymentID) }
[ "func", "(", "s", "*", "Switch", ")", "removePendingPayment", "(", "paymentID", "uint64", ")", "{", "s", ".", "pendingMutex", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "pendingMutex", ".", "Unlock", "(", ")", "\n\n", "delete", "(", "s", ".", "p...
// removePendingPayment is the helper function which removes the pending user // payment.
[ "removePendingPayment", "is", "the", "helper", "function", "which", "removes", "the", "pending", "user", "payment", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L2146-L2151
129,557
lightningnetwork/lnd
htlcswitch/switch.go
findPayment
func (s *Switch) findPayment(paymentID uint64) *pendingPayment { s.pendingMutex.RLock() defer s.pendingMutex.RUnlock() payment, ok := s.pendingPayments[paymentID] if !ok { log.Errorf("Cannot find pending payment with ID %d", paymentID) return nil } return payment }
go
func (s *Switch) findPayment(paymentID uint64) *pendingPayment { s.pendingMutex.RLock() defer s.pendingMutex.RUnlock() payment, ok := s.pendingPayments[paymentID] if !ok { log.Errorf("Cannot find pending payment with ID %d", paymentID) return nil } return payment }
[ "func", "(", "s", "*", "Switch", ")", "findPayment", "(", "paymentID", "uint64", ")", "*", "pendingPayment", "{", "s", ".", "pendingMutex", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "pendingMutex", ".", "RUnlock", "(", ")", "\n\n", "payment", ",...
// findPayment is the helper function which find the payment.
[ "findPayment", "is", "the", "helper", "function", "which", "find", "the", "payment", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L2154-L2166
129,558
lightningnetwork/lnd
htlcswitch/switch.go
numPendingPayments
func (s *Switch) numPendingPayments() int { s.pendingMutex.RLock() defer s.pendingMutex.RUnlock() return len(s.pendingPayments) }
go
func (s *Switch) numPendingPayments() int { s.pendingMutex.RLock() defer s.pendingMutex.RUnlock() return len(s.pendingPayments) }
[ "func", "(", "s", "*", "Switch", ")", "numPendingPayments", "(", ")", "int", "{", "s", ".", "pendingMutex", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "pendingMutex", ".", "RUnlock", "(", ")", "\n\n", "return", "len", "(", "s", ".", "pendingPay...
// numPendingPayments is helper function which returns the overall number of // pending user payments.
[ "numPendingPayments", "is", "helper", "function", "which", "returns", "the", "overall", "number", "of", "pending", "user", "payments", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L2176-L2181
129,559
lightningnetwork/lnd
htlcswitch/switch.go
commitCircuits
func (s *Switch) commitCircuits(circuits ...*PaymentCircuit) ( *CircuitFwdActions, error) { return s.circuits.CommitCircuits(circuits...) }
go
func (s *Switch) commitCircuits(circuits ...*PaymentCircuit) ( *CircuitFwdActions, error) { return s.circuits.CommitCircuits(circuits...) }
[ "func", "(", "s", "*", "Switch", ")", "commitCircuits", "(", "circuits", "...", "*", "PaymentCircuit", ")", "(", "*", "CircuitFwdActions", ",", "error", ")", "{", "return", "s", ".", "circuits", ".", "CommitCircuits", "(", "circuits", "...", ")", "\n", "...
// commitCircuits persistently adds a circuit to the switch's circuit map.
[ "commitCircuits", "persistently", "adds", "a", "circuit", "to", "the", "switch", "s", "circuit", "map", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L2184-L2188
129,560
lightningnetwork/lnd
htlcswitch/switch.go
openCircuits
func (s *Switch) openCircuits(keystones ...Keystone) error { return s.circuits.OpenCircuits(keystones...) }
go
func (s *Switch) openCircuits(keystones ...Keystone) error { return s.circuits.OpenCircuits(keystones...) }
[ "func", "(", "s", "*", "Switch", ")", "openCircuits", "(", "keystones", "...", "Keystone", ")", "error", "{", "return", "s", ".", "circuits", ".", "OpenCircuits", "(", "keystones", "...", ")", "\n", "}" ]
// openCircuits preemptively writes the keystones for Adds that are about to be // added to a commitment txn.
[ "openCircuits", "preemptively", "writes", "the", "keystones", "for", "Adds", "that", "are", "about", "to", "be", "added", "to", "a", "commitment", "txn", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L2192-L2194
129,561
lightningnetwork/lnd
htlcswitch/switch.go
deleteCircuits
func (s *Switch) deleteCircuits(inKeys ...CircuitKey) error { return s.circuits.DeleteCircuits(inKeys...) }
go
func (s *Switch) deleteCircuits(inKeys ...CircuitKey) error { return s.circuits.DeleteCircuits(inKeys...) }
[ "func", "(", "s", "*", "Switch", ")", "deleteCircuits", "(", "inKeys", "...", "CircuitKey", ")", "error", "{", "return", "s", ".", "circuits", ".", "DeleteCircuits", "(", "inKeys", "...", ")", "\n", "}" ]
// deleteCircuits persistently removes the circuit, and keystone if present, // from the circuit map.
[ "deleteCircuits", "persistently", "removes", "the", "circuit", "and", "keystone", "if", "present", "from", "the", "circuit", "map", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L2198-L2200
129,562
lightningnetwork/lnd
htlcswitch/switch.go
lookupCircuit
func (s *Switch) lookupCircuit(inKey CircuitKey) *PaymentCircuit { return s.circuits.LookupCircuit(inKey) }
go
func (s *Switch) lookupCircuit(inKey CircuitKey) *PaymentCircuit { return s.circuits.LookupCircuit(inKey) }
[ "func", "(", "s", "*", "Switch", ")", "lookupCircuit", "(", "inKey", "CircuitKey", ")", "*", "PaymentCircuit", "{", "return", "s", ".", "circuits", ".", "LookupCircuit", "(", "inKey", ")", "\n", "}" ]
// lookupCircuit queries the in memory representation of the circuit map to // retrieve a particular circuit.
[ "lookupCircuit", "queries", "the", "in", "memory", "representation", "of", "the", "circuit", "map", "to", "retrieve", "a", "particular", "circuit", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L2204-L2206
129,563
lightningnetwork/lnd
htlcswitch/switch.go
lookupOpenCircuit
func (s *Switch) lookupOpenCircuit(outKey CircuitKey) *PaymentCircuit { return s.circuits.LookupOpenCircuit(outKey) }
go
func (s *Switch) lookupOpenCircuit(outKey CircuitKey) *PaymentCircuit { return s.circuits.LookupOpenCircuit(outKey) }
[ "func", "(", "s", "*", "Switch", ")", "lookupOpenCircuit", "(", "outKey", "CircuitKey", ")", "*", "PaymentCircuit", "{", "return", "s", ".", "circuits", ".", "LookupOpenCircuit", "(", "outKey", ")", "\n", "}" ]
// lookupOpenCircuit queries the in-memory representation of the circuit map for a // circuit whose outgoing circuit key matches outKey.
[ "lookupOpenCircuit", "queries", "the", "in", "-", "memory", "representation", "of", "the", "circuit", "map", "for", "a", "circuit", "whose", "outgoing", "circuit", "key", "matches", "outKey", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L2210-L2212
129,564
lightningnetwork/lnd
htlcswitch/switch.go
FlushForwardingEvents
func (s *Switch) FlushForwardingEvents() error { // First, we'll obtain a copy of the current set of pending forwarding // events. s.fwdEventMtx.Lock() // If we won't have any forwarding events, then we can exit early. if len(s.pendingFwdingEvents) == 0 { s.fwdEventMtx.Unlock() return nil } events := make(...
go
func (s *Switch) FlushForwardingEvents() error { // First, we'll obtain a copy of the current set of pending forwarding // events. s.fwdEventMtx.Lock() // If we won't have any forwarding events, then we can exit early. if len(s.pendingFwdingEvents) == 0 { s.fwdEventMtx.Unlock() return nil } events := make(...
[ "func", "(", "s", "*", "Switch", ")", "FlushForwardingEvents", "(", ")", "error", "{", "// First, we'll obtain a copy of the current set of pending forwarding", "// events.", "s", ".", "fwdEventMtx", ".", "Lock", "(", ")", "\n\n", "// If we won't have any forwarding events,...
// FlushForwardingEvents flushes out the set of pending forwarding events to // the persistent log. This will be used by the switch to periodically flush // out the set of forwarding events to disk. External callers can also use this // method to ensure all data is flushed to dis before querying the log.
[ "FlushForwardingEvents", "flushes", "out", "the", "set", "of", "pending", "forwarding", "events", "to", "the", "persistent", "log", ".", "This", "will", "be", "used", "by", "the", "switch", "to", "periodically", "flush", "out", "the", "set", "of", "forwarding"...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/switch.go#L2218-L2241
129,565
lightningnetwork/lnd
lnwire/reply_short_chan_ids_end.go
Decode
func (c *ReplyShortChanIDsEnd) Decode(r io.Reader, pver uint32) error { return ReadElements(r, c.ChainHash[:], &c.Complete, ) }
go
func (c *ReplyShortChanIDsEnd) Decode(r io.Reader, pver uint32) error { return ReadElements(r, c.ChainHash[:], &c.Complete, ) }
[ "func", "(", "c", "*", "ReplyShortChanIDsEnd", ")", "Decode", "(", "r", "io", ".", "Reader", ",", "pver", "uint32", ")", "error", "{", "return", "ReadElements", "(", "r", ",", "c", ".", "ChainHash", "[", ":", "]", ",", "&", "c", ".", "Complete", ",...
// Decode deserializes a serialized ReplyShortChanIDsEnd message stored in the // passed io.Reader observing the specified protocol version. // // This is part of the lnwire.Message interface.
[ "Decode", "deserializes", "a", "serialized", "ReplyShortChanIDsEnd", "message", "stored", "in", "the", "passed", "io", ".", "Reader", "observing", "the", "specified", "protocol", "version", ".", "This", "is", "part", "of", "the", "lnwire", ".", "Message", "inter...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/reply_short_chan_ids_end.go#L40-L45
129,566
lightningnetwork/lnd
lnwire/reply_short_chan_ids_end.go
Encode
func (c *ReplyShortChanIDsEnd) Encode(w io.Writer, pver uint32) error { return WriteElements(w, c.ChainHash[:], c.Complete, ) }
go
func (c *ReplyShortChanIDsEnd) Encode(w io.Writer, pver uint32) error { return WriteElements(w, c.ChainHash[:], c.Complete, ) }
[ "func", "(", "c", "*", "ReplyShortChanIDsEnd", ")", "Encode", "(", "w", "io", ".", "Writer", ",", "pver", "uint32", ")", "error", "{", "return", "WriteElements", "(", "w", ",", "c", ".", "ChainHash", "[", ":", "]", ",", "c", ".", "Complete", ",", "...
// Encode serializes the target ReplyShortChanIDsEnd into the passed io.Writer // observing the protocol version specified. // // This is part of the lnwire.Message interface.
[ "Encode", "serializes", "the", "target", "ReplyShortChanIDsEnd", "into", "the", "passed", "io", ".", "Writer", "observing", "the", "protocol", "version", "specified", ".", "This", "is", "part", "of", "the", "lnwire", ".", "Message", "interface", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/reply_short_chan_ids_end.go#L51-L56
129,567
lightningnetwork/lnd
nat/pmp.go
DiscoverPMP
func DiscoverPMP(timeout time.Duration) (*PMP, error) { // Retrieve the gateway IP address of the local network. gatewayIP, err := gateway.DiscoverGateway() if err != nil { return nil, err } pmp := &PMP{ client: natpmp.NewClientWithTimeout(gatewayIP, timeout), forwardedPorts: make(map[uint16]struct{...
go
func DiscoverPMP(timeout time.Duration) (*PMP, error) { // Retrieve the gateway IP address of the local network. gatewayIP, err := gateway.DiscoverGateway() if err != nil { return nil, err } pmp := &PMP{ client: natpmp.NewClientWithTimeout(gatewayIP, timeout), forwardedPorts: make(map[uint16]struct{...
[ "func", "DiscoverPMP", "(", "timeout", "time", ".", "Duration", ")", "(", "*", "PMP", ",", "error", ")", "{", "// Retrieve the gateway IP address of the local network.", "gatewayIP", ",", "err", ":=", "gateway", ".", "DiscoverGateway", "(", ")", "\n", "if", "err...
// DiscoverPMP attempts to scan the local network for a NAT-PMP enabled device // within the given timeout.
[ "DiscoverPMP", "attempts", "to", "scan", "the", "local", "network", "for", "a", "NAT", "-", "PMP", "enabled", "device", "within", "the", "given", "timeout", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/nat/pmp.go#L27-L46
129,568
lightningnetwork/lnd
nat/pmp.go
ExternalIP
func (p *PMP) ExternalIP() (net.IP, error) { res, err := p.client.GetExternalAddress() if err != nil { return nil, err } ip := net.IP(res.ExternalIPAddress[:]) if isPrivateIP(ip) { return nil, ErrMultipleNAT } return ip, nil }
go
func (p *PMP) ExternalIP() (net.IP, error) { res, err := p.client.GetExternalAddress() if err != nil { return nil, err } ip := net.IP(res.ExternalIPAddress[:]) if isPrivateIP(ip) { return nil, ErrMultipleNAT } return ip, nil }
[ "func", "(", "p", "*", "PMP", ")", "ExternalIP", "(", ")", "(", "net", ".", "IP", ",", "error", ")", "{", "res", ",", "err", ":=", "p", ".", "client", ".", "GetExternalAddress", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",...
// ExternalIP returns the external IP address of the NAT-PMP enabled device.
[ "ExternalIP", "returns", "the", "external", "IP", "address", "of", "the", "NAT", "-", "PMP", "enabled", "device", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/nat/pmp.go#L49-L61
129,569
lightningnetwork/lnd
discovery/bootstrapper.go
NewGraphBootstrapper
func NewGraphBootstrapper(cg autopilot.ChannelGraph) (NetworkPeerBootstrapper, error) { c := &ChannelGraphBootstrapper{ chanGraph: cg, tried: make(map[autopilot.NodeID]struct{}), } if _, err := rand.Read(c.hashAccumulator[:]); err != nil { return nil, err } return c, nil }
go
func NewGraphBootstrapper(cg autopilot.ChannelGraph) (NetworkPeerBootstrapper, error) { c := &ChannelGraphBootstrapper{ chanGraph: cg, tried: make(map[autopilot.NodeID]struct{}), } if _, err := rand.Read(c.hashAccumulator[:]); err != nil { return nil, err } return c, nil }
[ "func", "NewGraphBootstrapper", "(", "cg", "autopilot", ".", "ChannelGraph", ")", "(", "NetworkPeerBootstrapper", ",", "error", ")", "{", "c", ":=", "&", "ChannelGraphBootstrapper", "{", "chanGraph", ":", "cg", ",", "tried", ":", "make", "(", "map", "[", "au...
// NewGraphBootstrapper returns a new instance of a ChannelGraphBootstrapper // backed by an active autopilot.ChannelGraph instance. This type of network // peer bootstrapper will use the authenticated nodes within the known channel // graph to bootstrap connections.
[ "NewGraphBootstrapper", "returns", "a", "new", "instance", "of", "a", "ChannelGraphBootstrapper", "backed", "by", "an", "active", "autopilot", ".", "ChannelGraph", "instance", ".", "This", "type", "of", "network", "peer", "bootstrapper", "will", "use", "the", "aut...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/discovery/bootstrapper.go#L136-L148
129,570
lightningnetwork/lnd
discovery/bootstrapper.go
NewDNSSeedBootstrapper
func NewDNSSeedBootstrapper(seeds [][2]string, net tor.Net) NetworkPeerBootstrapper { return &DNSSeedBootstrapper{dnsSeeds: seeds, net: net} }
go
func NewDNSSeedBootstrapper(seeds [][2]string, net tor.Net) NetworkPeerBootstrapper { return &DNSSeedBootstrapper{dnsSeeds: seeds, net: net} }
[ "func", "NewDNSSeedBootstrapper", "(", "seeds", "[", "]", "[", "2", "]", "string", ",", "net", "tor", ".", "Net", ")", "NetworkPeerBootstrapper", "{", "return", "&", "DNSSeedBootstrapper", "{", "dnsSeeds", ":", "seeds", ",", "net", ":", "net", "}", "\n", ...
// NewDNSSeedBootstrapper returns a new instance of the DNSSeedBootstrapper. // The set of passed seeds should point to DNS servers that properly implement // Lightning's DNS peer bootstrapping protocol as defined in BOLT-0010. The set // of passed DNS seeds should come in pairs, with the second host name to be // used...
[ "NewDNSSeedBootstrapper", "returns", "a", "new", "instance", "of", "the", "DNSSeedBootstrapper", ".", "The", "set", "of", "passed", "seeds", "should", "point", "to", "DNS", "servers", "that", "properly", "implement", "Lightning", "s", "DNS", "peer", "bootstrapping...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/discovery/bootstrapper.go#L303-L305
129,571
lightningnetwork/lnd
discovery/bootstrapper.go
fallBackSRVLookup
func (d *DNSSeedBootstrapper) fallBackSRVLookup(soaShim string, targetEndPoint string) ([]*net.SRV, error) { log.Tracef("Attempting to query fallback DNS seed") // First, we'll lookup the IP address of the server that will act as // our shim. addrs, err := d.net.LookupHost(soaShim) if err != nil { return nil,...
go
func (d *DNSSeedBootstrapper) fallBackSRVLookup(soaShim string, targetEndPoint string) ([]*net.SRV, error) { log.Tracef("Attempting to query fallback DNS seed") // First, we'll lookup the IP address of the server that will act as // our shim. addrs, err := d.net.LookupHost(soaShim) if err != nil { return nil,...
[ "func", "(", "d", "*", "DNSSeedBootstrapper", ")", "fallBackSRVLookup", "(", "soaShim", "string", ",", "targetEndPoint", "string", ")", "(", "[", "]", "*", "net", ".", "SRV", ",", "error", ")", "{", "log", ".", "Tracef", "(", "\"", "\"", ")", "\n\n", ...
// fallBackSRVLookup attempts to manually query for SRV records we need to // properly bootstrap. We do this by querying the special record at the "soa." // sub-domain of supporting DNS servers. The retuned IP address will be the IP // address of the authoritative DNS server. Once we have this IP address, we'll // conn...
[ "fallBackSRVLookup", "attempts", "to", "manually", "query", "for", "SRV", "records", "we", "need", "to", "properly", "bootstrap", ".", "We", "do", "this", "by", "querying", "the", "special", "record", "at", "the", "soa", ".", "sub", "-", "domain", "of", "s...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/discovery/bootstrapper.go#L315-L371
129,572
lightningnetwork/lnd
discovery/bootstrapper.go
SampleNodeAddrs
func (d *DNSSeedBootstrapper) SampleNodeAddrs(numAddrs uint32, ignore map[autopilot.NodeID]struct{}) ([]*lnwire.NetAddress, error) { var netAddrs []*lnwire.NetAddress // We'll continue this loop until we reach our target address limit. // Each SRV query to the seed will return 25 random nodes, so we can // conti...
go
func (d *DNSSeedBootstrapper) SampleNodeAddrs(numAddrs uint32, ignore map[autopilot.NodeID]struct{}) ([]*lnwire.NetAddress, error) { var netAddrs []*lnwire.NetAddress // We'll continue this loop until we reach our target address limit. // Each SRV query to the seed will return 25 random nodes, so we can // conti...
[ "func", "(", "d", "*", "DNSSeedBootstrapper", ")", "SampleNodeAddrs", "(", "numAddrs", "uint32", ",", "ignore", "map", "[", "autopilot", ".", "NodeID", "]", "struct", "{", "}", ")", "(", "[", "]", "*", "lnwire", ".", "NetAddress", ",", "error", ")", "{...
// SampleNodeAddrs uniformly samples a set of specified address from the // network peer bootstrapper source. The num addrs field passed in denotes how // many valid peer addresses to return. The set of DNS seeds are used // successively to retrieve eligible target nodes.
[ "SampleNodeAddrs", "uniformly", "samples", "a", "set", "of", "specified", "address", "from", "the", "network", "peer", "bootstrapper", "source", ".", "The", "num", "addrs", "field", "passed", "in", "denotes", "how", "many", "valid", "peer", "addresses", "to", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/discovery/bootstrapper.go#L377-L515
129,573
lightningnetwork/lnd
docs/go-fuzz/wirefuzz.go
Fuzz
func Fuzz(data []byte) int { // Because go-fuzz requires this function signature with a []byte parameter, // and we want to emulate the behavior of mainScenario in lnwire_test.go, // we first parse the []byte parameter into a Message type. // Parsing []byte into Message r := bytes.NewReader(data) msg, err := lnw...
go
func Fuzz(data []byte) int { // Because go-fuzz requires this function signature with a []byte parameter, // and we want to emulate the behavior of mainScenario in lnwire_test.go, // we first parse the []byte parameter into a Message type. // Parsing []byte into Message r := bytes.NewReader(data) msg, err := lnw...
[ "func", "Fuzz", "(", "data", "[", "]", "byte", ")", "int", "{", "// Because go-fuzz requires this function signature with a []byte parameter,", "// and we want to emulate the behavior of mainScenario in lnwire_test.go,", "// we first parse the []byte parameter into a Message type.", "// Pa...
// Fuzz is used by go-fuzz to fuzz for potentially malicious input
[ "Fuzz", "is", "used", "by", "go", "-", "fuzz", "to", "fuzz", "for", "potentially", "malicious", "input" ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/docs/go-fuzz/wirefuzz.go#L12-L54
129,574
lightningnetwork/lnd
watchtower/wtclient/session_queue.go
newSessionQueue
func newSessionQueue(cfg *sessionQueueConfig) *sessionQueue { localInit := wtwire.NewInitMessage( lnwire.NewRawFeatureVector(wtwire.WtSessionsRequired), cfg.ChainHash, ) towerAddr := &lnwire.NetAddress{ IdentityKey: cfg.ClientSession.Tower.IdentityKey, Address: cfg.ClientSession.Tower.Addresses[0], } ...
go
func newSessionQueue(cfg *sessionQueueConfig) *sessionQueue { localInit := wtwire.NewInitMessage( lnwire.NewRawFeatureVector(wtwire.WtSessionsRequired), cfg.ChainHash, ) towerAddr := &lnwire.NetAddress{ IdentityKey: cfg.ClientSession.Tower.IdentityKey, Address: cfg.ClientSession.Tower.Addresses[0], } ...
[ "func", "newSessionQueue", "(", "cfg", "*", "sessionQueueConfig", ")", "*", "sessionQueue", "{", "localInit", ":=", "wtwire", ".", "NewInitMessage", "(", "lnwire", ".", "NewRawFeatureVector", "(", "wtwire", ".", "WtSessionsRequired", ")", ",", "cfg", ".", "Chain...
// newSessionQueue intiializes a fresh sessionQueue.
[ "newSessionQueue", "intiializes", "a", "fresh", "sessionQueue", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/session_queue.go#L111-L139
129,575
lightningnetwork/lnd
watchtower/wtclient/session_queue.go
Stop
func (q *sessionQueue) Stop() { q.stopped.Do(func() { log.Debugf("Stopping session queue %s", q.ID()) close(q.quit) q.signalUntilShutdown() // Skip log if we also force quit. select { case <-q.forceQuit: return default: } log.Debugf("Session queue %s successfully stopped", q.ID()) }) }
go
func (q *sessionQueue) Stop() { q.stopped.Do(func() { log.Debugf("Stopping session queue %s", q.ID()) close(q.quit) q.signalUntilShutdown() // Skip log if we also force quit. select { case <-q.forceQuit: return default: } log.Debugf("Session queue %s successfully stopped", q.ID()) }) }
[ "func", "(", "q", "*", "sessionQueue", ")", "Stop", "(", ")", "{", "q", ".", "stopped", ".", "Do", "(", "func", "(", ")", "{", "log", ".", "Debugf", "(", "\"", "\"", ",", "q", ".", "ID", "(", ")", ")", "\n\n", "close", "(", "q", ".", "quit"...
// Stop idempotently stops the sessionQueue by initiating a clean shutdown that // will clear all pending tasks in the queue before returning to the caller.
[ "Stop", "idempotently", "stops", "the", "sessionQueue", "by", "initiating", "a", "clean", "shutdown", "that", "will", "clear", "all", "pending", "tasks", "in", "the", "queue", "before", "returning", "to", "the", "caller", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/session_queue.go#L154-L170
129,576
lightningnetwork/lnd
watchtower/wtclient/session_queue.go
ForceQuit
func (q *sessionQueue) ForceQuit() { q.forced.Do(func() { log.Infof("Force quitting session queue %s", q.ID()) close(q.forceQuit) q.signalUntilShutdown() log.Infof("Session queue %s unclean shutdown complete", q.ID()) }) }
go
func (q *sessionQueue) ForceQuit() { q.forced.Do(func() { log.Infof("Force quitting session queue %s", q.ID()) close(q.forceQuit) q.signalUntilShutdown() log.Infof("Session queue %s unclean shutdown complete", q.ID()) }) }
[ "func", "(", "q", "*", "sessionQueue", ")", "ForceQuit", "(", ")", "{", "q", ".", "forced", ".", "Do", "(", "func", "(", ")", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "q", ".", "ID", "(", ")", ")", "\n\n", "close", "(", "q", ".", "fo...
// ForceQuit idempotently aborts any clean shutdown in progress and returns to // he caller after all lingering goroutines have spun down.
[ "ForceQuit", "idempotently", "aborts", "any", "clean", "shutdown", "in", "progress", "and", "returns", "to", "he", "caller", "after", "all", "lingering", "goroutines", "have", "spun", "down", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/session_queue.go#L174-L183
129,577
lightningnetwork/lnd
watchtower/wtclient/session_queue.go
AcceptTask
func (q *sessionQueue) AcceptTask(task *backupTask) (reserveStatus, bool) { q.queueCond.L.Lock() // Examine the current reserve status of the session queue. curStatus := q.reserveStatus() switch curStatus { // The session queue is exhausted, and cannot accept the task because it // is full. Reject the task such...
go
func (q *sessionQueue) AcceptTask(task *backupTask) (reserveStatus, bool) { q.queueCond.L.Lock() // Examine the current reserve status of the session queue. curStatus := q.reserveStatus() switch curStatus { // The session queue is exhausted, and cannot accept the task because it // is full. Reject the task such...
[ "func", "(", "q", "*", "sessionQueue", ")", "AcceptTask", "(", "task", "*", "backupTask", ")", "(", "reserveStatus", ",", "bool", ")", "{", "q", ".", "queueCond", ".", "L", ".", "Lock", "(", ")", "\n\n", "// Examine the current reserve status of the session qu...
// AcceptTask attempts to queue a backupTask for delivery to the sessionQueue's // tower. The session will only be accepted if the queue is not already // exhausted and the task is successfully bound to the ClientSession.
[ "AcceptTask", "attempts", "to", "queue", "a", "backupTask", "for", "delivery", "to", "the", "sessionQueue", "s", "tower", ".", "The", "session", "will", "only", "be", "accepted", "if", "the", "queue", "is", "not", "already", "exhausted", "and", "the", "task"...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/session_queue.go#L194-L238
129,578
lightningnetwork/lnd
watchtower/wtclient/session_queue.go
restoreCommittedUpdates
func (q *sessionQueue) restoreCommittedUpdates() { committedUpdates := q.cfg.ClientSession.CommittedUpdates // Construct and unordered slice of all committed updates with their // assigned sequence numbers. sortedUpdates := make([]updateWithSeqNum, 0, len(committedUpdates)) for seqNum, update := range committedUp...
go
func (q *sessionQueue) restoreCommittedUpdates() { committedUpdates := q.cfg.ClientSession.CommittedUpdates // Construct and unordered slice of all committed updates with their // assigned sequence numbers. sortedUpdates := make([]updateWithSeqNum, 0, len(committedUpdates)) for seqNum, update := range committedUp...
[ "func", "(", "q", "*", "sessionQueue", ")", "restoreCommittedUpdates", "(", ")", "{", "committedUpdates", ":=", "q", ".", "cfg", ".", "ClientSession", ".", "CommittedUpdates", "\n\n", "// Construct and unordered slice of all committed updates with their", "// assigned seque...
// restoreCommittedUpdates processes any CommittedUpdates loaded on startup by // sorting them in ascending order of sequence numbers and adding them to the // commitQueue. These will be sent before any pending updates are processed.
[ "restoreCommittedUpdates", "processes", "any", "CommittedUpdates", "loaded", "on", "startup", "by", "sorting", "them", "in", "ascending", "order", "of", "sequence", "numbers", "and", "adding", "them", "to", "the", "commitQueue", ".", "These", "will", "be", "sent",...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/session_queue.go#L251-L277
129,579
lightningnetwork/lnd
watchtower/wtclient/session_queue.go
sessionManager
func (q *sessionQueue) sessionManager() { defer close(q.shutdown) for { q.queueCond.L.Lock() for q.commitQueue.Len() == 0 && q.pendingQueue.Len() == 0 { q.queueCond.Wait() select { case <-q.quit: if q.commitQueue.Len() == 0 && q.pendingQueue.Len() == 0 { q.queueCond.L.Unlock() re...
go
func (q *sessionQueue) sessionManager() { defer close(q.shutdown) for { q.queueCond.L.Lock() for q.commitQueue.Len() == 0 && q.pendingQueue.Len() == 0 { q.queueCond.Wait() select { case <-q.quit: if q.commitQueue.Len() == 0 && q.pendingQueue.Len() == 0 { q.queueCond.L.Unlock() re...
[ "func", "(", "q", "*", "sessionQueue", ")", "sessionManager", "(", ")", "{", "defer", "close", "(", "q", ".", "shutdown", ")", "\n\n", "for", "{", "q", ".", "queueCond", ".", "L", ".", "Lock", "(", ")", "\n", "for", "q", ".", "commitQueue", ".", ...
// sessionManager is the primary event loop for the sessionQueue, and is // responsible for encrypting and sending accepted tasks to the tower.
[ "sessionManager", "is", "the", "primary", "event", "loop", "for", "the", "sessionQueue", "and", "is", "responsible", "for", "encrypting", "and", "sending", "accepted", "tasks", "to", "the", "tower", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/session_queue.go#L281-L320
129,580
lightningnetwork/lnd
watchtower/wtclient/session_queue.go
drainBackups
func (q *sessionQueue) drainBackups() { // First, check that we are able to dial this session's tower. conn, err := q.cfg.Dial(q.cfg.ClientSession.SessionPrivKey, q.towerAddr) if err != nil { log.Errorf("Unable to dial watchtower at %v: %v", q.towerAddr, err) q.increaseBackoff() select { case <-time.Afte...
go
func (q *sessionQueue) drainBackups() { // First, check that we are able to dial this session's tower. conn, err := q.cfg.Dial(q.cfg.ClientSession.SessionPrivKey, q.towerAddr) if err != nil { log.Errorf("Unable to dial watchtower at %v: %v", q.towerAddr, err) q.increaseBackoff() select { case <-time.Afte...
[ "func", "(", "q", "*", "sessionQueue", ")", "drainBackups", "(", ")", "{", "// First, check that we are able to dial this session's tower.", "conn", ",", "err", ":=", "q", ".", "cfg", ".", "Dial", "(", "q", ".", "cfg", ".", "ClientSession", ".", "SessionPrivKey"...
// drainBackups attempts to send all pending updates in the queue to the tower.
[ "drainBackups", "attempts", "to", "send", "all", "pending", "updates", "in", "the", "queue", "to", "the", "tower", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/session_queue.go#L323-L386
129,581
lightningnetwork/lnd
watchtower/wtclient/session_queue.go
nextStateUpdate
func (q *sessionQueue) nextStateUpdate() (*wtwire.StateUpdate, bool, error) { var ( seqNum uint16 update *wtdb.CommittedUpdate isLast bool isPending bool ) q.queueCond.L.Lock() switch { // If the commit queue is non-empty, parse the next committed update. case q.commitQueue.Len() > 0: next :=...
go
func (q *sessionQueue) nextStateUpdate() (*wtwire.StateUpdate, bool, error) { var ( seqNum uint16 update *wtdb.CommittedUpdate isLast bool isPending bool ) q.queueCond.L.Lock() switch { // If the commit queue is non-empty, parse the next committed update. case q.commitQueue.Len() > 0: next :=...
[ "func", "(", "q", "*", "sessionQueue", ")", "nextStateUpdate", "(", ")", "(", "*", "wtwire", ".", "StateUpdate", ",", "bool", ",", "error", ")", "{", "var", "(", "seqNum", "uint16", "\n", "update", "*", "wtdb", ".", "CommittedUpdate", "\n", "isLast", "...
// nextStateUpdate returns the next wtwire.StateUpdate to upload to the tower. // If any committed updates are present, this method will reconstruct the state // update from the committed update using the current last applied value found // in the database. Otherwise, it will select the next pending update, craft the /...
[ "nextStateUpdate", "returns", "the", "next", "wtwire", ".", "StateUpdate", "to", "upload", "to", "the", "tower", ".", "If", "any", "committed", "updates", "are", "present", "this", "method", "will", "reconstruct", "the", "state", "update", "from", "the", "comm...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/session_queue.go#L396-L493
129,582
lightningnetwork/lnd
watchtower/wtclient/session_queue.go
increaseBackoff
func (q *sessionQueue) increaseBackoff() { q.retryBackoff *= 2 if q.retryBackoff > q.cfg.MaxBackoff { q.retryBackoff = q.cfg.MaxBackoff } }
go
func (q *sessionQueue) increaseBackoff() { q.retryBackoff *= 2 if q.retryBackoff > q.cfg.MaxBackoff { q.retryBackoff = q.cfg.MaxBackoff } }
[ "func", "(", "q", "*", "sessionQueue", ")", "increaseBackoff", "(", ")", "{", "q", ".", "retryBackoff", "*=", "2", "\n", "if", "q", ".", "retryBackoff", ">", "q", ".", "cfg", ".", "MaxBackoff", "{", "q", ".", "retryBackoff", "=", "q", ".", "cfg", "...
// increaseBackoff doubles the current connection backoff, clamping to the // configured maximum backoff if it would exceed the limit.
[ "increaseBackoff", "doubles", "the", "current", "connection", "backoff", "clamping", "to", "the", "configured", "maximum", "backoff", "if", "it", "would", "exceed", "the", "limit", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/session_queue.go#L646-L651
129,583
lightningnetwork/lnd
watchtower/wtclient/session_queue.go
signalUntilShutdown
func (q *sessionQueue) signalUntilShutdown() { for { select { case <-time.After(time.Millisecond): q.queueCond.Signal() case <-q.shutdown: return } } }
go
func (q *sessionQueue) signalUntilShutdown() { for { select { case <-time.After(time.Millisecond): q.queueCond.Signal() case <-q.shutdown: return } } }
[ "func", "(", "q", "*", "sessionQueue", ")", "signalUntilShutdown", "(", ")", "{", "for", "{", "select", "{", "case", "<-", "time", ".", "After", "(", "time", ".", "Millisecond", ")", ":", "q", ".", "queueCond", ".", "Signal", "(", ")", "\n", "case", ...
// signalUntilShutdown strobes the sessionQueue's condition variable until the // main event loop exits.
[ "signalUntilShutdown", "strobes", "the", "sessionQueue", "s", "condition", "variable", "until", "the", "main", "event", "loop", "exits", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/session_queue.go#L655-L664
129,584
lightningnetwork/lnd
watchtower/wtclient/session_queue.go
ApplyAndWait
func (s *sessionQueueSet) ApplyAndWait(getApply func(*sessionQueue) func()) { var wg sync.WaitGroup for _, sessionq := range *s { wg.Add(1) go func(sq *sessionQueue) { defer wg.Done() getApply(sq)() }(sessionq) } wg.Wait() }
go
func (s *sessionQueueSet) ApplyAndWait(getApply func(*sessionQueue) func()) { var wg sync.WaitGroup for _, sessionq := range *s { wg.Add(1) go func(sq *sessionQueue) { defer wg.Done() getApply(sq)() }(sessionq) } wg.Wait() }
[ "func", "(", "s", "*", "sessionQueueSet", ")", "ApplyAndWait", "(", "getApply", "func", "(", "*", "sessionQueue", ")", "func", "(", ")", ")", "{", "var", "wg", "sync", ".", "WaitGroup", "\n", "for", "_", ",", "sessionq", ":=", "range", "*", "s", "{",...
// ApplyAndWait executes the nil-adic function returned from getApply for each // sessionQueue in the set in parallel, then waits for all of them to finish // before returning to the caller.
[ "ApplyAndWait", "executes", "the", "nil", "-", "adic", "function", "returned", "from", "getApply", "for", "each", "sessionQueue", "in", "the", "set", "in", "parallel", "then", "waits", "for", "all", "of", "them", "to", "finish", "before", "returning", "to", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/session_queue.go#L678-L688
129,585
lightningnetwork/lnd
lnwallet/btcwallet/driver.go
createNewWallet
func createNewWallet(args ...interface{}) (lnwallet.WalletController, error) { if len(args) != 1 { return nil, fmt.Errorf("incorrect number of arguments to .New(...), "+ "expected 1, instead passed %v", len(args)) } config, ok := args[0].(*Config) if !ok { return nil, fmt.Errorf("first argument to btcdnotif...
go
func createNewWallet(args ...interface{}) (lnwallet.WalletController, error) { if len(args) != 1 { return nil, fmt.Errorf("incorrect number of arguments to .New(...), "+ "expected 1, instead passed %v", len(args)) } config, ok := args[0].(*Config) if !ok { return nil, fmt.Errorf("first argument to btcdnotif...
[ "func", "createNewWallet", "(", "args", "...", "interface", "{", "}", ")", "(", "lnwallet", ".", "WalletController", ",", "error", ")", "{", "if", "len", "(", "args", ")", "!=", "1", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ...
// createNewWallet creates a new instance of BtcWallet given the proper list of // initialization parameters. This function is the factory function required to // properly create an instance of the lnwallet.WalletDriver struct for // BtcWallet.
[ "createNewWallet", "creates", "a", "new", "instance", "of", "BtcWallet", "given", "the", "proper", "list", "of", "initialization", "parameters", ".", "This", "function", "is", "the", "factory", "function", "required", "to", "properly", "create", "an", "instance", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/btcwallet/driver.go#L18-L31
129,586
lightningnetwork/lnd
lnwallet/btcwallet/driver.go
init
func init() { // Register the driver. driver := &lnwallet.WalletDriver{ WalletType: walletType, New: createNewWallet, BackEnds: chain.BackEnds, } if err := lnwallet.RegisterWallet(driver); err != nil { panic(fmt.Sprintf("failed to register wallet driver '%s': %v", walletType, err)) } }
go
func init() { // Register the driver. driver := &lnwallet.WalletDriver{ WalletType: walletType, New: createNewWallet, BackEnds: chain.BackEnds, } if err := lnwallet.RegisterWallet(driver); err != nil { panic(fmt.Sprintf("failed to register wallet driver '%s': %v", walletType, err)) } }
[ "func", "init", "(", ")", "{", "// Register the driver.", "driver", ":=", "&", "lnwallet", ".", "WalletDriver", "{", "WalletType", ":", "walletType", ",", "New", ":", "createNewWallet", ",", "BackEnds", ":", "chain", ".", "BackEnds", ",", "}", "\n\n", "if", ...
// init registers a driver for the BtcWallet concrete implementation of the // lnwallet.WalletController interface.
[ "init", "registers", "a", "driver", "for", "the", "BtcWallet", "concrete", "implementation", "of", "the", "lnwallet", ".", "WalletController", "interface", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/btcwallet/driver.go#L35-L47
129,587
lightningnetwork/lnd
watchtower/wtserver/server.go
New
func New(cfg *Config) (*Server, error) { localInit := wtwire.NewInitMessage( lnwire.NewRawFeatureVector(wtwire.WtSessionsOptional), cfg.ChainHash, ) s := &Server{ cfg: cfg, clients: make(map[wtdb.SessionID]Peer), newPeers: make(chan Peer), localInit: localInit, quit: make(chan struct{}),...
go
func New(cfg *Config) (*Server, error) { localInit := wtwire.NewInitMessage( lnwire.NewRawFeatureVector(wtwire.WtSessionsOptional), cfg.ChainHash, ) s := &Server{ cfg: cfg, clients: make(map[wtdb.SessionID]Peer), newPeers: make(chan Peer), localInit: localInit, quit: make(chan struct{}),...
[ "func", "New", "(", "cfg", "*", "Config", ")", "(", "*", "Server", ",", "error", ")", "{", "localInit", ":=", "wtwire", ".", "NewInitMessage", "(", "lnwire", ".", "NewRawFeatureVector", "(", "wtwire", ".", "WtSessionsOptional", ")", ",", "cfg", ".", "Cha...
// New creates a new server to handle watchtower clients. The server will accept // clients connecting to the listener addresses, and allows them to open // sessions and send state updates.
[ "New", "creates", "a", "new", "server", "to", "handle", "watchtower", "clients", ".", "The", "server", "will", "accept", "clients", "connecting", "to", "the", "listener", "addresses", "and", "allows", "them", "to", "open", "sessions", "and", "send", "state", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/server.go#L93-L119
129,588
lightningnetwork/lnd
watchtower/wtserver/server.go
Start
func (s *Server) Start() error { s.started.Do(func() { log.Infof("Starting watchtower server") s.wg.Add(1) go s.peerHandler() s.connMgr.Start() log.Infof("Watchtower server started successfully") }) return nil }
go
func (s *Server) Start() error { s.started.Do(func() { log.Infof("Starting watchtower server") s.wg.Add(1) go s.peerHandler() s.connMgr.Start() log.Infof("Watchtower server started successfully") }) return nil }
[ "func", "(", "s", "*", "Server", ")", "Start", "(", ")", "error", "{", "s", ".", "started", ".", "Do", "(", "func", "(", ")", "{", "log", ".", "Infof", "(", "\"", "\"", ")", "\n\n", "s", ".", "wg", ".", "Add", "(", "1", ")", "\n", "go", "...
// Start begins listening on the server's listeners.
[ "Start", "begins", "listening", "on", "the", "server", "s", "listeners", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/server.go#L122-L134
129,589
lightningnetwork/lnd
watchtower/wtserver/server.go
Stop
func (s *Server) Stop() error { s.stopped.Do(func() { log.Infof("Stopping watchtower server") s.connMgr.Stop() close(s.quit) s.wg.Wait() log.Infof("Watchtower server stopped successfully") }) return nil }
go
func (s *Server) Stop() error { s.stopped.Do(func() { log.Infof("Stopping watchtower server") s.connMgr.Stop() close(s.quit) s.wg.Wait() log.Infof("Watchtower server stopped successfully") }) return nil }
[ "func", "(", "s", "*", "Server", ")", "Stop", "(", ")", "error", "{", "s", ".", "stopped", ".", "Do", "(", "func", "(", ")", "{", "log", ".", "Infof", "(", "\"", "\"", ")", "\n\n", "s", ".", "connMgr", ".", "Stop", "(", ")", "\n\n", "close", ...
// Stop shutdowns down the server's listeners and any active requests.
[ "Stop", "shutdowns", "down", "the", "server", "s", "listeners", "and", "any", "active", "requests", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/server.go#L137-L149
129,590
lightningnetwork/lnd
watchtower/wtserver/server.go
inboundPeerConnected
func (s *Server) inboundPeerConnected(c net.Conn) { peer, ok := c.(Peer) if !ok { log.Warnf("incoming connection %T does not satisfy "+ "server.Peer interface", c) c.Close() return } s.InboundPeerConnected(peer) }
go
func (s *Server) inboundPeerConnected(c net.Conn) { peer, ok := c.(Peer) if !ok { log.Warnf("incoming connection %T does not satisfy "+ "server.Peer interface", c) c.Close() return } s.InboundPeerConnected(peer) }
[ "func", "(", "s", "*", "Server", ")", "inboundPeerConnected", "(", "c", "net", ".", "Conn", ")", "{", "peer", ",", "ok", ":=", "c", ".", "(", "Peer", ")", "\n", "if", "!", "ok", "{", "log", ".", "Warnf", "(", "\"", "\"", "+", "\"", "\"", ",",...
// inboundPeerConnected is the callback given to the connection manager, and is // called each time a new connection is made to the watchtower. This method // proxies the new peers by filtering out those that do not satisfy the // server.Peer interface, and closes their connection. Successful connections // will be pas...
[ "inboundPeerConnected", "is", "the", "callback", "given", "to", "the", "connection", "manager", "and", "is", "called", "each", "time", "a", "new", "connection", "is", "made", "to", "the", "watchtower", ".", "This", "method", "proxies", "the", "new", "peers", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/server.go#L156-L166
129,591
lightningnetwork/lnd
watchtower/wtserver/server.go
InboundPeerConnected
func (s *Server) InboundPeerConnected(peer Peer) { select { case s.newPeers <- peer: case <-s.quit: } }
go
func (s *Server) InboundPeerConnected(peer Peer) { select { case s.newPeers <- peer: case <-s.quit: } }
[ "func", "(", "s", "*", "Server", ")", "InboundPeerConnected", "(", "peer", "Peer", ")", "{", "select", "{", "case", "s", ".", "newPeers", "<-", "peer", ":", "case", "<-", "s", ".", "quit", ":", "}", "\n", "}" ]
// InboundPeerConnected accepts a server.Peer, and handles the request submitted // by the client. This method serves also as a public endpoint for locally // registering new clients with the server.
[ "InboundPeerConnected", "accepts", "a", "server", ".", "Peer", "and", "handles", "the", "request", "submitted", "by", "the", "client", ".", "This", "method", "serves", "also", "as", "a", "public", "endpoint", "for", "locally", "registering", "new", "clients", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/server.go#L171-L176
129,592
lightningnetwork/lnd
watchtower/wtserver/server.go
peerHandler
func (s *Server) peerHandler() { defer s.wg.Done() defer s.removeAllPeers() for { select { case peer := <-s.newPeers: s.wg.Add(1) go s.handleClient(peer) case <-s.quit: return } } }
go
func (s *Server) peerHandler() { defer s.wg.Done() defer s.removeAllPeers() for { select { case peer := <-s.newPeers: s.wg.Add(1) go s.handleClient(peer) case <-s.quit: return } } }
[ "func", "(", "s", "*", "Server", ")", "peerHandler", "(", ")", "{", "defer", "s", ".", "wg", ".", "Done", "(", ")", "\n", "defer", "s", ".", "removeAllPeers", "(", ")", "\n\n", "for", "{", "select", "{", "case", "peer", ":=", "<-", "s", ".", "n...
// peerHandler processes newly accepted peers and spawns a client handler for // each. The peerHandler is used to ensure that waitgrouped client handlers are // spawned from a waitgrouped goroutine.
[ "peerHandler", "processes", "newly", "accepted", "peers", "and", "spawns", "a", "client", "handler", "for", "each", ".", "The", "peerHandler", "is", "used", "to", "ensure", "that", "waitgrouped", "client", "handlers", "are", "spawned", "from", "a", "waitgrouped"...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/server.go#L181-L195
129,593
lightningnetwork/lnd
watchtower/wtserver/server.go
Error
func (f *connFailure) Error() string { return fmt.Sprintf("connection with %s failed with code=%s", f.ID, f.Code, ) }
go
func (f *connFailure) Error() string { return fmt.Sprintf("connection with %s failed with code=%s", f.ID, f.Code, ) }
[ "func", "(", "f", "*", "connFailure", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "f", ".", "ID", ",", "f", ".", "Code", ",", ")", "\n", "}" ]
// Error displays the SessionID and Code that caused the connection failure.
[ "Error", "displays", "the", "SessionID", "and", "Code", "that", "caused", "the", "connection", "failure", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/server.go#L294-L298
129,594
lightningnetwork/lnd
watchtower/wtserver/server.go
readMessage
func (s *Server) readMessage(peer Peer) (wtwire.Message, error) { // Set a read timeout to ensure we drop the client if not sent in a // timely manner. err := peer.SetReadDeadline(time.Now().Add(s.cfg.ReadTimeout)) if err != nil { err = fmt.Errorf("unable to set read deadline: %v", err) return nil, err } // ...
go
func (s *Server) readMessage(peer Peer) (wtwire.Message, error) { // Set a read timeout to ensure we drop the client if not sent in a // timely manner. err := peer.SetReadDeadline(time.Now().Add(s.cfg.ReadTimeout)) if err != nil { err = fmt.Errorf("unable to set read deadline: %v", err) return nil, err } // ...
[ "func", "(", "s", "*", "Server", ")", "readMessage", "(", "peer", "Peer", ")", "(", "wtwire", ".", "Message", ",", "error", ")", "{", "// Set a read timeout to ensure we drop the client if not sent in a", "// timely manner.", "err", ":=", "peer", ".", "SetReadDeadli...
// readMessage receives and parses the next message from the given Peer. An // error is returned if a message is not received before the server's read // timeout, the read off the wire failed, or the message could not be // deserialized.
[ "readMessage", "receives", "and", "parses", "the", "next", "message", "from", "the", "given", "Peer", ".", "An", "error", "is", "returned", "if", "a", "message", "is", "not", "received", "before", "the", "server", "s", "read", "timeout", "the", "read", "of...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/server.go#L304-L331
129,595
lightningnetwork/lnd
watchtower/wtserver/server.go
sendMessage
func (s *Server) sendMessage(peer Peer, msg wtwire.Message) error { // TODO(conner): use buffer pool? var b bytes.Buffer _, err := wtwire.WriteMessage(&b, msg, 0) if err != nil { err = fmt.Errorf("unable to encode msg: %v", err) return err } err = peer.SetWriteDeadline(time.Now().Add(s.cfg.WriteTimeout)) i...
go
func (s *Server) sendMessage(peer Peer, msg wtwire.Message) error { // TODO(conner): use buffer pool? var b bytes.Buffer _, err := wtwire.WriteMessage(&b, msg, 0) if err != nil { err = fmt.Errorf("unable to encode msg: %v", err) return err } err = peer.SetWriteDeadline(time.Now().Add(s.cfg.WriteTimeout)) i...
[ "func", "(", "s", "*", "Server", ")", "sendMessage", "(", "peer", "Peer", ",", "msg", "wtwire", ".", "Message", ")", "error", "{", "// TODO(conner): use buffer pool?", "var", "b", "bytes", ".", "Buffer", "\n", "_", ",", "err", ":=", "wtwire", ".", "Write...
// sendMessage sends a watchtower wire message to the target peer.
[ "sendMessage", "sends", "a", "watchtower", "wire", "message", "to", "the", "target", "peer", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/server.go#L334-L354
129,596
lightningnetwork/lnd
watchtower/wtserver/server.go
addPeer
func (s *Server) addPeer(id *wtdb.SessionID, peer Peer) error { s.clientMtx.Lock() defer s.clientMtx.Unlock() if existingPeer, ok := s.clients[*id]; ok { log.Infof("Already connected to peer %s@%s, disconnecting %s", id, existingPeer.RemoteAddr(), peer.RemoteAddr()) return ErrPeerAlreadyConnected } s.clien...
go
func (s *Server) addPeer(id *wtdb.SessionID, peer Peer) error { s.clientMtx.Lock() defer s.clientMtx.Unlock() if existingPeer, ok := s.clients[*id]; ok { log.Infof("Already connected to peer %s@%s, disconnecting %s", id, existingPeer.RemoteAddr(), peer.RemoteAddr()) return ErrPeerAlreadyConnected } s.clien...
[ "func", "(", "s", "*", "Server", ")", "addPeer", "(", "id", "*", "wtdb", ".", "SessionID", ",", "peer", "Peer", ")", "error", "{", "s", ".", "clientMtx", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "clientMtx", ".", "Unlock", "(", ")", "\n\n"...
// addPeer stores a client in the server's client map. An error is returned if a // client with the same session id already exists.
[ "addPeer", "stores", "a", "client", "in", "the", "server", "s", "client", "map", ".", "An", "error", "is", "returned", "if", "a", "client", "with", "the", "same", "session", "id", "already", "exists", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/server.go#L358-L373
129,597
lightningnetwork/lnd
watchtower/wtserver/server.go
removePeer
func (s *Server) removePeer(id *wtdb.SessionID, addr net.Addr) { log.Infof("Releasing incoming peer %s@%s", id, addr) s.clientMtx.Lock() peer, ok := s.clients[*id] delete(s.clients, *id) s.clientMtx.Unlock() if ok { peer.Close() } }
go
func (s *Server) removePeer(id *wtdb.SessionID, addr net.Addr) { log.Infof("Releasing incoming peer %s@%s", id, addr) s.clientMtx.Lock() peer, ok := s.clients[*id] delete(s.clients, *id) s.clientMtx.Unlock() if ok { peer.Close() } }
[ "func", "(", "s", "*", "Server", ")", "removePeer", "(", "id", "*", "wtdb", ".", "SessionID", ",", "addr", "net", ".", "Addr", ")", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "id", ",", "addr", ")", "\n\n", "s", ".", "clientMtx", ".", "Loc...
// removePeer deletes a client from the server's client map. If a peer is found, // this method will close the peer's connection.
[ "removePeer", "deletes", "a", "client", "from", "the", "server", "s", "client", "map", ".", "If", "a", "peer", "is", "found", "this", "method", "will", "close", "the", "peer", "s", "connection", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/server.go#L377-L388
129,598
lightningnetwork/lnd
watchtower/wtserver/server.go
removeAllPeers
func (s *Server) removeAllPeers() { s.clientMtx.Lock() defer s.clientMtx.Unlock() for id, peer := range s.clients { log.Infof("Releasing incoming peer %s@%s", id, peer.RemoteAddr()) delete(s.clients, id) peer.Close() } }
go
func (s *Server) removeAllPeers() { s.clientMtx.Lock() defer s.clientMtx.Unlock() for id, peer := range s.clients { log.Infof("Releasing incoming peer %s@%s", id, peer.RemoteAddr()) delete(s.clients, id) peer.Close() } }
[ "func", "(", "s", "*", "Server", ")", "removeAllPeers", "(", ")", "{", "s", ".", "clientMtx", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "clientMtx", ".", "Unlock", "(", ")", "\n\n", "for", "id", ",", "peer", ":=", "range", "s", ".", "client...
// removeAllPeers iterates through the server's current set of peers and closes // all open connections.
[ "removeAllPeers", "iterates", "through", "the", "server", "s", "current", "set", "of", "peers", "and", "closes", "all", "open", "connections", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/server.go#L392-L403
129,599
lightningnetwork/lnd
watchtower/wtserver/server.go
noDial
func noDial(_ net.Addr) (net.Conn, error) { return nil, fmt.Errorf("watchtower cannot make outgoing conns") }
go
func noDial(_ net.Addr) (net.Conn, error) { return nil, fmt.Errorf("watchtower cannot make outgoing conns") }
[ "func", "noDial", "(", "_", "net", ".", "Addr", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}" ]
// noDial is a dummy dial method passed to the server's connmgr.
[ "noDial", "is", "a", "dummy", "dial", "method", "passed", "to", "the", "server", "s", "connmgr", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/server.go#L427-L429