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,000 | lightningnetwork/lnd | watchtower/wtmock/peer.go | NewMockConn | func NewMockConn(localPk, remotePk *btcec.PublicKey,
localAddr, remoteAddr net.Addr,
bufferSize int) (*MockPeer, *MockPeer) {
localPeer := &MockPeer{
remotePub: remotePk,
remoteAddr: remoteAddr,
localPub: localPk,
localAddr: localAddr,
IncomingMsgs: make(chan []byte, bufferSize),
OutgoingMsg... | go | func NewMockConn(localPk, remotePk *btcec.PublicKey,
localAddr, remoteAddr net.Addr,
bufferSize int) (*MockPeer, *MockPeer) {
localPeer := &MockPeer{
remotePub: remotePk,
remoteAddr: remoteAddr,
localPub: localPk,
localAddr: localAddr,
IncomingMsgs: make(chan []byte, bufferSize),
OutgoingMsg... | [
"func",
"NewMockConn",
"(",
"localPk",
",",
"remotePk",
"*",
"btcec",
".",
"PublicKey",
",",
"localAddr",
",",
"remoteAddr",
"net",
".",
"Addr",
",",
"bufferSize",
"int",
")",
"(",
"*",
"MockPeer",
",",
"*",
"MockPeer",
")",
"{",
"localPeer",
":=",
"&",
... | // NewMockConn establishes a bidirectional connection between two MockPeers. | [
"NewMockConn",
"establishes",
"a",
"bidirectional",
"connection",
"between",
"two",
"MockPeers",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtmock/peer.go#L48-L76 |
129,001 | lightningnetwork/lnd | watchtower/wtmock/peer.go | Write | func (p *MockPeer) Write(b []byte) (n int, err error) {
bb := make([]byte, len(b))
copy(bb, b)
select {
case p.OutgoingMsgs <- bb:
return len(b), nil
case <-p.writeDeadline:
return 0, fmt.Errorf("write timeout expired")
case <-p.RemoteQuit:
return 0, fmt.Errorf("remote closed connected")
case <-p.Quit:
... | go | func (p *MockPeer) Write(b []byte) (n int, err error) {
bb := make([]byte, len(b))
copy(bb, b)
select {
case p.OutgoingMsgs <- bb:
return len(b), nil
case <-p.writeDeadline:
return 0, fmt.Errorf("write timeout expired")
case <-p.RemoteQuit:
return 0, fmt.Errorf("remote closed connected")
case <-p.Quit:
... | [
"func",
"(",
"p",
"*",
"MockPeer",
")",
"Write",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"bb",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"b",
")",
")",
"\n",
"copy",
"(",
"bb",
",",
"b"... | // Write sends the raw bytes as the next full message read to the remote peer.
// The write will fail if either party closes the connection or the write
// deadline expires. The passed bytes slice is copied before sending, thus the
// bytes may be reused once the method returns. | [
"Write",
"sends",
"the",
"raw",
"bytes",
"as",
"the",
"next",
"full",
"message",
"read",
"to",
"the",
"remote",
"peer",
".",
"The",
"write",
"will",
"fail",
"if",
"either",
"party",
"closes",
"the",
"connection",
"or",
"the",
"write",
"deadline",
"expires"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtmock/peer.go#L82-L96 |
129,002 | lightningnetwork/lnd | watchtower/wtmock/peer.go | Close | func (p *MockPeer) Close() error {
select {
case <-p.Quit:
return fmt.Errorf("connection already closed")
default:
close(p.Quit)
return nil
}
} | go | func (p *MockPeer) Close() error {
select {
case <-p.Quit:
return fmt.Errorf("connection already closed")
default:
close(p.Quit)
return nil
}
} | [
"func",
"(",
"p",
"*",
"MockPeer",
")",
"Close",
"(",
")",
"error",
"{",
"select",
"{",
"case",
"<-",
"p",
".",
"Quit",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"default",
":",
"close",
"(",
"p",
".",
"Quit",
")",
"\n",
... | // Close tearsdown the connection, and fails any pending reads or writes. | [
"Close",
"tearsdown",
"the",
"connection",
"and",
"fails",
"any",
"pending",
"reads",
"or",
"writes",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtmock/peer.go#L99-L107 |
129,003 | lightningnetwork/lnd | watchtower/wtmock/peer.go | ReadNextMessage | func (p *MockPeer) ReadNextMessage() ([]byte, error) {
select {
case b := <-p.IncomingMsgs:
return b, nil
case <-p.readDeadline:
return nil, fmt.Errorf("read timeout expired")
case <-p.RemoteQuit:
return nil, fmt.Errorf("remote closed connected")
case <-p.Quit:
return nil, fmt.Errorf("connection closed")
... | go | func (p *MockPeer) ReadNextMessage() ([]byte, error) {
select {
case b := <-p.IncomingMsgs:
return b, nil
case <-p.readDeadline:
return nil, fmt.Errorf("read timeout expired")
case <-p.RemoteQuit:
return nil, fmt.Errorf("remote closed connected")
case <-p.Quit:
return nil, fmt.Errorf("connection closed")
... | [
"func",
"(",
"p",
"*",
"MockPeer",
")",
"ReadNextMessage",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"select",
"{",
"case",
"b",
":=",
"<-",
"p",
".",
"IncomingMsgs",
":",
"return",
"b",
",",
"nil",
"\n",
"case",
"<-",
"p",
".",
... | // ReadNextMessage returns the raw bytes of the next full message read from the
// remote peer. The read will fail if either party closes the connection or the
// read deadline expires. | [
"ReadNextMessage",
"returns",
"the",
"raw",
"bytes",
"of",
"the",
"next",
"full",
"message",
"read",
"from",
"the",
"remote",
"peer",
".",
"The",
"read",
"will",
"fail",
"if",
"either",
"party",
"closes",
"the",
"connection",
"or",
"the",
"read",
"deadline",... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtmock/peer.go#L112-L123 |
129,004 | lightningnetwork/lnd | watchtower/wtmock/peer.go | SetWriteDeadline | func (p *MockPeer) SetWriteDeadline(t time.Time) error {
if t.IsZero() {
p.writeDeadline = nil
return nil
}
duration := time.Until(t)
p.writeDeadline = time.After(duration)
return nil
} | go | func (p *MockPeer) SetWriteDeadline(t time.Time) error {
if t.IsZero() {
p.writeDeadline = nil
return nil
}
duration := time.Until(t)
p.writeDeadline = time.After(duration)
return nil
} | [
"func",
"(",
"p",
"*",
"MockPeer",
")",
"SetWriteDeadline",
"(",
"t",
"time",
".",
"Time",
")",
"error",
"{",
"if",
"t",
".",
"IsZero",
"(",
")",
"{",
"p",
".",
"writeDeadline",
"=",
"nil",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"duration",
":="... | // SetWriteDeadline initializes a timer that will cause any pending writes to
// fail at time t. If t is zero, the deadline is infinite. | [
"SetWriteDeadline",
"initializes",
"a",
"timer",
"that",
"will",
"cause",
"any",
"pending",
"writes",
"to",
"fail",
"at",
"time",
"t",
".",
"If",
"t",
"is",
"zero",
"the",
"deadline",
"is",
"infinite",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtmock/peer.go#L127-L137 |
129,005 | lightningnetwork/lnd | watchtower/wtmock/peer.go | SetReadDeadline | func (p *MockPeer) SetReadDeadline(t time.Time) error {
if t.IsZero() {
p.readDeadline = nil
return nil
}
duration := time.Until(t)
p.readDeadline = time.After(duration)
return nil
} | go | func (p *MockPeer) SetReadDeadline(t time.Time) error {
if t.IsZero() {
p.readDeadline = nil
return nil
}
duration := time.Until(t)
p.readDeadline = time.After(duration)
return nil
} | [
"func",
"(",
"p",
"*",
"MockPeer",
")",
"SetReadDeadline",
"(",
"t",
"time",
".",
"Time",
")",
"error",
"{",
"if",
"t",
".",
"IsZero",
"(",
")",
"{",
"p",
".",
"readDeadline",
"=",
"nil",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"duration",
":=",
... | // SetReadDeadline initializes a timer that will cause any pending reads to fail
// at time t. If t is zero, the deadline is infinite. | [
"SetReadDeadline",
"initializes",
"a",
"timer",
"that",
"will",
"cause",
"any",
"pending",
"reads",
"to",
"fail",
"at",
"time",
"t",
".",
"If",
"t",
"is",
"zero",
"the",
"deadline",
"is",
"infinite",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtmock/peer.go#L141-L151 |
129,006 | lightningnetwork/lnd | watchtower/wtserver/delete_session.go | handleDeleteSession | func (s *Server) handleDeleteSession(peer Peer, id *wtdb.SessionID) error {
var failCode wtwire.DeleteSessionCode
// Delete all session data associated with id.
err := s.cfg.DB.DeleteSession(*id)
switch {
case err == nil:
failCode = wtwire.CodeOK
log.Debugf("Session %s deleted", id)
case err == wtdb.ErrSes... | go | func (s *Server) handleDeleteSession(peer Peer, id *wtdb.SessionID) error {
var failCode wtwire.DeleteSessionCode
// Delete all session data associated with id.
err := s.cfg.DB.DeleteSession(*id)
switch {
case err == nil:
failCode = wtwire.CodeOK
log.Debugf("Session %s deleted", id)
case err == wtdb.ErrSes... | [
"func",
"(",
"s",
"*",
"Server",
")",
"handleDeleteSession",
"(",
"peer",
"Peer",
",",
"id",
"*",
"wtdb",
".",
"SessionID",
")",
"error",
"{",
"var",
"failCode",
"wtwire",
".",
"DeleteSessionCode",
"\n\n",
"// Delete all session data associated with id.",
"err",
... | // handleDeleteSession processes a DeleteSession request for a client with given
// SessionID. The id is assumed to have been previously authenticated by the
// brontide connection. | [
"handleDeleteSession",
"processes",
"a",
"DeleteSession",
"request",
"for",
"a",
"client",
"with",
"given",
"SessionID",
".",
"The",
"id",
"is",
"assumed",
"to",
"have",
"been",
"previously",
"authenticated",
"by",
"the",
"brontide",
"connection",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/delete_session.go#L11-L30 |
129,007 | lightningnetwork/lnd | watchtower/wtserver/delete_session.go | replyDeleteSession | func (s *Server) replyDeleteSession(peer Peer, id *wtdb.SessionID,
code wtwire.DeleteSessionCode) error {
msg := &wtwire.DeleteSessionReply{
Code: code,
}
err := s.sendMessage(peer, msg)
if err != nil {
log.Errorf("Unable to send DeleteSessionReply to %s", id)
}
// Return the write error if the request su... | go | func (s *Server) replyDeleteSession(peer Peer, id *wtdb.SessionID,
code wtwire.DeleteSessionCode) error {
msg := &wtwire.DeleteSessionReply{
Code: code,
}
err := s.sendMessage(peer, msg)
if err != nil {
log.Errorf("Unable to send DeleteSessionReply to %s", id)
}
// Return the write error if the request su... | [
"func",
"(",
"s",
"*",
"Server",
")",
"replyDeleteSession",
"(",
"peer",
"Peer",
",",
"id",
"*",
"wtdb",
".",
"SessionID",
",",
"code",
"wtwire",
".",
"DeleteSessionCode",
")",
"error",
"{",
"msg",
":=",
"&",
"wtwire",
".",
"DeleteSessionReply",
"{",
"Co... | // replyDeleteSession sends a DeleteSessionReply back to the peer containing the
// error code resulting from processes a DeleteSession request. | [
"replyDeleteSession",
"sends",
"a",
"DeleteSessionReply",
"back",
"to",
"the",
"peer",
"containing",
"the",
"error",
"code",
"resulting",
"from",
"processes",
"a",
"DeleteSession",
"request",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/delete_session.go#L34-L57 |
129,008 | lightningnetwork/lnd | chanbackup/crypto.go | encryptPayloadToWriter | func encryptPayloadToWriter(payload bytes.Buffer, w io.Writer,
keyRing keychain.KeyRing) error {
// First, we'll derive the key that we'll use to encrypt the payload
// for safe storage without giving away the details of any of our
// channels. The final operation is:
//
// key = SHA256(baseKey)
encryptionKey... | go | func encryptPayloadToWriter(payload bytes.Buffer, w io.Writer,
keyRing keychain.KeyRing) error {
// First, we'll derive the key that we'll use to encrypt the payload
// for safe storage without giving away the details of any of our
// channels. The final operation is:
//
// key = SHA256(baseKey)
encryptionKey... | [
"func",
"encryptPayloadToWriter",
"(",
"payload",
"bytes",
".",
"Buffer",
",",
"w",
"io",
".",
"Writer",
",",
"keyRing",
"keychain",
".",
"KeyRing",
")",
"error",
"{",
"// First, we'll derive the key that we'll use to encrypt the payload",
"// for safe storage without givin... | // encryptPayloadToWriter attempts to write the set of bytes contained within
// the passed byes.Buffer into the passed io.Writer in an encrypted form. We
// use a 24-byte chachapoly AEAD instance with a randomized nonce that's
// pre-pended to the final payload and used as associated data in the AEAD. We
// use the pa... | [
"encryptPayloadToWriter",
"attempts",
"to",
"write",
"the",
"set",
"of",
"bytes",
"contained",
"within",
"the",
"passed",
"byes",
".",
"Buffer",
"into",
"the",
"passed",
"io",
".",
"Writer",
"in",
"an",
"encrypted",
"form",
".",
"We",
"use",
"a",
"24",
"-"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chanbackup/crypto.go#L59-L97 |
129,009 | lightningnetwork/lnd | chanbackup/crypto.go | decryptPayloadFromReader | func decryptPayloadFromReader(payload io.Reader,
keyRing keychain.KeyRing) ([]byte, error) {
// First, we'll re-generate the encryption key that we use for all the
// SCBs.
encryptionKey, err := genEncryptionKey(keyRing)
if err != nil {
return nil, err
}
// Next, we'll read out the entire blob as we need to ... | go | func decryptPayloadFromReader(payload io.Reader,
keyRing keychain.KeyRing) ([]byte, error) {
// First, we'll re-generate the encryption key that we use for all the
// SCBs.
encryptionKey, err := genEncryptionKey(keyRing)
if err != nil {
return nil, err
}
// Next, we'll read out the entire blob as we need to ... | [
"func",
"decryptPayloadFromReader",
"(",
"payload",
"io",
".",
"Reader",
",",
"keyRing",
"keychain",
".",
"KeyRing",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// First, we'll re-generate the encryption key that we use for all the",
"// SCBs.",
"encryptionKey"... | // decryptPayloadFromReader attempts to decrypt the encrypted bytes within the
// passed io.Reader instance using the key derived from the passed keyRing. For
// further details regarding the key derivation protocol, see the
// genEncryptionKey method. | [
"decryptPayloadFromReader",
"attempts",
"to",
"decrypt",
"the",
"encrypted",
"bytes",
"within",
"the",
"passed",
"io",
".",
"Reader",
"instance",
"using",
"the",
"key",
"derived",
"from",
"the",
"passed",
"keyRing",
".",
"For",
"further",
"details",
"regarding",
... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chanbackup/crypto.go#L103-L140 |
129,010 | lightningnetwork/lnd | lnwallet/wallet.go | Startup | func (l *LightningWallet) Startup() error {
// Already started?
if atomic.AddInt32(&l.started, 1) != 1 {
return nil
}
// Start the underlying wallet controller.
if err := l.Start(); err != nil {
return err
}
l.wg.Add(1)
// TODO(roasbeef): multiple request handlers?
go l.requestHandler()
return nil
} | go | func (l *LightningWallet) Startup() error {
// Already started?
if atomic.AddInt32(&l.started, 1) != 1 {
return nil
}
// Start the underlying wallet controller.
if err := l.Start(); err != nil {
return err
}
l.wg.Add(1)
// TODO(roasbeef): multiple request handlers?
go l.requestHandler()
return nil
} | [
"func",
"(",
"l",
"*",
"LightningWallet",
")",
"Startup",
"(",
")",
"error",
"{",
"// Already started?",
"if",
"atomic",
".",
"AddInt32",
"(",
"&",
"l",
".",
"started",
",",
"1",
")",
"!=",
"1",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Start the un... | // Startup establishes a connection to the RPC source, and spins up all
// goroutines required to handle incoming messages. | [
"Startup",
"establishes",
"a",
"connection",
"to",
"the",
"RPC",
"source",
"and",
"spins",
"up",
"all",
"goroutines",
"required",
"to",
"handle",
"incoming",
"messages",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/wallet.go#L300-L316 |
129,011 | lightningnetwork/lnd | lnwallet/wallet.go | Shutdown | func (l *LightningWallet) Shutdown() error {
if atomic.AddInt32(&l.shutdown, 1) != 1 {
return nil
}
// Signal the underlying wallet controller to shutdown, waiting until
// all active goroutines have been shutdown.
if err := l.Stop(); err != nil {
return err
}
close(l.quit)
l.wg.Wait()
return nil
} | go | func (l *LightningWallet) Shutdown() error {
if atomic.AddInt32(&l.shutdown, 1) != 1 {
return nil
}
// Signal the underlying wallet controller to shutdown, waiting until
// all active goroutines have been shutdown.
if err := l.Stop(); err != nil {
return err
}
close(l.quit)
l.wg.Wait()
return nil
} | [
"func",
"(",
"l",
"*",
"LightningWallet",
")",
"Shutdown",
"(",
")",
"error",
"{",
"if",
"atomic",
".",
"AddInt32",
"(",
"&",
"l",
".",
"shutdown",
",",
"1",
")",
"!=",
"1",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Signal the underlying wallet contro... | // Shutdown gracefully stops the wallet, and all active goroutines. | [
"Shutdown",
"gracefully",
"stops",
"the",
"wallet",
"and",
"all",
"active",
"goroutines",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/wallet.go#L319-L333 |
129,012 | lightningnetwork/lnd | lnwallet/wallet.go | LockedOutpoints | func (l *LightningWallet) LockedOutpoints() []*wire.OutPoint {
outPoints := make([]*wire.OutPoint, 0, len(l.lockedOutPoints))
for outPoint := range l.lockedOutPoints {
outPoints = append(outPoints, &outPoint)
}
return outPoints
} | go | func (l *LightningWallet) LockedOutpoints() []*wire.OutPoint {
outPoints := make([]*wire.OutPoint, 0, len(l.lockedOutPoints))
for outPoint := range l.lockedOutPoints {
outPoints = append(outPoints, &outPoint)
}
return outPoints
} | [
"func",
"(",
"l",
"*",
"LightningWallet",
")",
"LockedOutpoints",
"(",
")",
"[",
"]",
"*",
"wire",
".",
"OutPoint",
"{",
"outPoints",
":=",
"make",
"(",
"[",
"]",
"*",
"wire",
".",
"OutPoint",
",",
"0",
",",
"len",
"(",
"l",
".",
"lockedOutPoints",
... | // LockedOutpoints returns a list of all currently locked outpoint. | [
"LockedOutpoints",
"returns",
"a",
"list",
"of",
"all",
"currently",
"locked",
"outpoint",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/wallet.go#L336-L343 |
129,013 | lightningnetwork/lnd | lnwallet/wallet.go | ResetReservations | func (l *LightningWallet) ResetReservations() {
l.nextFundingID = 0
l.fundingLimbo = make(map[uint64]*ChannelReservation)
for outpoint := range l.lockedOutPoints {
l.UnlockOutpoint(outpoint)
}
l.lockedOutPoints = make(map[wire.OutPoint]struct{})
} | go | func (l *LightningWallet) ResetReservations() {
l.nextFundingID = 0
l.fundingLimbo = make(map[uint64]*ChannelReservation)
for outpoint := range l.lockedOutPoints {
l.UnlockOutpoint(outpoint)
}
l.lockedOutPoints = make(map[wire.OutPoint]struct{})
} | [
"func",
"(",
"l",
"*",
"LightningWallet",
")",
"ResetReservations",
"(",
")",
"{",
"l",
".",
"nextFundingID",
"=",
"0",
"\n",
"l",
".",
"fundingLimbo",
"=",
"make",
"(",
"map",
"[",
"uint64",
"]",
"*",
"ChannelReservation",
")",
"\n\n",
"for",
"outpoint"... | // ResetReservations reset the volatile wallet state which tracks all currently
// active reservations. | [
"ResetReservations",
"reset",
"the",
"volatile",
"wallet",
"state",
"which",
"tracks",
"all",
"currently",
"active",
"reservations",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/wallet.go#L347-L355 |
129,014 | lightningnetwork/lnd | lnwallet/wallet.go | InitChannelReservation | func (l *LightningWallet) InitChannelReservation(
req *InitFundingReserveMsg) (*ChannelReservation, error) {
req.resp = make(chan *ChannelReservation, 1)
req.err = make(chan error, 1)
select {
case l.msgChan <- req:
case <-l.quit:
return nil, errors.New("wallet shutting down")
}
return <-req.resp, <-req.er... | go | func (l *LightningWallet) InitChannelReservation(
req *InitFundingReserveMsg) (*ChannelReservation, error) {
req.resp = make(chan *ChannelReservation, 1)
req.err = make(chan error, 1)
select {
case l.msgChan <- req:
case <-l.quit:
return nil, errors.New("wallet shutting down")
}
return <-req.resp, <-req.er... | [
"func",
"(",
"l",
"*",
"LightningWallet",
")",
"InitChannelReservation",
"(",
"req",
"*",
"InitFundingReserveMsg",
")",
"(",
"*",
"ChannelReservation",
",",
"error",
")",
"{",
"req",
".",
"resp",
"=",
"make",
"(",
"chan",
"*",
"ChannelReservation",
",",
"1",... | // InitChannelReservation kicks off the 3-step workflow required to successfully
// open a payment channel with a remote node. As part of the funding
// reservation, the inputs selected for the funding transaction are 'locked'.
// This ensures that multiple channel reservations aren't double spending the
// same inputs... | [
"InitChannelReservation",
"kicks",
"off",
"the",
"3",
"-",
"step",
"workflow",
"required",
"to",
"successfully",
"open",
"a",
"payment",
"channel",
"with",
"a",
"remote",
"node",
".",
"As",
"part",
"of",
"the",
"funding",
"reservation",
"the",
"inputs",
"selec... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/wallet.go#L415-L428 |
129,015 | lightningnetwork/lnd | lnwallet/wallet.go | handleFundingCancelRequest | func (l *LightningWallet) handleFundingCancelRequest(req *fundingReserveCancelMsg) {
// TODO(roasbeef): holding lock too long
l.limboMtx.Lock()
defer l.limboMtx.Unlock()
pendingReservation, ok := l.fundingLimbo[req.pendingFundingID]
if !ok {
// TODO(roasbeef): make new error, "unknown funding state" or somethin... | go | func (l *LightningWallet) handleFundingCancelRequest(req *fundingReserveCancelMsg) {
// TODO(roasbeef): holding lock too long
l.limboMtx.Lock()
defer l.limboMtx.Unlock()
pendingReservation, ok := l.fundingLimbo[req.pendingFundingID]
if !ok {
// TODO(roasbeef): make new error, "unknown funding state" or somethin... | [
"func",
"(",
"l",
"*",
"LightningWallet",
")",
"handleFundingCancelRequest",
"(",
"req",
"*",
"fundingReserveCancelMsg",
")",
"{",
"// TODO(roasbeef): holding lock too long",
"l",
".",
"limboMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"limboMtx",
".",
... | // handleFundingReserveCancel cancels an existing channel reservation. As part
// of the cancellation, outputs previously selected as inputs for the funding
// transaction via coin selection are freed allowing future reservations to
// include them. | [
"handleFundingReserveCancel",
"cancels",
"an",
"existing",
"channel",
"reservation",
".",
"As",
"part",
"of",
"the",
"cancellation",
"outputs",
"previously",
"selected",
"as",
"inputs",
"for",
"the",
"funding",
"transaction",
"via",
"coin",
"selection",
"are",
"free... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/wallet.go#L592-L623 |
129,016 | lightningnetwork/lnd | lnwallet/wallet.go | CreateCommitmentTxns | func CreateCommitmentTxns(localBalance, remoteBalance btcutil.Amount,
ourChanCfg, theirChanCfg *channeldb.ChannelConfig,
localCommitPoint, remoteCommitPoint *btcec.PublicKey,
fundingTxIn wire.TxIn) (*wire.MsgTx, *wire.MsgTx, error) {
localCommitmentKeys := deriveCommitmentKeys(localCommitPoint, true,
ourChanCfg,... | go | func CreateCommitmentTxns(localBalance, remoteBalance btcutil.Amount,
ourChanCfg, theirChanCfg *channeldb.ChannelConfig,
localCommitPoint, remoteCommitPoint *btcec.PublicKey,
fundingTxIn wire.TxIn) (*wire.MsgTx, *wire.MsgTx, error) {
localCommitmentKeys := deriveCommitmentKeys(localCommitPoint, true,
ourChanCfg,... | [
"func",
"CreateCommitmentTxns",
"(",
"localBalance",
",",
"remoteBalance",
"btcutil",
".",
"Amount",
",",
"ourChanCfg",
",",
"theirChanCfg",
"*",
"channeldb",
".",
"ChannelConfig",
",",
"localCommitPoint",
",",
"remoteCommitPoint",
"*",
"btcec",
".",
"PublicKey",
",... | // CreateCommitmentTxns is a helper function that creates the initial
// commitment transaction for both parties. This function is used during the
// initial funding workflow as both sides must generate a signature for the
// remote party's commitment transaction, and verify the signature for their
// version of the co... | [
"CreateCommitmentTxns",
"is",
"a",
"helper",
"function",
"that",
"creates",
"the",
"initial",
"commitment",
"transaction",
"for",
"both",
"parties",
".",
"This",
"function",
"is",
"used",
"during",
"the",
"initial",
"funding",
"workflow",
"as",
"both",
"sides",
... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/wallet.go#L630-L665 |
129,017 | lightningnetwork/lnd | lnwallet/wallet.go | handleSingleContribution | func (l *LightningWallet) handleSingleContribution(req *addSingleContributionMsg) {
l.limboMtx.Lock()
pendingReservation, ok := l.fundingLimbo[req.pendingFundingID]
l.limboMtx.Unlock()
if !ok {
req.err <- fmt.Errorf("attempted to update non-existent funding state")
return
}
// Grab the mutex on the channelRe... | go | func (l *LightningWallet) handleSingleContribution(req *addSingleContributionMsg) {
l.limboMtx.Lock()
pendingReservation, ok := l.fundingLimbo[req.pendingFundingID]
l.limboMtx.Unlock()
if !ok {
req.err <- fmt.Errorf("attempted to update non-existent funding state")
return
}
// Grab the mutex on the channelRe... | [
"func",
"(",
"l",
"*",
"LightningWallet",
")",
"handleSingleContribution",
"(",
"req",
"*",
"addSingleContributionMsg",
")",
"{",
"l",
".",
"limboMtx",
".",
"Lock",
"(",
")",
"\n",
"pendingReservation",
",",
"ok",
":=",
"l",
".",
"fundingLimbo",
"[",
"req",
... | // handleSingleContribution is called as the second step to a single funder
// workflow to which we are the responder. It simply saves the remote peer's
// contribution to the channel, as solely the remote peer will contribute any
// funds to the channel. | [
"handleSingleContribution",
"is",
"called",
"as",
"the",
"second",
"step",
"to",
"a",
"single",
"funder",
"workflow",
"to",
"which",
"we",
"are",
"the",
"responder",
".",
"It",
"simply",
"saves",
"the",
"remote",
"peer",
"s",
"contribution",
"to",
"the",
"ch... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/wallet.go#L884-L919 |
129,018 | lightningnetwork/lnd | lnwallet/wallet.go | WithCoinSelectLock | func (l *LightningWallet) WithCoinSelectLock(f func() error) error {
l.coinSelectMtx.Lock()
defer l.coinSelectMtx.Unlock()
return f()
} | go | func (l *LightningWallet) WithCoinSelectLock(f func() error) error {
l.coinSelectMtx.Lock()
defer l.coinSelectMtx.Unlock()
return f()
} | [
"func",
"(",
"l",
"*",
"LightningWallet",
")",
"WithCoinSelectLock",
"(",
"f",
"func",
"(",
")",
"error",
")",
"error",
"{",
"l",
".",
"coinSelectMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"coinSelectMtx",
".",
"Unlock",
"(",
")",
"\n\n",
... | // WithCoinSelectLock will execute the passed function closure in a
// synchronized manner preventing any coin selection operations from proceeding
// while the closure if executing. This can be seen as the ability to execute a
// function closure under an exclusive coin selection lock. | [
"WithCoinSelectLock",
"will",
"execute",
"the",
"passed",
"function",
"closure",
"in",
"a",
"synchronized",
"manner",
"preventing",
"any",
"coin",
"selection",
"operations",
"from",
"proceeding",
"while",
"the",
"closure",
"if",
"executing",
".",
"This",
"can",
"b... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/wallet.go#L1260-L1265 |
129,019 | lightningnetwork/lnd | lnwallet/wallet.go | initStateHints | func initStateHints(commit1, commit2 *wire.MsgTx,
obfuscator [StateHintSize]byte) error {
if err := SetStateNumHint(commit1, 0, obfuscator); err != nil {
return err
}
if err := SetStateNumHint(commit2, 0, obfuscator); err != nil {
return err
}
return nil
} | go | func initStateHints(commit1, commit2 *wire.MsgTx,
obfuscator [StateHintSize]byte) error {
if err := SetStateNumHint(commit1, 0, obfuscator); err != nil {
return err
}
if err := SetStateNumHint(commit2, 0, obfuscator); err != nil {
return err
}
return nil
} | [
"func",
"initStateHints",
"(",
"commit1",
",",
"commit2",
"*",
"wire",
".",
"MsgTx",
",",
"obfuscator",
"[",
"StateHintSize",
"]",
"byte",
")",
"error",
"{",
"if",
"err",
":=",
"SetStateNumHint",
"(",
"commit1",
",",
"0",
",",
"obfuscator",
")",
";",
"er... | // initStateHints properly sets the obfuscated state hints on both commitment
// transactions using the passed obfuscator. | [
"initStateHints",
"properly",
"sets",
"the",
"obfuscated",
"state",
"hints",
"on",
"both",
"commitment",
"transactions",
"using",
"the",
"passed",
"obfuscator",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/wallet.go#L1360-L1371 |
129,020 | lightningnetwork/lnd | lnwallet/wallet.go | selectInputs | func selectInputs(amt btcutil.Amount, coins []*Utxo) (btcutil.Amount, []*Utxo, error) {
satSelected := btcutil.Amount(0)
for i, coin := range coins {
satSelected += coin.Value
if satSelected >= amt {
return satSelected, coins[:i+1], nil
}
}
return 0, nil, &ErrInsufficientFunds{amt, satSelected}
} | go | func selectInputs(amt btcutil.Amount, coins []*Utxo) (btcutil.Amount, []*Utxo, error) {
satSelected := btcutil.Amount(0)
for i, coin := range coins {
satSelected += coin.Value
if satSelected >= amt {
return satSelected, coins[:i+1], nil
}
}
return 0, nil, &ErrInsufficientFunds{amt, satSelected}
} | [
"func",
"selectInputs",
"(",
"amt",
"btcutil",
".",
"Amount",
",",
"coins",
"[",
"]",
"*",
"Utxo",
")",
"(",
"btcutil",
".",
"Amount",
",",
"[",
"]",
"*",
"Utxo",
",",
"error",
")",
"{",
"satSelected",
":=",
"btcutil",
".",
"Amount",
"(",
"0",
")",... | // selectInputs selects a slice of inputs necessary to meet the specified
// selection amount. If input selection is unable to succeed due to insufficient
// funds, a non-nil error is returned. Additionally, the total amount of the
// selected coins are returned in order for the caller to properly handle
// change+fees... | [
"selectInputs",
"selects",
"a",
"slice",
"of",
"inputs",
"necessary",
"to",
"meet",
"the",
"specified",
"selection",
"amount",
".",
"If",
"input",
"selection",
"is",
"unable",
"to",
"succeed",
"due",
"to",
"insufficient",
"funds",
"a",
"non",
"-",
"nil",
"er... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/wallet.go#L1378-L1387 |
129,021 | lightningnetwork/lnd | watchtower/lookout/lookout.go | Start | func (l *Lookout) Start() error {
if !atomic.CompareAndSwapInt32(&l.started, 0, 1) {
return nil
}
log.Infof("Starting lookout")
startEpoch, err := l.cfg.DB.GetLookoutTip()
if err != nil {
return err
}
if startEpoch == nil {
log.Infof("Starting lookout from chain tip")
} else {
log.Infof("Starting loo... | go | func (l *Lookout) Start() error {
if !atomic.CompareAndSwapInt32(&l.started, 0, 1) {
return nil
}
log.Infof("Starting lookout")
startEpoch, err := l.cfg.DB.GetLookoutTip()
if err != nil {
return err
}
if startEpoch == nil {
log.Infof("Starting lookout from chain tip")
} else {
log.Infof("Starting loo... | [
"func",
"(",
"l",
"*",
"Lookout",
")",
"Start",
"(",
")",
"error",
"{",
"if",
"!",
"atomic",
".",
"CompareAndSwapInt32",
"(",
"&",
"l",
".",
"started",
",",
"0",
",",
"1",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"log",
".",
"Infof",
"(",
... | // Start safely spins up the Lookout and begins monitoring for breaches. | [
"Start",
"safely",
"spins",
"up",
"the",
"Lookout",
"and",
"begins",
"monitoring",
"for",
"breaches",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/lookout/lookout.go#L57-L88 |
129,022 | lightningnetwork/lnd | watchtower/lookout/lookout.go | Stop | func (l *Lookout) Stop() error {
if !atomic.CompareAndSwapInt32(&l.shutdown, 0, 1) {
return nil
}
log.Infof("Stopping lookout")
close(l.quit)
l.wg.Wait()
log.Infof("Lookout stopped successfully")
return nil
} | go | func (l *Lookout) Stop() error {
if !atomic.CompareAndSwapInt32(&l.shutdown, 0, 1) {
return nil
}
log.Infof("Stopping lookout")
close(l.quit)
l.wg.Wait()
log.Infof("Lookout stopped successfully")
return nil
} | [
"func",
"(",
"l",
"*",
"Lookout",
")",
"Stop",
"(",
")",
"error",
"{",
"if",
"!",
"atomic",
".",
"CompareAndSwapInt32",
"(",
"&",
"l",
".",
"shutdown",
",",
"0",
",",
"1",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"log",
".",
"Infof",
"(",
... | // Stop safely shuts down the Lookout. | [
"Stop",
"safely",
"shuts",
"down",
"the",
"Lookout",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/lookout/lookout.go#L91-L104 |
129,023 | lightningnetwork/lnd | watchtower/lookout/lookout.go | watchBlocks | func (l *Lookout) watchBlocks(epochs *chainntnfs.BlockEpochEvent) {
defer l.wg.Done()
defer epochs.Cancel()
for {
select {
case epoch := <-epochs.Epochs:
log.Debugf("Fetching block for (height=%d, hash=%s)",
epoch.Height, epoch.Hash)
// Fetch the full block from the backend corresponding
// to the... | go | func (l *Lookout) watchBlocks(epochs *chainntnfs.BlockEpochEvent) {
defer l.wg.Done()
defer epochs.Cancel()
for {
select {
case epoch := <-epochs.Epochs:
log.Debugf("Fetching block for (height=%d, hash=%s)",
epoch.Height, epoch.Hash)
// Fetch the full block from the backend corresponding
// to the... | [
"func",
"(",
"l",
"*",
"Lookout",
")",
"watchBlocks",
"(",
"epochs",
"*",
"chainntnfs",
".",
"BlockEpochEvent",
")",
"{",
"defer",
"l",
".",
"wg",
".",
"Done",
"(",
")",
"\n",
"defer",
"epochs",
".",
"Cancel",
"(",
")",
"\n\n",
"for",
"{",
"select",
... | // watchBlocks serially pulls incoming epochs from the epoch source and searches
// our accepted state updates for any breached transactions. If any are found,
// we will attempt to decrypt the state updates' encrypted blobs and exact
// justice for the victim.
//
// This method MUST be run as a goroutine. | [
"watchBlocks",
"serially",
"pulls",
"incoming",
"epochs",
"from",
"the",
"epoch",
"source",
"and",
"searches",
"our",
"accepted",
"state",
"updates",
"for",
"any",
"breached",
"transactions",
".",
"If",
"any",
"are",
"found",
"we",
"will",
"attempt",
"to",
"de... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/lookout/lookout.go#L112-L145 |
129,024 | lightningnetwork/lnd | watchtower/lookout/lookout.go | processEpoch | func (l *Lookout) processEpoch(epoch *chainntnfs.BlockEpoch,
block *wire.MsgBlock) error {
numTxnsInBlock := len(block.Transactions)
log.Debugf("Scanning %d transaction in block (height=%d, hash=%s) "+
"for breaches", numTxnsInBlock, epoch.Height, epoch.Hash)
// Iterate over the transactions contained in the b... | go | func (l *Lookout) processEpoch(epoch *chainntnfs.BlockEpoch,
block *wire.MsgBlock) error {
numTxnsInBlock := len(block.Transactions)
log.Debugf("Scanning %d transaction in block (height=%d, hash=%s) "+
"for breaches", numTxnsInBlock, epoch.Height, epoch.Hash)
// Iterate over the transactions contained in the b... | [
"func",
"(",
"l",
"*",
"Lookout",
")",
"processEpoch",
"(",
"epoch",
"*",
"chainntnfs",
".",
"BlockEpoch",
",",
"block",
"*",
"wire",
".",
"MsgBlock",
")",
"error",
"{",
"numTxnsInBlock",
":=",
"len",
"(",
"block",
".",
"Transactions",
")",
"\n\n",
"log"... | // processEpoch accepts an Epoch and queries the database for any matching state
// updates for the confirmed transactions. If any are found, the lookout
// responds by attempting to decrypt the encrypted blob and publishing the
// justice transaction. | [
"processEpoch",
"accepts",
"an",
"Epoch",
"and",
"queries",
"the",
"database",
"for",
"any",
"matching",
"state",
"updates",
"for",
"the",
"confirmed",
"transactions",
".",
"If",
"any",
"are",
"found",
"the",
"lookout",
"responds",
"by",
"attempting",
"to",
"d... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/lookout/lookout.go#L151-L246 |
129,025 | lightningnetwork/lnd | watchtower/lookout/lookout.go | dispatchPunisher | func (l *Lookout) dispatchPunisher(desc *JusticeDescriptor) {
defer l.wg.Done()
// Give the justice descriptor to the punisher to construct and publish
// the justice transaction. The lookout's quit channel is provided so
// that long-running tasks that watch for on-chain events can be
// canceled during shutdown... | go | func (l *Lookout) dispatchPunisher(desc *JusticeDescriptor) {
defer l.wg.Done()
// Give the justice descriptor to the punisher to construct and publish
// the justice transaction. The lookout's quit channel is provided so
// that long-running tasks that watch for on-chain events can be
// canceled during shutdown... | [
"func",
"(",
"l",
"*",
"Lookout",
")",
"dispatchPunisher",
"(",
"desc",
"*",
"JusticeDescriptor",
")",
"{",
"defer",
"l",
".",
"wg",
".",
"Done",
"(",
")",
"\n\n",
"// Give the justice descriptor to the punisher to construct and publish",
"// the justice transaction. Th... | // dispatchPunisher accepts a justice descriptor corresponding to a successfully
// decrypted blob. The punisher will then construct the witness scripts and
// witness stacks for the breached outputs. If construction of the justice
// transaction is successful, it will be published to the network to retrieve
// the fu... | [
"dispatchPunisher",
"accepts",
"a",
"justice",
"descriptor",
"corresponding",
"to",
"a",
"successfully",
"decrypted",
"blob",
".",
"The",
"punisher",
"will",
"then",
"construct",
"the",
"witness",
"scripts",
"and",
"witness",
"stacks",
"for",
"the",
"breached",
"o... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/lookout/lookout.go#L255-L272 |
129,026 | lightningnetwork/lnd | lnwire/pong.go | Decode | func (p *Pong) Decode(r io.Reader, pver uint32) error {
return ReadElements(r,
&p.PongBytes,
)
} | go | func (p *Pong) Decode(r io.Reader, pver uint32) error {
return ReadElements(r,
&p.PongBytes,
)
} | [
"func",
"(",
"p",
"*",
"Pong",
")",
"Decode",
"(",
"r",
"io",
".",
"Reader",
",",
"pver",
"uint32",
")",
"error",
"{",
"return",
"ReadElements",
"(",
"r",
",",
"&",
"p",
".",
"PongBytes",
",",
")",
"\n",
"}"
] | // Decode deserializes a serialized Pong message stored in the passed io.Reader
// observing the specified protocol version.
//
// This is part of the lnwire.Message interface. | [
"Decode",
"deserializes",
"a",
"serialized",
"Pong",
"message",
"stored",
"in",
"the",
"passed",
"io",
".",
"Reader",
"observing",
"the",
"specified",
"protocol",
"version",
".",
"This",
"is",
"part",
"of",
"the",
"lnwire",
".",
"Message",
"interface",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/pong.go#L33-L37 |
129,027 | lightningnetwork/lnd | lnwire/pong.go | Encode | func (p *Pong) Encode(w io.Writer, pver uint32) error {
return WriteElements(w,
p.PongBytes,
)
} | go | func (p *Pong) Encode(w io.Writer, pver uint32) error {
return WriteElements(w,
p.PongBytes,
)
} | [
"func",
"(",
"p",
"*",
"Pong",
")",
"Encode",
"(",
"w",
"io",
".",
"Writer",
",",
"pver",
"uint32",
")",
"error",
"{",
"return",
"WriteElements",
"(",
"w",
",",
"p",
".",
"PongBytes",
",",
")",
"\n",
"}"
] | // Encode serializes the target Pong into the passed io.Writer observing the
// protocol version specified.
//
// This is part of the lnwire.Message interface. | [
"Encode",
"serializes",
"the",
"target",
"Pong",
"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/pong.go#L43-L47 |
129,028 | lightningnetwork/lnd | build/log.go | NewSubLogger | func NewSubLogger(subsystem string,
genSubLogger func(string) btclog.Logger) btclog.Logger {
switch Deployment {
// For production builds, generate a new subsystem logger from the
// primary log backend. If no function is provided, logging will be
// disabled.
case Production:
if genSubLogger != nil {
retu... | go | func NewSubLogger(subsystem string,
genSubLogger func(string) btclog.Logger) btclog.Logger {
switch Deployment {
// For production builds, generate a new subsystem logger from the
// primary log backend. If no function is provided, logging will be
// disabled.
case Production:
if genSubLogger != nil {
retu... | [
"func",
"NewSubLogger",
"(",
"subsystem",
"string",
",",
"genSubLogger",
"func",
"(",
"string",
")",
"btclog",
".",
"Logger",
")",
"btclog",
".",
"Logger",
"{",
"switch",
"Deployment",
"{",
"// For production builds, generate a new subsystem logger from the",
"// primar... | // NewSubLogger constructs a new subsystem log from the current LogWriter
// implementation. This is primarily intended for use with stdlog, as the actual
// writer is shared amongst all instantiations. | [
"NewSubLogger",
"constructs",
"a",
"new",
"subsystem",
"log",
"from",
"the",
"current",
"LogWriter",
"implementation",
".",
"This",
"is",
"primarily",
"intended",
"for",
"use",
"with",
"stdlog",
"as",
"the",
"actual",
"writer",
"is",
"shared",
"amongst",
"all",
... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/build/log.go#L51-L95 |
129,029 | lightningnetwork/lnd | htlcswitch/mailbox.go | newMemoryMailBox | func newMemoryMailBox() *memoryMailBox {
box := &memoryMailBox{
wireMessages: list.New(),
htlcPkts: list.New(),
messageOutbox: make(chan lnwire.Message),
pktOutbox: make(chan *htlcPacket),
msgReset: make(chan chan struct{}, 1),
pktReset: make(chan chan struct{}, 1),
pktIndex: mak... | go | func newMemoryMailBox() *memoryMailBox {
box := &memoryMailBox{
wireMessages: list.New(),
htlcPkts: list.New(),
messageOutbox: make(chan lnwire.Message),
pktOutbox: make(chan *htlcPacket),
msgReset: make(chan chan struct{}, 1),
pktReset: make(chan chan struct{}, 1),
pktIndex: mak... | [
"func",
"newMemoryMailBox",
"(",
")",
"*",
"memoryMailBox",
"{",
"box",
":=",
"&",
"memoryMailBox",
"{",
"wireMessages",
":",
"list",
".",
"New",
"(",
")",
",",
"htlcPkts",
":",
"list",
".",
"New",
"(",
")",
",",
"messageOutbox",
":",
"make",
"(",
"cha... | // newMemoryMailBox creates a new instance of the memoryMailBox. | [
"newMemoryMailBox",
"creates",
"a",
"new",
"instance",
"of",
"the",
"memoryMailBox",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/mailbox.go#L88-L103 |
129,030 | lightningnetwork/lnd | htlcswitch/mailbox.go | ResetMessages | func (m *memoryMailBox) ResetMessages() error {
msgDone := make(chan struct{})
select {
case m.msgReset <- msgDone:
return m.signalUntilReset(wireCourier, msgDone)
case <-m.quit:
return ErrMailBoxShuttingDown
}
} | go | func (m *memoryMailBox) ResetMessages() error {
msgDone := make(chan struct{})
select {
case m.msgReset <- msgDone:
return m.signalUntilReset(wireCourier, msgDone)
case <-m.quit:
return ErrMailBoxShuttingDown
}
} | [
"func",
"(",
"m",
"*",
"memoryMailBox",
")",
"ResetMessages",
"(",
")",
"error",
"{",
"msgDone",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"select",
"{",
"case",
"m",
".",
"msgReset",
"<-",
"msgDone",
":",
"return",
"m",
".",
"signalU... | // ResetMessages blocks until all buffered wire messages are cleared. | [
"ResetMessages",
"blocks",
"until",
"all",
"buffered",
"wire",
"messages",
"are",
"cleared",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/mailbox.go#L138-L146 |
129,031 | lightningnetwork/lnd | htlcswitch/mailbox.go | ResetPackets | func (m *memoryMailBox) ResetPackets() error {
pktDone := make(chan struct{})
select {
case m.pktReset <- pktDone:
return m.signalUntilReset(pktCourier, pktDone)
case <-m.quit:
return ErrMailBoxShuttingDown
}
} | go | func (m *memoryMailBox) ResetPackets() error {
pktDone := make(chan struct{})
select {
case m.pktReset <- pktDone:
return m.signalUntilReset(pktCourier, pktDone)
case <-m.quit:
return ErrMailBoxShuttingDown
}
} | [
"func",
"(",
"m",
"*",
"memoryMailBox",
")",
"ResetPackets",
"(",
")",
"error",
"{",
"pktDone",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"select",
"{",
"case",
"m",
".",
"pktReset",
"<-",
"pktDone",
":",
"return",
"m",
".",
"signalUn... | // ResetPackets blocks until the head of packets buffer is reset, causing the
// packets to be redelivered in order. | [
"ResetPackets",
"blocks",
"until",
"the",
"head",
"of",
"packets",
"buffer",
"is",
"reset",
"causing",
"the",
"packets",
"to",
"be",
"redelivered",
"in",
"order",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/mailbox.go#L150-L158 |
129,032 | lightningnetwork/lnd | htlcswitch/mailbox.go | signalUntilReset | func (m *memoryMailBox) signalUntilReset(cType courierType,
done chan struct{}) error {
for {
switch cType {
case wireCourier:
m.wireCond.Signal()
case pktCourier:
m.pktCond.Signal()
}
select {
case <-time.After(time.Millisecond):
continue
case <-done:
return nil
case <-m.quit:
return... | go | func (m *memoryMailBox) signalUntilReset(cType courierType,
done chan struct{}) error {
for {
switch cType {
case wireCourier:
m.wireCond.Signal()
case pktCourier:
m.pktCond.Signal()
}
select {
case <-time.After(time.Millisecond):
continue
case <-done:
return nil
case <-m.quit:
return... | [
"func",
"(",
"m",
"*",
"memoryMailBox",
")",
"signalUntilReset",
"(",
"cType",
"courierType",
",",
"done",
"chan",
"struct",
"{",
"}",
")",
"error",
"{",
"for",
"{",
"switch",
"cType",
"{",
"case",
"wireCourier",
":",
"m",
".",
"wireCond",
".",
"Signal",... | // signalUntilReset strobes the condition variable for the specified inbox type
// until receiving a response that the mailbox has processed a reset. | [
"signalUntilReset",
"strobes",
"the",
"condition",
"variable",
"for",
"the",
"specified",
"inbox",
"type",
"until",
"receiving",
"a",
"response",
"that",
"the",
"mailbox",
"has",
"processed",
"a",
"reset",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/mailbox.go#L162-L182 |
129,033 | lightningnetwork/lnd | htlcswitch/mailbox.go | HasPacket | func (m *memoryMailBox) HasPacket(inKey CircuitKey) bool {
m.pktCond.L.Lock()
_, ok := m.pktIndex[inKey]
m.pktCond.L.Unlock()
return ok
} | go | func (m *memoryMailBox) HasPacket(inKey CircuitKey) bool {
m.pktCond.L.Lock()
_, ok := m.pktIndex[inKey]
m.pktCond.L.Unlock()
return ok
} | [
"func",
"(",
"m",
"*",
"memoryMailBox",
")",
"HasPacket",
"(",
"inKey",
"CircuitKey",
")",
"bool",
"{",
"m",
".",
"pktCond",
".",
"L",
".",
"Lock",
"(",
")",
"\n",
"_",
",",
"ok",
":=",
"m",
".",
"pktIndex",
"[",
"inKey",
"]",
"\n",
"m",
".",
"... | // HasPacket queries the packets for a circuit key, this is used to drop packets
// bound for the switch that already have a queued response. | [
"HasPacket",
"queries",
"the",
"packets",
"for",
"a",
"circuit",
"key",
"this",
"is",
"used",
"to",
"drop",
"packets",
"bound",
"for",
"the",
"switch",
"that",
"already",
"have",
"a",
"queued",
"response",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/mailbox.go#L205-L211 |
129,034 | lightningnetwork/lnd | htlcswitch/mailbox.go | newMailOrchestrator | func newMailOrchestrator() *mailOrchestrator {
return &mailOrchestrator{
mailboxes: make(map[lnwire.ChannelID]MailBox),
liveIndex: make(map[lnwire.ShortChannelID]lnwire.ChannelID),
unclaimedPackets: make(map[lnwire.ShortChannelID][]*htlcPacket),
}
} | go | func newMailOrchestrator() *mailOrchestrator {
return &mailOrchestrator{
mailboxes: make(map[lnwire.ChannelID]MailBox),
liveIndex: make(map[lnwire.ShortChannelID]lnwire.ChannelID),
unclaimedPackets: make(map[lnwire.ShortChannelID][]*htlcPacket),
}
} | [
"func",
"newMailOrchestrator",
"(",
")",
"*",
"mailOrchestrator",
"{",
"return",
"&",
"mailOrchestrator",
"{",
"mailboxes",
":",
"make",
"(",
"map",
"[",
"lnwire",
".",
"ChannelID",
"]",
"MailBox",
")",
",",
"liveIndex",
":",
"make",
"(",
"map",
"[",
"lnwi... | // newMailOrchestrator initializes a fresh mailOrchestrator. | [
"newMailOrchestrator",
"initializes",
"a",
"fresh",
"mailOrchestrator",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/mailbox.go#L435-L441 |
129,035 | lightningnetwork/lnd | htlcswitch/mailbox.go | GetOrCreateMailBox | func (mo *mailOrchestrator) GetOrCreateMailBox(chanID lnwire.ChannelID) MailBox {
// First, try lookup the mailbox directly using only the shared mutex.
mo.mu.RLock()
mailbox, ok := mo.mailboxes[chanID]
if ok {
mo.mu.RUnlock()
return mailbox
}
mo.mu.RUnlock()
// Otherwise, we will try again with exclusive l... | go | func (mo *mailOrchestrator) GetOrCreateMailBox(chanID lnwire.ChannelID) MailBox {
// First, try lookup the mailbox directly using only the shared mutex.
mo.mu.RLock()
mailbox, ok := mo.mailboxes[chanID]
if ok {
mo.mu.RUnlock()
return mailbox
}
mo.mu.RUnlock()
// Otherwise, we will try again with exclusive l... | [
"func",
"(",
"mo",
"*",
"mailOrchestrator",
")",
"GetOrCreateMailBox",
"(",
"chanID",
"lnwire",
".",
"ChannelID",
")",
"MailBox",
"{",
"// First, try lookup the mailbox directly using only the shared mutex.",
"mo",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"mailbox",
... | // GetOrCreateMailBox returns an existing mailbox belonging to `chanID`, or
// creates and returns a new mailbox if none is found. | [
"GetOrCreateMailBox",
"returns",
"an",
"existing",
"mailbox",
"belonging",
"to",
"chanID",
"or",
"creates",
"and",
"returns",
"a",
"new",
"mailbox",
"if",
"none",
"is",
"found",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/mailbox.go#L452-L469 |
129,036 | lightningnetwork/lnd | htlcswitch/mailbox.go | Deliver | func (mo *mailOrchestrator) Deliver(
sid lnwire.ShortChannelID, pkt *htlcPacket) error {
var (
mailbox MailBox
found bool
)
// First, try to find the channel id for the target short_chan_id. If
// the link is live, we will also look up the created mailbox.
mo.mu.RLock()
chanID, isLive := mo.liveIndex[sid... | go | func (mo *mailOrchestrator) Deliver(
sid lnwire.ShortChannelID, pkt *htlcPacket) error {
var (
mailbox MailBox
found bool
)
// First, try to find the channel id for the target short_chan_id. If
// the link is live, we will also look up the created mailbox.
mo.mu.RLock()
chanID, isLive := mo.liveIndex[sid... | [
"func",
"(",
"mo",
"*",
"mailOrchestrator",
")",
"Deliver",
"(",
"sid",
"lnwire",
".",
"ShortChannelID",
",",
"pkt",
"*",
"htlcPacket",
")",
"error",
"{",
"var",
"(",
"mailbox",
"MailBox",
"\n",
"found",
"bool",
"\n",
")",
"\n\n",
"// First, try to find the ... | // Deliver lookups the target mailbox using the live index from short_chan_id
// to channel_id. If the mailbox is found, the message is delivered directly.
// Otherwise the packet is recorded as unclaimed, and will be delivered to the
// mailbox upon the subsequent call to BindLiveShortChanID. | [
"Deliver",
"lookups",
"the",
"target",
"mailbox",
"using",
"the",
"live",
"index",
"from",
"short_chan_id",
"to",
"channel_id",
".",
"If",
"the",
"mailbox",
"is",
"found",
"the",
"message",
"is",
"delivered",
"directly",
".",
"Otherwise",
"the",
"packet",
"is"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/mailbox.go#L516-L575 |
129,037 | lightningnetwork/lnd | chainntnfs/neutrinonotify/neutrino.go | Start | func (n *NeutrinoNotifier) Start() error {
// Already started?
if atomic.AddInt32(&n.started, 1) != 1 {
return nil
}
// First, we'll obtain the latest block height of the p2p node. We'll
// start the auto-rescan from this point. Once a caller actually wishes
// to register a chain view, the rescan state will b... | go | func (n *NeutrinoNotifier) Start() error {
// Already started?
if atomic.AddInt32(&n.started, 1) != 1 {
return nil
}
// First, we'll obtain the latest block height of the p2p node. We'll
// start the auto-rescan from this point. Once a caller actually wishes
// to register a chain view, the rescan state will b... | [
"func",
"(",
"n",
"*",
"NeutrinoNotifier",
")",
"Start",
"(",
")",
"error",
"{",
"// Already started?",
"if",
"atomic",
".",
"AddInt32",
"(",
"&",
"n",
".",
"started",
",",
"1",
")",
"!=",
"1",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// First, we'll ... | // Start contacts the running neutrino light client and kicks off an initial
// empty rescan. | [
"Start",
"contacts",
"the",
"running",
"neutrino",
"light",
"client",
"and",
"kicks",
"off",
"an",
"initial",
"empty",
"rescan",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/neutrinonotify/neutrino.go#L115-L172 |
129,038 | lightningnetwork/lnd | chainntnfs/neutrinonotify/neutrino.go | Stop | func (n *NeutrinoNotifier) Stop() error {
// Already shutting down?
if atomic.AddInt32(&n.stopped, 1) != 1 {
return nil
}
close(n.quit)
n.wg.Wait()
n.chainUpdates.Stop()
n.txUpdates.Stop()
// Notify all pending clients of our shutdown by closing the related
// notification channels.
for _, epochClient :=... | go | func (n *NeutrinoNotifier) Stop() error {
// Already shutting down?
if atomic.AddInt32(&n.stopped, 1) != 1 {
return nil
}
close(n.quit)
n.wg.Wait()
n.chainUpdates.Stop()
n.txUpdates.Stop()
// Notify all pending clients of our shutdown by closing the related
// notification channels.
for _, epochClient :=... | [
"func",
"(",
"n",
"*",
"NeutrinoNotifier",
")",
"Stop",
"(",
")",
"error",
"{",
"// Already shutting down?",
"if",
"atomic",
".",
"AddInt32",
"(",
"&",
"n",
".",
"stopped",
",",
"1",
")",
"!=",
"1",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"close",
"... | // Stop shuts down the NeutrinoNotifier. | [
"Stop",
"shuts",
"down",
"the",
"NeutrinoNotifier",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/neutrinonotify/neutrino.go#L175-L198 |
129,039 | lightningnetwork/lnd | chainntnfs/neutrinonotify/neutrino.go | onFilteredBlockConnected | func (n *NeutrinoNotifier) onFilteredBlockConnected(height int32,
header *wire.BlockHeader, txns []*btcutil.Tx) {
// Append this new chain update to the end of the queue of new chain
// updates.
select {
case n.chainUpdates.ChanIn() <- &filteredBlock{
hash: header.BlockHash(),
height: uint32(height),
tx... | go | func (n *NeutrinoNotifier) onFilteredBlockConnected(height int32,
header *wire.BlockHeader, txns []*btcutil.Tx) {
// Append this new chain update to the end of the queue of new chain
// updates.
select {
case n.chainUpdates.ChanIn() <- &filteredBlock{
hash: header.BlockHash(),
height: uint32(height),
tx... | [
"func",
"(",
"n",
"*",
"NeutrinoNotifier",
")",
"onFilteredBlockConnected",
"(",
"height",
"int32",
",",
"header",
"*",
"wire",
".",
"BlockHeader",
",",
"txns",
"[",
"]",
"*",
"btcutil",
".",
"Tx",
")",
"{",
"// Append this new chain update to the end of the queue... | // onFilteredBlockConnected is a callback which is executed each a new block is
// connected to the end of the main chain. | [
"onFilteredBlockConnected",
"is",
"a",
"callback",
"which",
"is",
"executed",
"each",
"a",
"new",
"block",
"is",
"connected",
"to",
"the",
"end",
"of",
"the",
"main",
"chain",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/neutrinonotify/neutrino.go#L224-L238 |
129,040 | lightningnetwork/lnd | chainntnfs/neutrinonotify/neutrino.go | onFilteredBlockDisconnected | func (n *NeutrinoNotifier) onFilteredBlockDisconnected(height int32,
header *wire.BlockHeader) {
// Append this new chain update to the end of the queue of new chain
// disconnects.
select {
case n.chainUpdates.ChanIn() <- &filteredBlock{
hash: header.BlockHash(),
height: uint32(height),
connect: false,... | go | func (n *NeutrinoNotifier) onFilteredBlockDisconnected(height int32,
header *wire.BlockHeader) {
// Append this new chain update to the end of the queue of new chain
// disconnects.
select {
case n.chainUpdates.ChanIn() <- &filteredBlock{
hash: header.BlockHash(),
height: uint32(height),
connect: false,... | [
"func",
"(",
"n",
"*",
"NeutrinoNotifier",
")",
"onFilteredBlockDisconnected",
"(",
"height",
"int32",
",",
"header",
"*",
"wire",
".",
"BlockHeader",
")",
"{",
"// Append this new chain update to the end of the queue of new chain",
"// disconnects.",
"select",
"{",
"case... | // onFilteredBlockDisconnected is a callback which is executed each time a new
// block has been disconnected from the end of the mainchain due to a re-org. | [
"onFilteredBlockDisconnected",
"is",
"a",
"callback",
"which",
"is",
"executed",
"each",
"time",
"a",
"new",
"block",
"has",
"been",
"disconnected",
"from",
"the",
"end",
"of",
"the",
"mainchain",
"due",
"to",
"a",
"re",
"-",
"org",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/neutrinonotify/neutrino.go#L242-L255 |
129,041 | lightningnetwork/lnd | chainntnfs/neutrinonotify/neutrino.go | onRelevantTx | func (n *NeutrinoNotifier) onRelevantTx(tx *btcutil.Tx, details *btcjson.BlockDetails) {
select {
case n.txUpdates.ChanIn() <- &relevantTx{tx, details}:
case <-n.quit:
}
} | go | func (n *NeutrinoNotifier) onRelevantTx(tx *btcutil.Tx, details *btcjson.BlockDetails) {
select {
case n.txUpdates.ChanIn() <- &relevantTx{tx, details}:
case <-n.quit:
}
} | [
"func",
"(",
"n",
"*",
"NeutrinoNotifier",
")",
"onRelevantTx",
"(",
"tx",
"*",
"btcutil",
".",
"Tx",
",",
"details",
"*",
"btcjson",
".",
"BlockDetails",
")",
"{",
"select",
"{",
"case",
"n",
".",
"txUpdates",
".",
"ChanIn",
"(",
")",
"<-",
"&",
"re... | // onRelevantTx is a callback that proxies relevant transaction notifications
// from the backend to the notifier's main event handler. | [
"onRelevantTx",
"is",
"a",
"callback",
"that",
"proxies",
"relevant",
"transaction",
"notifications",
"from",
"the",
"backend",
"to",
"the",
"notifier",
"s",
"main",
"event",
"handler",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/neutrinonotify/neutrino.go#L266-L271 |
129,042 | lightningnetwork/lnd | chainntnfs/neutrinonotify/neutrino.go | getFilteredBlock | func (n *NeutrinoNotifier) getFilteredBlock(epoch chainntnfs.BlockEpoch) (*filteredBlock, error) {
rawBlock, err := n.p2pNode.GetBlock(*epoch.Hash)
if err != nil {
return nil, fmt.Errorf("unable to get block: %v", err)
}
txns := rawBlock.Transactions()
block := &filteredBlock{
hash: *epoch.Hash,
height:... | go | func (n *NeutrinoNotifier) getFilteredBlock(epoch chainntnfs.BlockEpoch) (*filteredBlock, error) {
rawBlock, err := n.p2pNode.GetBlock(*epoch.Hash)
if err != nil {
return nil, fmt.Errorf("unable to get block: %v", err)
}
txns := rawBlock.Transactions()
block := &filteredBlock{
hash: *epoch.Hash,
height:... | [
"func",
"(",
"n",
"*",
"NeutrinoNotifier",
")",
"getFilteredBlock",
"(",
"epoch",
"chainntnfs",
".",
"BlockEpoch",
")",
"(",
"*",
"filteredBlock",
",",
"error",
")",
"{",
"rawBlock",
",",
"err",
":=",
"n",
".",
"p2pNode",
".",
"GetBlock",
"(",
"*",
"epoc... | // getFilteredBlock is a utility to retrieve the full filtered block from a block epoch. | [
"getFilteredBlock",
"is",
"a",
"utility",
"to",
"retrieve",
"the",
"full",
"filtered",
"block",
"from",
"a",
"block",
"epoch",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/neutrinonotify/neutrino.go#L613-L628 |
129,043 | lightningnetwork/lnd | chainntnfs/neutrinonotify/neutrino.go | RegisterBlockEpochNtfn | func (n *NeutrinoNotifier) RegisterBlockEpochNtfn(
bestBlock *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error) {
reg := &blockEpochRegistration{
epochQueue: queue.NewConcurrentQueue(20),
epochChan: make(chan *chainntnfs.BlockEpoch, 20),
cancelChan: make(chan struct{}),
epochID: atomic.AddUint6... | go | func (n *NeutrinoNotifier) RegisterBlockEpochNtfn(
bestBlock *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error) {
reg := &blockEpochRegistration{
epochQueue: queue.NewConcurrentQueue(20),
epochChan: make(chan *chainntnfs.BlockEpoch, 20),
cancelChan: make(chan struct{}),
epochID: atomic.AddUint6... | [
"func",
"(",
"n",
"*",
"NeutrinoNotifier",
")",
"RegisterBlockEpochNtfn",
"(",
"bestBlock",
"*",
"chainntnfs",
".",
"BlockEpoch",
")",
"(",
"*",
"chainntnfs",
".",
"BlockEpochEvent",
",",
"error",
")",
"{",
"reg",
":=",
"&",
"blockEpochRegistration",
"{",
"epo... | // RegisterBlockEpochNtfn returns a BlockEpochEvent which subscribes the
// caller to receive notifications, of each new block connected to the main
// chain. Clients have the option of passing in their best known block, which
// the notifier uses to check if they are behind on blocks and catch them up. If
// they do n... | [
"RegisterBlockEpochNtfn",
"returns",
"a",
"BlockEpochEvent",
"which",
"subscribes",
"the",
"caller",
"to",
"receive",
"notifications",
"of",
"each",
"new",
"block",
"connected",
"to",
"the",
"main",
"chain",
".",
"Clients",
"have",
"the",
"option",
"of",
"passing"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/neutrinonotify/neutrino.go#L929-L1008 |
129,044 | lightningnetwork/lnd | chainntnfs/neutrinonotify/neutrino.go | GetBlockHeader | func (n *NeutrinoChainConn) GetBlockHeader(blockHash *chainhash.Hash) (*wire.BlockHeader, error) {
return n.p2pNode.GetBlockHeader(blockHash)
} | go | func (n *NeutrinoChainConn) GetBlockHeader(blockHash *chainhash.Hash) (*wire.BlockHeader, error) {
return n.p2pNode.GetBlockHeader(blockHash)
} | [
"func",
"(",
"n",
"*",
"NeutrinoChainConn",
")",
"GetBlockHeader",
"(",
"blockHash",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"wire",
".",
"BlockHeader",
",",
"error",
")",
"{",
"return",
"n",
".",
"p2pNode",
".",
"GetBlockHeader",
"(",
"blockHash",
... | // GetBlockHeader returns the block header for a hash. | [
"GetBlockHeader",
"returns",
"the",
"block",
"header",
"for",
"a",
"hash",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/neutrinonotify/neutrino.go#L1017-L1019 |
129,045 | lightningnetwork/lnd | chainntnfs/neutrinonotify/neutrino.go | GetBlockHeaderVerbose | func (n *NeutrinoChainConn) GetBlockHeaderVerbose(blockHash *chainhash.Hash) (
*btcjson.GetBlockHeaderVerboseResult, error) {
height, err := n.p2pNode.GetBlockHeight(blockHash)
if err != nil {
return nil, err
}
// Since only the height is used from the result, leave the hash nil.
return &btcjson.GetBlockHeader... | go | func (n *NeutrinoChainConn) GetBlockHeaderVerbose(blockHash *chainhash.Hash) (
*btcjson.GetBlockHeaderVerboseResult, error) {
height, err := n.p2pNode.GetBlockHeight(blockHash)
if err != nil {
return nil, err
}
// Since only the height is used from the result, leave the hash nil.
return &btcjson.GetBlockHeader... | [
"func",
"(",
"n",
"*",
"NeutrinoChainConn",
")",
"GetBlockHeaderVerbose",
"(",
"blockHash",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"btcjson",
".",
"GetBlockHeaderVerboseResult",
",",
"error",
")",
"{",
"height",
",",
"err",
":=",
"n",
".",
"p2pNode",
... | // GetBlockHeaderVerbose returns a verbose block header result for a hash. This
// result only contains the height with a nil hash. | [
"GetBlockHeaderVerbose",
"returns",
"a",
"verbose",
"block",
"header",
"result",
"for",
"a",
"hash",
".",
"This",
"result",
"only",
"contains",
"the",
"height",
"with",
"a",
"nil",
"hash",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/neutrinonotify/neutrino.go#L1023-L1032 |
129,046 | lightningnetwork/lnd | chainntnfs/neutrinonotify/neutrino.go | GetBlockHash | func (n *NeutrinoChainConn) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) {
return n.p2pNode.GetBlockHash(blockHeight)
} | go | func (n *NeutrinoChainConn) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) {
return n.p2pNode.GetBlockHash(blockHeight)
} | [
"func",
"(",
"n",
"*",
"NeutrinoChainConn",
")",
"GetBlockHash",
"(",
"blockHeight",
"int64",
")",
"(",
"*",
"chainhash",
".",
"Hash",
",",
"error",
")",
"{",
"return",
"n",
".",
"p2pNode",
".",
"GetBlockHash",
"(",
"blockHeight",
")",
"\n",
"}"
] | // GetBlockHash returns the hash from a block height. | [
"GetBlockHash",
"returns",
"the",
"hash",
"from",
"a",
"block",
"height",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/neutrinonotify/neutrino.go#L1035-L1037 |
129,047 | lightningnetwork/lnd | watchtower/wtwire/delete_session_reply.go | Decode | func (m *DeleteSessionReply) Decode(r io.Reader, pver uint32) error {
return ReadElements(r,
&m.Code,
)
} | go | func (m *DeleteSessionReply) Decode(r io.Reader, pver uint32) error {
return ReadElements(r,
&m.Code,
)
} | [
"func",
"(",
"m",
"*",
"DeleteSessionReply",
")",
"Decode",
"(",
"r",
"io",
".",
"Reader",
",",
"pver",
"uint32",
")",
"error",
"{",
"return",
"ReadElements",
"(",
"r",
",",
"&",
"m",
".",
"Code",
",",
")",
"\n",
"}"
] | // Decode deserializes a serialized DeleteSessionReply message stored in the
// passed io.Reader observing the specified protocol version.
//
// This is part of the wtwire.Message interface. | [
"Decode",
"deserializes",
"a",
"serialized",
"DeleteSessionReply",
"message",
"stored",
"in",
"the",
"passed",
"io",
".",
"Reader",
"observing",
"the",
"specified",
"protocol",
"version",
".",
"This",
"is",
"part",
"of",
"the",
"wtwire",
".",
"Message",
"interfa... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtwire/delete_session_reply.go#L34-L38 |
129,048 | lightningnetwork/lnd | watchtower/wtwire/delete_session_reply.go | Encode | func (m *DeleteSessionReply) Encode(w io.Writer, pver uint32) error {
return WriteElements(w,
m.Code,
)
} | go | func (m *DeleteSessionReply) Encode(w io.Writer, pver uint32) error {
return WriteElements(w,
m.Code,
)
} | [
"func",
"(",
"m",
"*",
"DeleteSessionReply",
")",
"Encode",
"(",
"w",
"io",
".",
"Writer",
",",
"pver",
"uint32",
")",
"error",
"{",
"return",
"WriteElements",
"(",
"w",
",",
"m",
".",
"Code",
",",
")",
"\n",
"}"
] | // Encode serializes the target DeleteSessionReply into the passed io.Writer
// observing the protocol version specified.
//
// This is part of the wtwire.Message interface. | [
"Encode",
"serializes",
"the",
"target",
"DeleteSessionReply",
"into",
"the",
"passed",
"io",
".",
"Writer",
"observing",
"the",
"protocol",
"version",
"specified",
".",
"This",
"is",
"part",
"of",
"the",
"wtwire",
".",
"Message",
"interface",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtwire/delete_session_reply.go#L44-L48 |
129,049 | lightningnetwork/lnd | lnwire/error.go | Decode | func (c *Error) Decode(r io.Reader, pver uint32) error {
return ReadElements(r,
&c.ChanID,
&c.Data,
)
} | go | func (c *Error) Decode(r io.Reader, pver uint32) error {
return ReadElements(r,
&c.ChanID,
&c.Data,
)
} | [
"func",
"(",
"c",
"*",
"Error",
")",
"Decode",
"(",
"r",
"io",
".",
"Reader",
",",
"pver",
"uint32",
")",
"error",
"{",
"return",
"ReadElements",
"(",
"r",
",",
"&",
"c",
".",
"ChanID",
",",
"&",
"c",
".",
"Data",
",",
")",
"\n",
"}"
] | // Decode deserializes a serialized Error message stored in the passed
// io.Reader observing the specified protocol version.
//
// This is part of the lnwire.Message interface. | [
"Decode",
"deserializes",
"a",
"serialized",
"Error",
"message",
"stored",
"in",
"the",
"passed",
"io",
".",
"Reader",
"observing",
"the",
"specified",
"protocol",
"version",
".",
"This",
"is",
"part",
"of",
"the",
"lnwire",
".",
"Message",
"interface",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/error.go#L94-L99 |
129,050 | lightningnetwork/lnd | lnwire/error.go | Encode | func (c *Error) Encode(w io.Writer, pver uint32) error {
return WriteElements(w,
c.ChanID,
c.Data,
)
} | go | func (c *Error) Encode(w io.Writer, pver uint32) error {
return WriteElements(w,
c.ChanID,
c.Data,
)
} | [
"func",
"(",
"c",
"*",
"Error",
")",
"Encode",
"(",
"w",
"io",
".",
"Writer",
",",
"pver",
"uint32",
")",
"error",
"{",
"return",
"WriteElements",
"(",
"w",
",",
"c",
".",
"ChanID",
",",
"c",
".",
"Data",
",",
")",
"\n",
"}"
] | // Encode serializes the target Error into the passed io.Writer observing the
// protocol version specified.
//
// This is part of the lnwire.Message interface. | [
"Encode",
"serializes",
"the",
"target",
"Error",
"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/error.go#L105-L110 |
129,051 | lightningnetwork/lnd | channeldb/graph.go | newChannelGraph | func newChannelGraph(db *DB, rejectCacheSize, chanCacheSize int) *ChannelGraph {
return &ChannelGraph{
db: db,
rejectCache: newRejectCache(rejectCacheSize),
chanCache: newChannelCache(chanCacheSize),
}
} | go | func newChannelGraph(db *DB, rejectCacheSize, chanCacheSize int) *ChannelGraph {
return &ChannelGraph{
db: db,
rejectCache: newRejectCache(rejectCacheSize),
chanCache: newChannelCache(chanCacheSize),
}
} | [
"func",
"newChannelGraph",
"(",
"db",
"*",
"DB",
",",
"rejectCacheSize",
",",
"chanCacheSize",
"int",
")",
"*",
"ChannelGraph",
"{",
"return",
"&",
"ChannelGraph",
"{",
"db",
":",
"db",
",",
"rejectCache",
":",
"newRejectCache",
"(",
"rejectCacheSize",
")",
... | // newChannelGraph allocates a new ChannelGraph backed by a DB instance. The
// returned instance has its own unique reject cache and channel cache. | [
"newChannelGraph",
"allocates",
"a",
"new",
"ChannelGraph",
"backed",
"by",
"a",
"DB",
"instance",
".",
"The",
"returned",
"instance",
"has",
"its",
"own",
"unique",
"reject",
"cache",
"and",
"channel",
"cache",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L168-L174 |
129,052 | lightningnetwork/lnd | channeldb/graph.go | SourceNode | func (c *ChannelGraph) SourceNode() (*LightningNode, error) {
var source *LightningNode
err := c.db.View(func(tx *bbolt.Tx) error {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes := tx.Bucket(nodeBucket)
if nodes == nil {
return ErrGraphNotFound
}
nod... | go | func (c *ChannelGraph) SourceNode() (*LightningNode, error) {
var source *LightningNode
err := c.db.View(func(tx *bbolt.Tx) error {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes := tx.Bucket(nodeBucket)
if nodes == nil {
return ErrGraphNotFound
}
nod... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"SourceNode",
"(",
")",
"(",
"*",
"LightningNode",
",",
"error",
")",
"{",
"var",
"source",
"*",
"LightningNode",
"\n",
"err",
":=",
"c",
".",
"db",
".",
"View",
"(",
"func",
"(",
"tx",
"*",
"bbolt",
".",... | // SourceNode returns the source node of the graph. The source node is treated
// as the center node within a star-graph. This method may be used to kick off
// a path finding algorithm in order to explore the reachability of another
// node based off the source node. | [
"SourceNode",
"returns",
"the",
"source",
"node",
"of",
"the",
"graph",
".",
"The",
"source",
"node",
"is",
"treated",
"as",
"the",
"center",
"node",
"within",
"a",
"star",
"-",
"graph",
".",
"This",
"method",
"may",
"be",
"used",
"to",
"kick",
"off",
... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L296-L319 |
129,053 | lightningnetwork/lnd | channeldb/graph.go | sourceNode | func (c *ChannelGraph) sourceNode(nodes *bbolt.Bucket) (*LightningNode, error) {
selfPub := nodes.Get(sourceKey)
if selfPub == nil {
return nil, ErrSourceNodeNotSet
}
// With the pubKey of the source node retrieved, we're able to
// fetch the full node information.
node, err := fetchLightningNode(nodes, selfPu... | go | func (c *ChannelGraph) sourceNode(nodes *bbolt.Bucket) (*LightningNode, error) {
selfPub := nodes.Get(sourceKey)
if selfPub == nil {
return nil, ErrSourceNodeNotSet
}
// With the pubKey of the source node retrieved, we're able to
// fetch the full node information.
node, err := fetchLightningNode(nodes, selfPu... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"sourceNode",
"(",
"nodes",
"*",
"bbolt",
".",
"Bucket",
")",
"(",
"*",
"LightningNode",
",",
"error",
")",
"{",
"selfPub",
":=",
"nodes",
".",
"Get",
"(",
"sourceKey",
")",
"\n",
"if",
"selfPub",
"==",
"ni... | // sourceNode uses an existing database transaction and returns the source node
// of the graph. The source node is treated as the center node within a
// star-graph. This method may be used to kick off a path finding algorithm in
// order to explore the reachability of another node based off the source node. | [
"sourceNode",
"uses",
"an",
"existing",
"database",
"transaction",
"and",
"returns",
"the",
"source",
"node",
"of",
"the",
"graph",
".",
"The",
"source",
"node",
"is",
"treated",
"as",
"the",
"center",
"node",
"within",
"a",
"star",
"-",
"graph",
".",
"Thi... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L325-L340 |
129,054 | lightningnetwork/lnd | channeldb/graph.go | SetSourceNode | func (c *ChannelGraph) SetSourceNode(node *LightningNode) error {
nodePubBytes := node.PubKeyBytes[:]
return c.db.Update(func(tx *bbolt.Tx) error {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes, err := tx.CreateBucketIfNotExists(nodeBucket)
if err != nil {
... | go | func (c *ChannelGraph) SetSourceNode(node *LightningNode) error {
nodePubBytes := node.PubKeyBytes[:]
return c.db.Update(func(tx *bbolt.Tx) error {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes, err := tx.CreateBucketIfNotExists(nodeBucket)
if err != nil {
... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"SetSourceNode",
"(",
"node",
"*",
"LightningNode",
")",
"error",
"{",
"nodePubBytes",
":=",
"node",
".",
"PubKeyBytes",
"[",
":",
"]",
"\n\n",
"return",
"c",
".",
"db",
".",
"Update",
"(",
"func",
"(",
"tx",... | // SetSourceNode sets the source node within the graph database. The source
// node is to be used as the center of a star-graph within path finding
// algorithms. | [
"SetSourceNode",
"sets",
"the",
"source",
"node",
"within",
"the",
"graph",
"database",
".",
"The",
"source",
"node",
"is",
"to",
"be",
"used",
"as",
"the",
"center",
"of",
"a",
"star",
"-",
"graph",
"within",
"path",
"finding",
"algorithms",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L345-L366 |
129,055 | lightningnetwork/lnd | channeldb/graph.go | addChannelEdge | func (c *ChannelGraph) addChannelEdge(tx *bbolt.Tx, edge *ChannelEdgeInfo) error {
// Construct the channel's primary key which is the 8-byte channel ID.
var chanKey [8]byte
binary.BigEndian.PutUint64(chanKey[:], edge.ChannelID)
nodes, err := tx.CreateBucketIfNotExists(nodeBucket)
if err != nil {
return err
}
... | go | func (c *ChannelGraph) addChannelEdge(tx *bbolt.Tx, edge *ChannelEdgeInfo) error {
// Construct the channel's primary key which is the 8-byte channel ID.
var chanKey [8]byte
binary.BigEndian.PutUint64(chanKey[:], edge.ChannelID)
nodes, err := tx.CreateBucketIfNotExists(nodeBucket)
if err != nil {
return err
}
... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"addChannelEdge",
"(",
"tx",
"*",
"bbolt",
".",
"Tx",
",",
"edge",
"*",
"ChannelEdgeInfo",
")",
"error",
"{",
"// Construct the channel's primary key which is the 8-byte channel ID.",
"var",
"chanKey",
"[",
"8",
"]",
"by... | // addChannelEdge is the private form of AddChannelEdge that allows callers to
// utilize an existing db transaction. | [
"addChannelEdge",
"is",
"the",
"private",
"form",
"of",
"AddChannelEdge",
"that",
"allows",
"callers",
"to",
"utilize",
"an",
"existing",
"db",
"transaction",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L523-L615 |
129,056 | lightningnetwork/lnd | channeldb/graph.go | UpdateChannelEdge | func (c *ChannelGraph) UpdateChannelEdge(edge *ChannelEdgeInfo) error {
// Construct the channel's primary key which is the 8-byte channel ID.
var chanKey [8]byte
binary.BigEndian.PutUint64(chanKey[:], edge.ChannelID)
return c.db.Update(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edge == nil {... | go | func (c *ChannelGraph) UpdateChannelEdge(edge *ChannelEdgeInfo) error {
// Construct the channel's primary key which is the 8-byte channel ID.
var chanKey [8]byte
binary.BigEndian.PutUint64(chanKey[:], edge.ChannelID)
return c.db.Update(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edge == nil {... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"UpdateChannelEdge",
"(",
"edge",
"*",
"ChannelEdgeInfo",
")",
"error",
"{",
"// Construct the channel's primary key which is the 8-byte channel ID.",
"var",
"chanKey",
"[",
"8",
"]",
"byte",
"\n",
"binary",
".",
"BigEndian"... | // UpdateChannelEdge retrieves and update edge of the graph database. Method
// only reserved for updating an edge info after its already been created.
// In order to maintain this constraints, we return an error in the scenario
// that an edge info hasn't yet been created yet, but someone attempts to update
// it. | [
"UpdateChannelEdge",
"retrieves",
"and",
"update",
"edge",
"of",
"the",
"graph",
"database",
".",
"Method",
"only",
"reserved",
"for",
"updating",
"an",
"edge",
"info",
"after",
"its",
"already",
"been",
"created",
".",
"In",
"order",
"to",
"maintain",
"this",... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L730-L752 |
129,057 | lightningnetwork/lnd | channeldb/graph.go | PruneGraph | func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
blockHash *chainhash.Hash, blockHeight uint32) ([]*ChannelEdgeInfo, error) {
c.cacheMu.Lock()
defer c.cacheMu.Unlock()
var chansClosed []*ChannelEdgeInfo
err := c.db.Update(func(tx *bbolt.Tx) error {
// First grab the edges bucket which houses t... | go | func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
blockHash *chainhash.Hash, blockHeight uint32) ([]*ChannelEdgeInfo, error) {
c.cacheMu.Lock()
defer c.cacheMu.Unlock()
var chansClosed []*ChannelEdgeInfo
err := c.db.Update(func(tx *bbolt.Tx) error {
// First grab the edges bucket which houses t... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"PruneGraph",
"(",
"spentOutputs",
"[",
"]",
"*",
"wire",
".",
"OutPoint",
",",
"blockHash",
"*",
"chainhash",
".",
"Hash",
",",
"blockHeight",
"uint32",
")",
"(",
"[",
"]",
"*",
"ChannelEdgeInfo",
",",
"error"... | // PruneGraph prunes newly closed channels from the channel graph in response
// to a new block being solved on the network. Any transactions which spend the
// funding output of any known channels within he graph will be deleted.
// Additionally, the "prune tip", or the last block which has been used to
// prune the g... | [
"PruneGraph",
"prunes",
"newly",
"closed",
"channels",
"from",
"the",
"channel",
"graph",
"in",
"response",
"to",
"a",
"new",
"block",
"being",
"solved",
"on",
"the",
"network",
".",
"Any",
"transactions",
"which",
"spend",
"the",
"funding",
"output",
"of",
... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L770-L885 |
129,058 | lightningnetwork/lnd | channeldb/graph.go | PruneGraphNodes | func (c *ChannelGraph) PruneGraphNodes() error {
return c.db.Update(func(tx *bbolt.Tx) error {
nodes := tx.Bucket(nodeBucket)
if nodes == nil {
return ErrGraphNodesNotFound
}
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNotFound
}
edgeIndex := edges.Bucket(edgeIndexBucket)
if e... | go | func (c *ChannelGraph) PruneGraphNodes() error {
return c.db.Update(func(tx *bbolt.Tx) error {
nodes := tx.Bucket(nodeBucket)
if nodes == nil {
return ErrGraphNodesNotFound
}
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNotFound
}
edgeIndex := edges.Bucket(edgeIndexBucket)
if e... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"PruneGraphNodes",
"(",
")",
"error",
"{",
"return",
"c",
".",
"db",
".",
"Update",
"(",
"func",
"(",
"tx",
"*",
"bbolt",
".",
"Tx",
")",
"error",
"{",
"nodes",
":=",
"tx",
".",
"Bucket",
"(",
"nodeBucket... | // PruneGraphNodes is a garbage collection method which attempts to prune out
// any nodes from the channel graph that are currently unconnected. This ensure
// that we only maintain a graph of reachable nodes. In the event that a pruned
// node gains more channels, it will be re-added back to the graph. | [
"PruneGraphNodes",
"is",
"a",
"garbage",
"collection",
"method",
"which",
"attempts",
"to",
"prune",
"out",
"any",
"nodes",
"from",
"the",
"channel",
"graph",
"that",
"are",
"currently",
"unconnected",
".",
"This",
"ensure",
"that",
"we",
"only",
"maintain",
"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L891-L908 |
129,059 | lightningnetwork/lnd | channeldb/graph.go | pruneGraphNodes | func (c *ChannelGraph) pruneGraphNodes(nodes *bbolt.Bucket,
edgeIndex *bbolt.Bucket) error {
log.Trace("Pruning nodes from graph with no open channels")
// We'll retrieve the graph's source node to ensure we don't remove it
// even if it no longer has any open channels.
sourceNode, err := c.sourceNode(nodes)
if... | go | func (c *ChannelGraph) pruneGraphNodes(nodes *bbolt.Bucket,
edgeIndex *bbolt.Bucket) error {
log.Trace("Pruning nodes from graph with no open channels")
// We'll retrieve the graph's source node to ensure we don't remove it
// even if it no longer has any open channels.
sourceNode, err := c.sourceNode(nodes)
if... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"pruneGraphNodes",
"(",
"nodes",
"*",
"bbolt",
".",
"Bucket",
",",
"edgeIndex",
"*",
"bbolt",
".",
"Bucket",
")",
"error",
"{",
"log",
".",
"Trace",
"(",
"\"",
"\"",
")",
"\n\n",
"// We'll retrieve the graph's so... | // pruneGraphNodes attempts to remove any nodes from the graph who have had a
// channel closed within the current block. If the node still has existing
// channels in the graph, this will act as a no-op. | [
"pruneGraphNodes",
"attempts",
"to",
"remove",
"any",
"nodes",
"from",
"the",
"graph",
"who",
"have",
"had",
"a",
"channel",
"closed",
"within",
"the",
"current",
"block",
".",
"If",
"the",
"node",
"still",
"has",
"existing",
"channels",
"in",
"the",
"graph"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L913-L1004 |
129,060 | lightningnetwork/lnd | channeldb/graph.go | PruneTip | func (c *ChannelGraph) PruneTip() (*chainhash.Hash, uint32, error) {
var (
tipHash chainhash.Hash
tipHeight uint32
)
err := c.db.View(func(tx *bbolt.Tx) error {
graphMeta := tx.Bucket(graphMetaBucket)
if graphMeta == nil {
return ErrGraphNotFound
}
pruneBucket := graphMeta.Bucket(pruneLogBucket)
... | go | func (c *ChannelGraph) PruneTip() (*chainhash.Hash, uint32, error) {
var (
tipHash chainhash.Hash
tipHeight uint32
)
err := c.db.View(func(tx *bbolt.Tx) error {
graphMeta := tx.Bucket(graphMetaBucket)
if graphMeta == nil {
return ErrGraphNotFound
}
pruneBucket := graphMeta.Bucket(pruneLogBucket)
... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"PruneTip",
"(",
")",
"(",
"*",
"chainhash",
".",
"Hash",
",",
"uint32",
",",
"error",
")",
"{",
"var",
"(",
"tipHash",
"chainhash",
".",
"Hash",
"\n",
"tipHeight",
"uint32",
"\n",
")",
"\n\n",
"err",
":=",... | // PruneTip returns the block height and hash of the latest block that has been
// used to prune channels in the graph. Knowing the "prune tip" allows callers
// to tell if the graph is currently in sync with the current best known UTXO
// state. | [
"PruneTip",
"returns",
"the",
"block",
"height",
"and",
"hash",
"of",
"the",
"latest",
"block",
"that",
"has",
"been",
"used",
"to",
"prune",
"channels",
"in",
"the",
"graph",
".",
"Knowing",
"the",
"prune",
"tip",
"allows",
"callers",
"to",
"tell",
"if",
... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L1127-L1164 |
129,061 | lightningnetwork/lnd | channeldb/graph.go | DeleteChannelEdges | func (c *ChannelGraph) DeleteChannelEdges(chanIDs ...uint64) error {
// TODO(roasbeef): possibly delete from node bucket if node has no more
// channels
// TODO(roasbeef): don't delete both edges?
c.cacheMu.Lock()
defer c.cacheMu.Unlock()
err := c.db.Update(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBu... | go | func (c *ChannelGraph) DeleteChannelEdges(chanIDs ...uint64) error {
// TODO(roasbeef): possibly delete from node bucket if node has no more
// channels
// TODO(roasbeef): don't delete both edges?
c.cacheMu.Lock()
defer c.cacheMu.Unlock()
err := c.db.Update(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBu... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"DeleteChannelEdges",
"(",
"chanIDs",
"...",
"uint64",
")",
"error",
"{",
"// TODO(roasbeef): possibly delete from node bucket if node has no more",
"// channels",
"// TODO(roasbeef): don't delete both edges?",
"c",
".",
"cacheMu",
... | // DeleteChannelEdges removes edges with the given channel IDs from the database
// and marks them as zombies. This ensures that we're unable to re-add it to our
// database once again. If an edge does not exist within the database, then
// ErrEdgeNotFound will be returned. | [
"DeleteChannelEdges",
"removes",
"edges",
"with",
"the",
"given",
"channel",
"IDs",
"from",
"the",
"database",
"and",
"marks",
"them",
"as",
"zombies",
".",
"This",
"ensures",
"that",
"we",
"re",
"unable",
"to",
"re",
"-",
"add",
"it",
"to",
"our",
"databa... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L1170-L1224 |
129,062 | lightningnetwork/lnd | channeldb/graph.go | getChanID | func getChanID(tx *bbolt.Tx, chanPoint *wire.OutPoint) (uint64, error) {
var b bytes.Buffer
if err := writeOutpoint(&b, chanPoint); err != nil {
return 0, err
}
edges := tx.Bucket(edgeBucket)
if edges == nil {
return 0, ErrGraphNoEdgesFound
}
chanIndex := edges.Bucket(channelPointBucket)
if chanIndex == ni... | go | func getChanID(tx *bbolt.Tx, chanPoint *wire.OutPoint) (uint64, error) {
var b bytes.Buffer
if err := writeOutpoint(&b, chanPoint); err != nil {
return 0, err
}
edges := tx.Bucket(edgeBucket)
if edges == nil {
return 0, ErrGraphNoEdgesFound
}
chanIndex := edges.Bucket(channelPointBucket)
if chanIndex == ni... | [
"func",
"getChanID",
"(",
"tx",
"*",
"bbolt",
".",
"Tx",
",",
"chanPoint",
"*",
"wire",
".",
"OutPoint",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"var",
"b",
"bytes",
".",
"Buffer",
"\n",
"if",
"err",
":=",
"writeOutpoint",
"(",
"&",
"b",
",",
... | // getChanID returns the assigned channel ID for a given channel point. | [
"getChanID",
"returns",
"the",
"assigned",
"channel",
"ID",
"for",
"a",
"given",
"channel",
"point",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L1243-L1266 |
129,063 | lightningnetwork/lnd | channeldb/graph.go | NodeUpdatesInHorizon | func (c *ChannelGraph) NodeUpdatesInHorizon(startTime, endTime time.Time) ([]LightningNode, error) {
var nodesInHorizon []LightningNode
err := c.db.View(func(tx *bbolt.Tx) error {
nodes := tx.Bucket(nodeBucket)
if nodes == nil {
return ErrGraphNodesNotFound
}
nodeUpdateIndex := nodes.Bucket(nodeUpdateInd... | go | func (c *ChannelGraph) NodeUpdatesInHorizon(startTime, endTime time.Time) ([]LightningNode, error) {
var nodesInHorizon []LightningNode
err := c.db.View(func(tx *bbolt.Tx) error {
nodes := tx.Bucket(nodeBucket)
if nodes == nil {
return ErrGraphNodesNotFound
}
nodeUpdateIndex := nodes.Bucket(nodeUpdateInd... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"NodeUpdatesInHorizon",
"(",
"startTime",
",",
"endTime",
"time",
".",
"Time",
")",
"(",
"[",
"]",
"LightningNode",
",",
"error",
")",
"{",
"var",
"nodesInHorizon",
"[",
"]",
"LightningNode",
"\n\n",
"err",
":=",... | // NodeUpdatesInHorizon returns all the known lightning node which have an
// update timestamp within the passed range. This method can be used by two
// nodes to quickly determine if they have the same set of up to date node
// announcements. | [
"NodeUpdatesInHorizon",
"returns",
"all",
"the",
"known",
"lightning",
"node",
"which",
"have",
"an",
"update",
"timestamp",
"within",
"the",
"passed",
"range",
".",
"This",
"method",
"can",
"be",
"used",
"by",
"two",
"nodes",
"to",
"quickly",
"determine",
"if... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L1457-L1512 |
129,064 | lightningnetwork/lnd | channeldb/graph.go | FilterKnownChanIDs | func (c *ChannelGraph) FilterKnownChanIDs(chanIDs []uint64) ([]uint64, error) {
var newChanIDs []uint64
err := c.db.View(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
}
edgeIndex := edges.Bucket(edgeIndexBucket)
if edgeIndex == nil {
return Er... | go | func (c *ChannelGraph) FilterKnownChanIDs(chanIDs []uint64) ([]uint64, error) {
var newChanIDs []uint64
err := c.db.View(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
}
edgeIndex := edges.Bucket(edgeIndexBucket)
if edgeIndex == nil {
return Er... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"FilterKnownChanIDs",
"(",
"chanIDs",
"[",
"]",
"uint64",
")",
"(",
"[",
"]",
"uint64",
",",
"error",
")",
"{",
"var",
"newChanIDs",
"[",
"]",
"uint64",
"\n\n",
"err",
":=",
"c",
".",
"db",
".",
"View",
"... | // FilterKnownChanIDs takes a set of channel IDs and return the subset of chan
// ID's that we don't know and are not known zombies of the passed set. In other
// words, we perform a set difference of our set of chan ID's and the ones
// passed in. This method can be used by callers to determine the set of
// channels ... | [
"FilterKnownChanIDs",
"takes",
"a",
"set",
"of",
"channel",
"IDs",
"and",
"return",
"the",
"subset",
"of",
"chan",
"ID",
"s",
"that",
"we",
"don",
"t",
"know",
"and",
"are",
"not",
"known",
"zombies",
"of",
"the",
"passed",
"set",
".",
"In",
"other",
"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L1519-L1572 |
129,065 | lightningnetwork/lnd | channeldb/graph.go | FilterChannelRange | func (c *ChannelGraph) FilterChannelRange(startHeight, endHeight uint32) ([]uint64, error) {
var chanIDs []uint64
startChanID := &lnwire.ShortChannelID{
BlockHeight: startHeight,
}
endChanID := lnwire.ShortChannelID{
BlockHeight: endHeight,
TxIndex: math.MaxUint32 & 0x00ffffff,
TxPosition: math.MaxUi... | go | func (c *ChannelGraph) FilterChannelRange(startHeight, endHeight uint32) ([]uint64, error) {
var chanIDs []uint64
startChanID := &lnwire.ShortChannelID{
BlockHeight: startHeight,
}
endChanID := lnwire.ShortChannelID{
BlockHeight: endHeight,
TxIndex: math.MaxUint32 & 0x00ffffff,
TxPosition: math.MaxUi... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"FilterChannelRange",
"(",
"startHeight",
",",
"endHeight",
"uint32",
")",
"(",
"[",
"]",
"uint64",
",",
"error",
")",
"{",
"var",
"chanIDs",
"[",
"]",
"uint64",
"\n\n",
"startChanID",
":=",
"&",
"lnwire",
".",... | // FilterChannelRange returns the channel ID's of all known channels which were
// mined in a block height within the passed range. This method can be used to
// quickly share with a peer the set of channels we know of within a particular
// range to catch them up after a period of time offline. | [
"FilterChannelRange",
"returns",
"the",
"channel",
"ID",
"s",
"of",
"all",
"known",
"channels",
"which",
"were",
"mined",
"in",
"a",
"block",
"height",
"within",
"the",
"passed",
"range",
".",
"This",
"method",
"can",
"be",
"used",
"to",
"quickly",
"share",
... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L1578-L1636 |
129,066 | lightningnetwork/lnd | channeldb/graph.go | FetchChanInfos | func (c *ChannelGraph) FetchChanInfos(chanIDs []uint64) ([]ChannelEdge, error) {
// TODO(roasbeef): sort cids?
var (
chanEdges []ChannelEdge
cidBytes [8]byte
)
err := c.db.View(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
}
edgeIndex := ed... | go | func (c *ChannelGraph) FetchChanInfos(chanIDs []uint64) ([]ChannelEdge, error) {
// TODO(roasbeef): sort cids?
var (
chanEdges []ChannelEdge
cidBytes [8]byte
)
err := c.db.View(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
}
edgeIndex := ed... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"FetchChanInfos",
"(",
"chanIDs",
"[",
"]",
"uint64",
")",
"(",
"[",
"]",
"ChannelEdge",
",",
"error",
")",
"{",
"// TODO(roasbeef): sort cids?",
"var",
"(",
"chanEdges",
"[",
"]",
"ChannelEdge",
"\n",
"cidBytes",
... | // FetchChanInfos returns the set of channel edges that correspond to the passed
// channel ID's. If an edge is the query is unknown to the database, it will
// skipped and the result will contain only those edges that exist at the time
// of the query. This can be used to respond to peer queries that are seeking to
//... | [
"FetchChanInfos",
"returns",
"the",
"set",
"of",
"channel",
"edges",
"that",
"correspond",
"to",
"the",
"passed",
"channel",
"ID",
"s",
".",
"If",
"an",
"edge",
"is",
"the",
"query",
"is",
"unknown",
"to",
"the",
"database",
"it",
"will",
"skipped",
"and",... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L1643-L1704 |
129,067 | lightningnetwork/lnd | channeldb/graph.go | UpdateEdgePolicy | func (c *ChannelGraph) UpdateEdgePolicy(edge *ChannelEdgePolicy) error {
c.cacheMu.Lock()
defer c.cacheMu.Unlock()
var isUpdate1 bool
err := c.db.Update(func(tx *bbolt.Tx) error {
var err error
isUpdate1, err = updateEdgePolicy(tx, edge)
return err
})
if err != nil {
return err
}
// If an entry for th... | go | func (c *ChannelGraph) UpdateEdgePolicy(edge *ChannelEdgePolicy) error {
c.cacheMu.Lock()
defer c.cacheMu.Unlock()
var isUpdate1 bool
err := c.db.Update(func(tx *bbolt.Tx) error {
var err error
isUpdate1, err = updateEdgePolicy(tx, edge)
return err
})
if err != nil {
return err
}
// If an entry for th... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"UpdateEdgePolicy",
"(",
"edge",
"*",
"ChannelEdgePolicy",
")",
"error",
"{",
"c",
".",
"cacheMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"cacheMu",
".",
"Unlock",
"(",
")",
"\n\n",
"var",
"isUpdate1... | // UpdateEdgePolicy updates the edge routing policy for a single directed edge
// within the database for the referenced channel. The `flags` attribute within
// the ChannelEdgePolicy determines which of the directed edges are being
// updated. If the flag is 1, then the first node's information is being
// updated, ot... | [
"UpdateEdgePolicy",
"updates",
"the",
"edge",
"routing",
"policy",
"for",
"a",
"single",
"directed",
"edge",
"within",
"the",
"database",
"for",
"the",
"referenced",
"channel",
".",
"The",
"flags",
"attribute",
"within",
"the",
"ChannelEdgePolicy",
"determines",
"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L1821-L1862 |
129,068 | lightningnetwork/lnd | channeldb/graph.go | updateEdgePolicy | func updateEdgePolicy(tx *bbolt.Tx, edge *ChannelEdgePolicy) (bool, error) {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return false, ErrEdgeNotFound
}
edgeIndex := edges.Bucket(edgeIndexBucket)
if edgeIndex == nil {
return false, ErrEdgeNotFound
}
nodes, err := tx.CreateBucketIfNotExists(nodeBucket)
... | go | func updateEdgePolicy(tx *bbolt.Tx, edge *ChannelEdgePolicy) (bool, error) {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return false, ErrEdgeNotFound
}
edgeIndex := edges.Bucket(edgeIndexBucket)
if edgeIndex == nil {
return false, ErrEdgeNotFound
}
nodes, err := tx.CreateBucketIfNotExists(nodeBucket)
... | [
"func",
"updateEdgePolicy",
"(",
"tx",
"*",
"bbolt",
".",
"Tx",
",",
"edge",
"*",
"ChannelEdgePolicy",
")",
"(",
"bool",
",",
"error",
")",
"{",
"edges",
":=",
"tx",
".",
"Bucket",
"(",
"edgeBucket",
")",
"\n",
"if",
"edges",
"==",
"nil",
"{",
"retur... | // updateEdgePolicy attempts to update an edge's policy within the relevant
// buckets using an existing database transaction. The returned boolean will be
// true if the updated policy belongs to node1, and false if the policy belonged
// to node2. | [
"updateEdgePolicy",
"attempts",
"to",
"update",
"an",
"edge",
"s",
"policy",
"within",
"the",
"relevant",
"buckets",
"using",
"an",
"existing",
"database",
"transaction",
".",
"The",
"returned",
"boolean",
"will",
"be",
"true",
"if",
"the",
"updated",
"policy",
... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L1868-L1917 |
129,069 | lightningnetwork/lnd | channeldb/graph.go | AddPubKey | func (l *LightningNode) AddPubKey(key *btcec.PublicKey) {
l.pubKey = key
copy(l.PubKeyBytes[:], key.SerializeCompressed())
} | go | func (l *LightningNode) AddPubKey(key *btcec.PublicKey) {
l.pubKey = key
copy(l.PubKeyBytes[:], key.SerializeCompressed())
} | [
"func",
"(",
"l",
"*",
"LightningNode",
")",
"AddPubKey",
"(",
"key",
"*",
"btcec",
".",
"PublicKey",
")",
"{",
"l",
".",
"pubKey",
"=",
"key",
"\n",
"copy",
"(",
"l",
".",
"PubKeyBytes",
"[",
":",
"]",
",",
"key",
".",
"SerializeCompressed",
"(",
... | // AddPubKey is a setter-link method that can be used to swap out the public
// key for a node. | [
"AddPubKey",
"is",
"a",
"setter",
"-",
"link",
"method",
"that",
"can",
"be",
"used",
"to",
"swap",
"out",
"the",
"public",
"key",
"for",
"a",
"node",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L2001-L2004 |
129,070 | lightningnetwork/lnd | channeldb/graph.go | NodeAnnouncement | func (l *LightningNode) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement,
error) {
if !l.HaveNodeAnnouncement {
return nil, fmt.Errorf("node does not have node announcement")
}
alias, err := lnwire.NewNodeAlias(l.Alias)
if err != nil {
return nil, err
}
nodeAnn := &lnwire.NodeAnnouncement{
Featur... | go | func (l *LightningNode) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement,
error) {
if !l.HaveNodeAnnouncement {
return nil, fmt.Errorf("node does not have node announcement")
}
alias, err := lnwire.NewNodeAlias(l.Alias)
if err != nil {
return nil, err
}
nodeAnn := &lnwire.NodeAnnouncement{
Featur... | [
"func",
"(",
"l",
"*",
"LightningNode",
")",
"NodeAnnouncement",
"(",
"signed",
"bool",
")",
"(",
"*",
"lnwire",
".",
"NodeAnnouncement",
",",
"error",
")",
"{",
"if",
"!",
"l",
".",
"HaveNodeAnnouncement",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf"... | // NodeAnnouncement retrieves the latest node announcement of the node. | [
"NodeAnnouncement",
"retrieves",
"the",
"latest",
"node",
"announcement",
"of",
"the",
"node",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L2007-L2041 |
129,071 | lightningnetwork/lnd | channeldb/graph.go | isPublic | func (l *LightningNode) isPublic(tx *bbolt.Tx, sourcePubKey []byte) (bool, error) {
// In order to determine whether this node is publicly advertised within
// the graph, we'll need to look at all of its edges and check whether
// they extend to any other node than the source node. errDone will be
// used to termin... | go | func (l *LightningNode) isPublic(tx *bbolt.Tx, sourcePubKey []byte) (bool, error) {
// In order to determine whether this node is publicly advertised within
// the graph, we'll need to look at all of its edges and check whether
// they extend to any other node than the source node. errDone will be
// used to termin... | [
"func",
"(",
"l",
"*",
"LightningNode",
")",
"isPublic",
"(",
"tx",
"*",
"bbolt",
".",
"Tx",
",",
"sourcePubKey",
"[",
"]",
"byte",
")",
"(",
"bool",
",",
"error",
")",
"{",
"// In order to determine whether this node is publicly advertised within",
"// the graph,... | // isPublic determines whether the node is seen as public within the graph from
// the source node's point of view. An existing database transaction can also be
// specified. | [
"isPublic",
"determines",
"whether",
"the",
"node",
"is",
"seen",
"as",
"public",
"within",
"the",
"graph",
"from",
"the",
"source",
"node",
"s",
"point",
"of",
"view",
".",
"An",
"existing",
"database",
"transaction",
"can",
"also",
"be",
"specified",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L2046-L2082 |
129,072 | lightningnetwork/lnd | channeldb/graph.go | FetchLightningNode | func (c *ChannelGraph) FetchLightningNode(pub *btcec.PublicKey) (*LightningNode, error) {
var node *LightningNode
nodePub := pub.SerializeCompressed()
err := c.db.View(func(tx *bbolt.Tx) error {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes := tx.Bucket(nodeB... | go | func (c *ChannelGraph) FetchLightningNode(pub *btcec.PublicKey) (*LightningNode, error) {
var node *LightningNode
nodePub := pub.SerializeCompressed()
err := c.db.View(func(tx *bbolt.Tx) error {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes := tx.Bucket(nodeB... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"FetchLightningNode",
"(",
"pub",
"*",
"btcec",
".",
"PublicKey",
")",
"(",
"*",
"LightningNode",
",",
"error",
")",
"{",
"var",
"node",
"*",
"LightningNode",
"\n",
"nodePub",
":=",
"pub",
".",
"SerializeCompress... | // FetchLightningNode attempts to look up a target node by its identity public
// key. If the node isn't found in the database, then ErrGraphNodeNotFound is
// returned. | [
"FetchLightningNode",
"attempts",
"to",
"look",
"up",
"a",
"target",
"node",
"by",
"its",
"identity",
"public",
"key",
".",
"If",
"the",
"node",
"isn",
"t",
"found",
"in",
"the",
"database",
"then",
"ErrGraphNodeNotFound",
"is",
"returned",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L2087-L2123 |
129,073 | lightningnetwork/lnd | channeldb/graph.go | HasLightningNode | func (c *ChannelGraph) HasLightningNode(nodePub [33]byte) (time.Time, bool, error) {
var (
updateTime time.Time
exists bool
)
err := c.db.View(func(tx *bbolt.Tx) error {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes := tx.Bucket(nodeBucket)
if node... | go | func (c *ChannelGraph) HasLightningNode(nodePub [33]byte) (time.Time, bool, error) {
var (
updateTime time.Time
exists bool
)
err := c.db.View(func(tx *bbolt.Tx) error {
// First grab the nodes bucket which stores the mapping from
// pubKey to node information.
nodes := tx.Bucket(nodeBucket)
if node... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"HasLightningNode",
"(",
"nodePub",
"[",
"33",
"]",
"byte",
")",
"(",
"time",
".",
"Time",
",",
"bool",
",",
"error",
")",
"{",
"var",
"(",
"updateTime",
"time",
".",
"Time",
"\n",
"exists",
"bool",
"\n",
... | // HasLightningNode determines if the graph has a vertex identified by the
// target node identity public key. If the node exists in the database, a
// timestamp of when the data for the node was lasted updated is returned along
// with a true boolean. Otherwise, an empty time.Time is returned with a false
// boolean. | [
"HasLightningNode",
"determines",
"if",
"the",
"graph",
"has",
"a",
"vertex",
"identified",
"by",
"the",
"target",
"node",
"identity",
"public",
"key",
".",
"If",
"the",
"node",
"exists",
"in",
"the",
"database",
"a",
"timestamp",
"of",
"when",
"the",
"data"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L2130-L2170 |
129,074 | lightningnetwork/lnd | channeldb/graph.go | AddNodeKeys | func (c *ChannelEdgeInfo) AddNodeKeys(nodeKey1, nodeKey2, bitcoinKey1,
bitcoinKey2 *btcec.PublicKey) {
c.nodeKey1 = nodeKey1
copy(c.NodeKey1Bytes[:], c.nodeKey1.SerializeCompressed())
c.nodeKey2 = nodeKey2
copy(c.NodeKey2Bytes[:], nodeKey2.SerializeCompressed())
c.bitcoinKey1 = bitcoinKey1
copy(c.BitcoinKey1B... | go | func (c *ChannelEdgeInfo) AddNodeKeys(nodeKey1, nodeKey2, bitcoinKey1,
bitcoinKey2 *btcec.PublicKey) {
c.nodeKey1 = nodeKey1
copy(c.NodeKey1Bytes[:], c.nodeKey1.SerializeCompressed())
c.nodeKey2 = nodeKey2
copy(c.NodeKey2Bytes[:], nodeKey2.SerializeCompressed())
c.bitcoinKey1 = bitcoinKey1
copy(c.BitcoinKey1B... | [
"func",
"(",
"c",
"*",
"ChannelEdgeInfo",
")",
"AddNodeKeys",
"(",
"nodeKey1",
",",
"nodeKey2",
",",
"bitcoinKey1",
",",
"bitcoinKey2",
"*",
"btcec",
".",
"PublicKey",
")",
"{",
"c",
".",
"nodeKey1",
"=",
"nodeKey1",
"\n",
"copy",
"(",
"c",
".",
"NodeKey... | // AddNodeKeys is a setter-like method that can be used to replace the set of
// keys for the target ChannelEdgeInfo. | [
"AddNodeKeys",
"is",
"a",
"setter",
"-",
"like",
"method",
"that",
"can",
"be",
"used",
"to",
"replace",
"the",
"set",
"of",
"keys",
"for",
"the",
"target",
"ChannelEdgeInfo",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L2337-L2351 |
129,075 | lightningnetwork/lnd | channeldb/graph.go | OtherNodeKeyBytes | func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) (
[]byte, error) {
switch {
case bytes.Equal(c.NodeKey1Bytes[:], thisNodeKey):
return c.NodeKey2Bytes[:], nil
case bytes.Equal(c.NodeKey2Bytes[:], thisNodeKey):
return c.NodeKey1Bytes[:], nil
default:
return nil, fmt.Errorf("node not participat... | go | func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) (
[]byte, error) {
switch {
case bytes.Equal(c.NodeKey1Bytes[:], thisNodeKey):
return c.NodeKey2Bytes[:], nil
case bytes.Equal(c.NodeKey2Bytes[:], thisNodeKey):
return c.NodeKey1Bytes[:], nil
default:
return nil, fmt.Errorf("node not participat... | [
"func",
"(",
"c",
"*",
"ChannelEdgeInfo",
")",
"OtherNodeKeyBytes",
"(",
"thisNodeKey",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"switch",
"{",
"case",
"bytes",
".",
"Equal",
"(",
"c",
".",
"NodeKey1Bytes",
"[",
":",
"]",... | // OtherNodeKeyBytes returns the node key bytes of the other end of
// the channel. | [
"OtherNodeKeyBytes",
"returns",
"the",
"node",
"key",
"bytes",
"of",
"the",
"other",
"end",
"of",
"the",
"channel",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L2438-L2449 |
129,076 | lightningnetwork/lnd | channeldb/graph.go | FetchOtherNode | func (c *ChannelEdgeInfo) FetchOtherNode(tx *bbolt.Tx, thisNodeKey []byte) (*LightningNode, error) {
// Ensure that the node passed in is actually a member of the channel.
var targetNodeBytes [33]byte
switch {
case bytes.Equal(c.NodeKey1Bytes[:], thisNodeKey):
targetNodeBytes = c.NodeKey2Bytes
case bytes.Equal(... | go | func (c *ChannelEdgeInfo) FetchOtherNode(tx *bbolt.Tx, thisNodeKey []byte) (*LightningNode, error) {
// Ensure that the node passed in is actually a member of the channel.
var targetNodeBytes [33]byte
switch {
case bytes.Equal(c.NodeKey1Bytes[:], thisNodeKey):
targetNodeBytes = c.NodeKey2Bytes
case bytes.Equal(... | [
"func",
"(",
"c",
"*",
"ChannelEdgeInfo",
")",
"FetchOtherNode",
"(",
"tx",
"*",
"bbolt",
".",
"Tx",
",",
"thisNodeKey",
"[",
"]",
"byte",
")",
"(",
"*",
"LightningNode",
",",
"error",
")",
"{",
"// Ensure that the node passed in is actually a member of the channe... | // FetchOtherNode attempts to fetch the full LightningNode that's opposite of
// the target node in the channel. This is useful when one knows the pubkey of
// one of the nodes, and wishes to obtain the full LightningNode for the other
// end of the channel. | [
"FetchOtherNode",
"attempts",
"to",
"fetch",
"the",
"full",
"LightningNode",
"that",
"s",
"opposite",
"of",
"the",
"target",
"node",
"in",
"the",
"channel",
".",
"This",
"is",
"useful",
"when",
"one",
"knows",
"the",
"pubkey",
"of",
"one",
"of",
"the",
"no... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L2455-L2498 |
129,077 | lightningnetwork/lnd | channeldb/graph.go | IsEmpty | func (c *ChannelAuthProof) IsEmpty() bool {
return len(c.NodeSig1Bytes) == 0 ||
len(c.NodeSig2Bytes) == 0 ||
len(c.BitcoinSig1Bytes) == 0 ||
len(c.BitcoinSig2Bytes) == 0
} | go | func (c *ChannelAuthProof) IsEmpty() bool {
return len(c.NodeSig1Bytes) == 0 ||
len(c.NodeSig2Bytes) == 0 ||
len(c.BitcoinSig1Bytes) == 0 ||
len(c.BitcoinSig2Bytes) == 0
} | [
"func",
"(",
"c",
"*",
"ChannelAuthProof",
")",
"IsEmpty",
"(",
")",
"bool",
"{",
"return",
"len",
"(",
"c",
".",
"NodeSig1Bytes",
")",
"==",
"0",
"||",
"len",
"(",
"c",
".",
"NodeSig2Bytes",
")",
"==",
"0",
"||",
"len",
"(",
"c",
".",
"BitcoinSig1... | // IsEmpty check is the authentication proof is empty Proof is empty if at
// least one of the signatures are equal to nil. | [
"IsEmpty",
"check",
"is",
"the",
"authentication",
"proof",
"is",
"empty",
"Proof",
"is",
"empty",
"if",
"at",
"least",
"one",
"of",
"the",
"signatures",
"are",
"equal",
"to",
"nil",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L2621-L2626 |
129,078 | lightningnetwork/lnd | channeldb/graph.go | IsDisabled | func (c *ChannelEdgePolicy) IsDisabled() bool {
return c.ChannelFlags&lnwire.ChanUpdateDisabled ==
lnwire.ChanUpdateDisabled
} | go | func (c *ChannelEdgePolicy) IsDisabled() bool {
return c.ChannelFlags&lnwire.ChanUpdateDisabled ==
lnwire.ChanUpdateDisabled
} | [
"func",
"(",
"c",
"*",
"ChannelEdgePolicy",
")",
"IsDisabled",
"(",
")",
"bool",
"{",
"return",
"c",
".",
"ChannelFlags",
"&",
"lnwire",
".",
"ChanUpdateDisabled",
"==",
"lnwire",
".",
"ChanUpdateDisabled",
"\n",
"}"
] | // IsDisabled determines whether the edge has the disabled bit set. | [
"IsDisabled",
"determines",
"whether",
"the",
"edge",
"has",
"the",
"disabled",
"bit",
"set",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L2716-L2719 |
129,079 | lightningnetwork/lnd | channeldb/graph.go | FetchChannelEdgesByOutpoint | func (c *ChannelGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint,
) (*ChannelEdgeInfo, *ChannelEdgePolicy, *ChannelEdgePolicy, error) {
var (
edgeInfo *ChannelEdgeInfo
policy1 *ChannelEdgePolicy
policy2 *ChannelEdgePolicy
)
err := c.db.View(func(tx *bbolt.Tx) error {
// First, grab the node bucket. T... | go | func (c *ChannelGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint,
) (*ChannelEdgeInfo, *ChannelEdgePolicy, *ChannelEdgePolicy, error) {
var (
edgeInfo *ChannelEdgeInfo
policy1 *ChannelEdgePolicy
policy2 *ChannelEdgePolicy
)
err := c.db.View(func(tx *bbolt.Tx) error {
// First, grab the node bucket. T... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"FetchChannelEdgesByOutpoint",
"(",
"op",
"*",
"wire",
".",
"OutPoint",
",",
")",
"(",
"*",
"ChannelEdgeInfo",
",",
"*",
"ChannelEdgePolicy",
",",
"*",
"ChannelEdgePolicy",
",",
"error",
")",
"{",
"var",
"(",
"ed... | // FetchChannelEdgesByOutpoint attempts to lookup the two directed edges for
// the channel identified by the funding outpoint. If the channel can't be
// found, then ErrEdgeNotFound is returned. A struct which houses the general
// information for the channel itself is returned as well as two structs that
// contain t... | [
"FetchChannelEdgesByOutpoint",
"attempts",
"to",
"lookup",
"the",
"two",
"directed",
"edges",
"for",
"the",
"channel",
"identified",
"by",
"the",
"funding",
"outpoint",
".",
"If",
"the",
"channel",
"can",
"t",
"be",
"found",
"then",
"ErrEdgeNotFound",
"is",
"ret... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L2726-L2798 |
129,080 | lightningnetwork/lnd | channeldb/graph.go | FetchChannelEdgesByID | func (c *ChannelGraph) FetchChannelEdgesByID(chanID uint64,
) (*ChannelEdgeInfo, *ChannelEdgePolicy, *ChannelEdgePolicy, error) {
var (
edgeInfo *ChannelEdgeInfo
policy1 *ChannelEdgePolicy
policy2 *ChannelEdgePolicy
channelID [8]byte
)
err := c.db.View(func(tx *bbolt.Tx) error {
// First, grab the n... | go | func (c *ChannelGraph) FetchChannelEdgesByID(chanID uint64,
) (*ChannelEdgeInfo, *ChannelEdgePolicy, *ChannelEdgePolicy, error) {
var (
edgeInfo *ChannelEdgeInfo
policy1 *ChannelEdgePolicy
policy2 *ChannelEdgePolicy
channelID [8]byte
)
err := c.db.View(func(tx *bbolt.Tx) error {
// First, grab the n... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"FetchChannelEdgesByID",
"(",
"chanID",
"uint64",
",",
")",
"(",
"*",
"ChannelEdgeInfo",
",",
"*",
"ChannelEdgePolicy",
",",
"*",
"ChannelEdgePolicy",
",",
"error",
")",
"{",
"var",
"(",
"edgeInfo",
"*",
"ChannelEd... | // FetchChannelEdgesByID attempts to lookup the two directed edges for the
// channel identified by the channel ID. If the channel can't be found, then
// ErrEdgeNotFound is returned. A struct which houses the general information
// for the channel itself is returned as well as two structs that contain the
// routing p... | [
"FetchChannelEdgesByID",
"attempts",
"to",
"lookup",
"the",
"two",
"directed",
"edges",
"for",
"the",
"channel",
"identified",
"by",
"the",
"channel",
"ID",
".",
"If",
"the",
"channel",
"can",
"t",
"be",
"found",
"then",
"ErrEdgeNotFound",
"is",
"returned",
".... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L2809-L2902 |
129,081 | lightningnetwork/lnd | channeldb/graph.go | IsPublicNode | func (c *ChannelGraph) IsPublicNode(pubKey [33]byte) (bool, error) {
var nodeIsPublic bool
err := c.db.View(func(tx *bbolt.Tx) error {
nodes := tx.Bucket(nodeBucket)
if nodes == nil {
return ErrGraphNodesNotFound
}
ourPubKey := nodes.Get(sourceKey)
if ourPubKey == nil {
return ErrSourceNodeNotSet
}
... | go | func (c *ChannelGraph) IsPublicNode(pubKey [33]byte) (bool, error) {
var nodeIsPublic bool
err := c.db.View(func(tx *bbolt.Tx) error {
nodes := tx.Bucket(nodeBucket)
if nodes == nil {
return ErrGraphNodesNotFound
}
ourPubKey := nodes.Get(sourceKey)
if ourPubKey == nil {
return ErrSourceNodeNotSet
}
... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"IsPublicNode",
"(",
"pubKey",
"[",
"33",
"]",
"byte",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"nodeIsPublic",
"bool",
"\n",
"err",
":=",
"c",
".",
"db",
".",
"View",
"(",
"func",
"(",
"tx",
"*... | // IsPublicNode is a helper method that determines whether the node with the
// given public key is seen as a public node in the graph from the graph's
// source node's point of view. | [
"IsPublicNode",
"is",
"a",
"helper",
"method",
"that",
"determines",
"whether",
"the",
"node",
"with",
"the",
"given",
"public",
"key",
"is",
"seen",
"as",
"a",
"public",
"node",
"in",
"the",
"graph",
"from",
"the",
"graph",
"s",
"source",
"node",
"s",
"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L2907-L2931 |
129,082 | lightningnetwork/lnd | channeldb/graph.go | genMultiSigP2WSH | func genMultiSigP2WSH(aPub, bPub []byte) ([]byte, error) {
if len(aPub) != 33 || len(bPub) != 33 {
return nil, fmt.Errorf("Pubkey size error. Compressed " +
"pubkeys only")
}
// Swap to sort pubkeys if needed. Keys are sorted in lexicographical
// order. The signatures within the scriptSig must also adhere to... | go | func genMultiSigP2WSH(aPub, bPub []byte) ([]byte, error) {
if len(aPub) != 33 || len(bPub) != 33 {
return nil, fmt.Errorf("Pubkey size error. Compressed " +
"pubkeys only")
}
// Swap to sort pubkeys if needed. Keys are sorted in lexicographical
// order. The signatures within the scriptSig must also adhere to... | [
"func",
"genMultiSigP2WSH",
"(",
"aPub",
",",
"bPub",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"len",
"(",
"aPub",
")",
"!=",
"33",
"||",
"len",
"(",
"bPub",
")",
"!=",
"33",
"{",
"return",
"nil",
",",
"fmt",
... | // genMultiSigP2WSH generates the p2wsh'd multisig script for 2 of 2 pubkeys. | [
"genMultiSigP2WSH",
"generates",
"the",
"p2wsh",
"d",
"multisig",
"script",
"for",
"2",
"of",
"2",
"pubkeys",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L2934-L2969 |
129,083 | lightningnetwork/lnd | channeldb/graph.go | markEdgeZombie | func markEdgeZombie(zombieIndex *bbolt.Bucket, chanID uint64, pubKey1,
pubKey2 [33]byte) error {
var k [8]byte
byteOrder.PutUint64(k[:], chanID)
var v [66]byte
copy(v[:33], pubKey1[:])
copy(v[33:], pubKey2[:])
return zombieIndex.Put(k[:], v[:])
} | go | func markEdgeZombie(zombieIndex *bbolt.Bucket, chanID uint64, pubKey1,
pubKey2 [33]byte) error {
var k [8]byte
byteOrder.PutUint64(k[:], chanID)
var v [66]byte
copy(v[:33], pubKey1[:])
copy(v[33:], pubKey2[:])
return zombieIndex.Put(k[:], v[:])
} | [
"func",
"markEdgeZombie",
"(",
"zombieIndex",
"*",
"bbolt",
".",
"Bucket",
",",
"chanID",
"uint64",
",",
"pubKey1",
",",
"pubKey2",
"[",
"33",
"]",
"byte",
")",
"error",
"{",
"var",
"k",
"[",
"8",
"]",
"byte",
"\n",
"byteOrder",
".",
"PutUint64",
"(",
... | // markEdgeZombie marks an edge as a zombie within our zombie index. The public
// keys should represent the node public keys of the two parties involved in the
// edge. | [
"markEdgeZombie",
"marks",
"an",
"edge",
"as",
"a",
"zombie",
"within",
"our",
"zombie",
"index",
".",
"The",
"public",
"keys",
"should",
"represent",
"the",
"node",
"public",
"keys",
"of",
"the",
"two",
"parties",
"involved",
"in",
"the",
"edge",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L3061-L3072 |
129,084 | lightningnetwork/lnd | channeldb/graph.go | MarkEdgeLive | func (c *ChannelGraph) MarkEdgeLive(chanID uint64) error {
c.cacheMu.Lock()
defer c.cacheMu.Unlock()
err := c.db.Update(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
}
zombieIndex := edges.Bucket(zombieBucket)
if zombieIndex == nil {
return n... | go | func (c *ChannelGraph) MarkEdgeLive(chanID uint64) error {
c.cacheMu.Lock()
defer c.cacheMu.Unlock()
err := c.db.Update(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
}
zombieIndex := edges.Bucket(zombieBucket)
if zombieIndex == nil {
return n... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"MarkEdgeLive",
"(",
"chanID",
"uint64",
")",
"error",
"{",
"c",
".",
"cacheMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"cacheMu",
".",
"Unlock",
"(",
")",
"\n\n",
"err",
":=",
"c",
".",
"db",
... | // MarkEdgeLive clears an edge from our zombie index, deeming it as live. | [
"MarkEdgeLive",
"clears",
"an",
"edge",
"from",
"our",
"zombie",
"index",
"deeming",
"it",
"as",
"live",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L3075-L3101 |
129,085 | lightningnetwork/lnd | channeldb/graph.go | IsZombieEdge | func (c *ChannelGraph) IsZombieEdge(chanID uint64) (bool, [33]byte, [33]byte) {
var (
isZombie bool
pubKey1, pubKey2 [33]byte
)
err := c.db.View(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
}
zombieIndex := edges.Bucket(zombieBucket)
... | go | func (c *ChannelGraph) IsZombieEdge(chanID uint64) (bool, [33]byte, [33]byte) {
var (
isZombie bool
pubKey1, pubKey2 [33]byte
)
err := c.db.View(func(tx *bbolt.Tx) error {
edges := tx.Bucket(edgeBucket)
if edges == nil {
return ErrGraphNoEdgesFound
}
zombieIndex := edges.Bucket(zombieBucket)
... | [
"func",
"(",
"c",
"*",
"ChannelGraph",
")",
"IsZombieEdge",
"(",
"chanID",
"uint64",
")",
"(",
"bool",
",",
"[",
"33",
"]",
"byte",
",",
"[",
"33",
"]",
"byte",
")",
"{",
"var",
"(",
"isZombie",
"bool",
"\n",
"pubKey1",
",",
"pubKey2",
"[",
"33",
... | // IsZombieEdge returns whether the edge is considered zombie. If it is a
// zombie, then the two node public keys corresponding to this edge are also
// returned. | [
"IsZombieEdge",
"returns",
"whether",
"the",
"edge",
"is",
"considered",
"zombie",
".",
"If",
"it",
"is",
"a",
"zombie",
"then",
"the",
"two",
"node",
"public",
"keys",
"corresponding",
"to",
"this",
"edge",
"are",
"also",
"returned",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L3106-L3130 |
129,086 | lightningnetwork/lnd | channeldb/graph.go | isZombieEdge | func isZombieEdge(zombieIndex *bbolt.Bucket,
chanID uint64) (bool, [33]byte, [33]byte) {
var k [8]byte
byteOrder.PutUint64(k[:], chanID)
v := zombieIndex.Get(k[:])
if v == nil {
return false, [33]byte{}, [33]byte{}
}
var pubKey1, pubKey2 [33]byte
copy(pubKey1[:], v[:33])
copy(pubKey2[:], v[33:])
return ... | go | func isZombieEdge(zombieIndex *bbolt.Bucket,
chanID uint64) (bool, [33]byte, [33]byte) {
var k [8]byte
byteOrder.PutUint64(k[:], chanID)
v := zombieIndex.Get(k[:])
if v == nil {
return false, [33]byte{}, [33]byte{}
}
var pubKey1, pubKey2 [33]byte
copy(pubKey1[:], v[:33])
copy(pubKey2[:], v[33:])
return ... | [
"func",
"isZombieEdge",
"(",
"zombieIndex",
"*",
"bbolt",
".",
"Bucket",
",",
"chanID",
"uint64",
")",
"(",
"bool",
",",
"[",
"33",
"]",
"byte",
",",
"[",
"33",
"]",
"byte",
")",
"{",
"var",
"k",
"[",
"8",
"]",
"byte",
"\n",
"byteOrder",
".",
"Pu... | // isZombieEdge returns whether an entry exists for the given channel in the
// zombie index. If an entry exists, then the two node public keys corresponding
// to this edge are also returned. | [
"isZombieEdge",
"returns",
"whether",
"an",
"entry",
"exists",
"for",
"the",
"given",
"channel",
"in",
"the",
"zombie",
"index",
".",
"If",
"an",
"entry",
"exists",
"then",
"the",
"two",
"node",
"public",
"keys",
"corresponding",
"to",
"this",
"edge",
"are",... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L3135-L3151 |
129,087 | lightningnetwork/lnd | channeldb/graph.go | putChanEdgePolicyUnknown | func putChanEdgePolicyUnknown(edges *bbolt.Bucket, channelID uint64,
from []byte) error {
var edgeKey [33 + 8]byte
copy(edgeKey[:], from)
byteOrder.PutUint64(edgeKey[33:], channelID)
if edges.Get(edgeKey[:]) != nil {
return fmt.Errorf("Cannot write unknown policy for channel %v "+
" when there is already a ... | go | func putChanEdgePolicyUnknown(edges *bbolt.Bucket, channelID uint64,
from []byte) error {
var edgeKey [33 + 8]byte
copy(edgeKey[:], from)
byteOrder.PutUint64(edgeKey[33:], channelID)
if edges.Get(edgeKey[:]) != nil {
return fmt.Errorf("Cannot write unknown policy for channel %v "+
" when there is already a ... | [
"func",
"putChanEdgePolicyUnknown",
"(",
"edges",
"*",
"bbolt",
".",
"Bucket",
",",
"channelID",
"uint64",
",",
"from",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"edgeKey",
"[",
"33",
"+",
"8",
"]",
"byte",
"\n",
"copy",
"(",
"edgeKey",
"[",
":",
"... | // putChanEdgePolicyUnknown marks the edge policy as unknown
// in the edges bucket. | [
"putChanEdgePolicyUnknown",
"marks",
"the",
"edge",
"policy",
"as",
"unknown",
"in",
"the",
"edges",
"bucket",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/graph.go#L3610-L3623 |
129,088 | lightningnetwork/lnd | witness_beacon.go | LookupPreimage | func (p *preimageBeacon) LookupPreimage(
payHash lntypes.Hash) (lntypes.Preimage, bool) {
p.RLock()
defer p.RUnlock()
// First, we'll check the invoice registry to see if we already know of
// the preimage as it's on that we created ourselves.
invoice, _, err := p.invoices.LookupInvoice(payHash)
switch {
case... | go | func (p *preimageBeacon) LookupPreimage(
payHash lntypes.Hash) (lntypes.Preimage, bool) {
p.RLock()
defer p.RUnlock()
// First, we'll check the invoice registry to see if we already know of
// the preimage as it's on that we created ourselves.
invoice, _, err := p.invoices.LookupInvoice(payHash)
switch {
case... | [
"func",
"(",
"p",
"*",
"preimageBeacon",
")",
"LookupPreimage",
"(",
"payHash",
"lntypes",
".",
"Hash",
")",
"(",
"lntypes",
".",
"Preimage",
",",
"bool",
")",
"{",
"p",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"RUnlock",
"(",
")",
"\n\n",
... | // LookupPreImage attempts to lookup a preimage in the global cache. True is
// returned for the second argument if the preimage is found. | [
"LookupPreImage",
"attempts",
"to",
"lookup",
"a",
"preimage",
"in",
"the",
"global",
"cache",
".",
"True",
"is",
"returned",
"for",
"the",
"second",
"argument",
"if",
"the",
"preimage",
"is",
"found",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/witness_beacon.go#L69-L102 |
129,089 | lightningnetwork/lnd | witness_beacon.go | AddPreimages | func (p *preimageBeacon) AddPreimages(preimages ...lntypes.Preimage) error {
// Exit early if no preimages are presented.
if len(preimages) == 0 {
return nil
}
// Copy the preimages to ensure the backing area can't be modified by
// the caller when delivering notifications.
preimageCopies := make([]lntypes.Pre... | go | func (p *preimageBeacon) AddPreimages(preimages ...lntypes.Preimage) error {
// Exit early if no preimages are presented.
if len(preimages) == 0 {
return nil
}
// Copy the preimages to ensure the backing area can't be modified by
// the caller when delivering notifications.
preimageCopies := make([]lntypes.Pre... | [
"func",
"(",
"p",
"*",
"preimageBeacon",
")",
"AddPreimages",
"(",
"preimages",
"...",
"lntypes",
".",
"Preimage",
")",
"error",
"{",
"// Exit early if no preimages are presented.",
"if",
"len",
"(",
"preimages",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}"... | // AddPreimages adds a batch of newly discovered preimages to the global cache,
// and also signals any subscribers of the newly discovered witness. | [
"AddPreimages",
"adds",
"a",
"batch",
"of",
"newly",
"discovered",
"preimages",
"to",
"the",
"global",
"cache",
"and",
"also",
"signals",
"any",
"subscribers",
"of",
"the",
"newly",
"discovered",
"witness",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/witness_beacon.go#L106-L144 |
129,090 | lightningnetwork/lnd | autopilot/combinedattach.go | NewWeightedCombAttachment | func NewWeightedCombAttachment(h ...*WeightedHeuristic) (
*WeightedCombAttachment, error) {
// The sum of weights given to the sub-heuristics must sum to exactly
// 1.0.
var sum float64
for _, w := range h {
sum += w.Weight
}
if sum != 1.0 {
return nil, fmt.Errorf("weights MUST sum to 1.0 (was %v)", sum)
... | go | func NewWeightedCombAttachment(h ...*WeightedHeuristic) (
*WeightedCombAttachment, error) {
// The sum of weights given to the sub-heuristics must sum to exactly
// 1.0.
var sum float64
for _, w := range h {
sum += w.Weight
}
if sum != 1.0 {
return nil, fmt.Errorf("weights MUST sum to 1.0 (was %v)", sum)
... | [
"func",
"NewWeightedCombAttachment",
"(",
"h",
"...",
"*",
"WeightedHeuristic",
")",
"(",
"*",
"WeightedCombAttachment",
",",
"error",
")",
"{",
"// The sum of weights given to the sub-heuristics must sum to exactly",
"// 1.0.",
"var",
"sum",
"float64",
"\n",
"for",
"_",
... | // NewWeightedCombAttachment creates a new instance of a WeightedCombAttachment. | [
"NewWeightedCombAttachment",
"creates",
"a",
"new",
"instance",
"of",
"a",
"WeightedCombAttachment",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/autopilot/combinedattach.go#L27-L44 |
129,091 | lightningnetwork/lnd | lnwire/update_fee.go | NewUpdateFee | func NewUpdateFee(chanID ChannelID, feePerKw uint32) *UpdateFee {
return &UpdateFee{
ChanID: chanID,
FeePerKw: feePerKw,
}
} | go | func NewUpdateFee(chanID ChannelID, feePerKw uint32) *UpdateFee {
return &UpdateFee{
ChanID: chanID,
FeePerKw: feePerKw,
}
} | [
"func",
"NewUpdateFee",
"(",
"chanID",
"ChannelID",
",",
"feePerKw",
"uint32",
")",
"*",
"UpdateFee",
"{",
"return",
"&",
"UpdateFee",
"{",
"ChanID",
":",
"chanID",
",",
"FeePerKw",
":",
"feePerKw",
",",
"}",
"\n",
"}"
] | // NewUpdateFee creates a new UpdateFee message. | [
"NewUpdateFee",
"creates",
"a",
"new",
"UpdateFee",
"message",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/update_fee.go#L22-L27 |
129,092 | lightningnetwork/lnd | lnwire/update_fee.go | Decode | func (c *UpdateFee) Decode(r io.Reader, pver uint32) error {
return ReadElements(r,
&c.ChanID,
&c.FeePerKw,
)
} | go | func (c *UpdateFee) Decode(r io.Reader, pver uint32) error {
return ReadElements(r,
&c.ChanID,
&c.FeePerKw,
)
} | [
"func",
"(",
"c",
"*",
"UpdateFee",
")",
"Decode",
"(",
"r",
"io",
".",
"Reader",
",",
"pver",
"uint32",
")",
"error",
"{",
"return",
"ReadElements",
"(",
"r",
",",
"&",
"c",
".",
"ChanID",
",",
"&",
"c",
".",
"FeePerKw",
",",
")",
"\n",
"}"
] | // Decode deserializes a serialized UpdateFee message stored in the passed
// io.Reader observing the specified protocol version.
//
// This is part of the lnwire.Message interface. | [
"Decode",
"deserializes",
"a",
"serialized",
"UpdateFee",
"message",
"stored",
"in",
"the",
"passed",
"io",
".",
"Reader",
"observing",
"the",
"specified",
"protocol",
"version",
".",
"This",
"is",
"part",
"of",
"the",
"lnwire",
".",
"Message",
"interface",
".... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/update_fee.go#L37-L42 |
129,093 | lightningnetwork/lnd | lnwire/update_fee.go | Encode | func (c *UpdateFee) Encode(w io.Writer, pver uint32) error {
return WriteElements(w,
c.ChanID,
c.FeePerKw,
)
} | go | func (c *UpdateFee) Encode(w io.Writer, pver uint32) error {
return WriteElements(w,
c.ChanID,
c.FeePerKw,
)
} | [
"func",
"(",
"c",
"*",
"UpdateFee",
")",
"Encode",
"(",
"w",
"io",
".",
"Writer",
",",
"pver",
"uint32",
")",
"error",
"{",
"return",
"WriteElements",
"(",
"w",
",",
"c",
".",
"ChanID",
",",
"c",
".",
"FeePerKw",
",",
")",
"\n",
"}"
] | // Encode serializes the target UpdateFee into the passed io.Writer
// observing the protocol version specified.
//
// This is part of the lnwire.Message interface. | [
"Encode",
"serializes",
"the",
"target",
"UpdateFee",
"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/update_fee.go#L48-L53 |
129,094 | lightningnetwork/lnd | watchtower/wtdb/version.go | getMigrations | func getMigrations(versions []version, curVersion uint32) []version {
var updates []version
for _, v := range versions {
if v.number > curVersion {
updates = append(updates, v)
}
}
return updates
} | go | func getMigrations(versions []version, curVersion uint32) []version {
var updates []version
for _, v := range versions {
if v.number > curVersion {
updates = append(updates, v)
}
}
return updates
} | [
"func",
"getMigrations",
"(",
"versions",
"[",
"]",
"version",
",",
"curVersion",
"uint32",
")",
"[",
"]",
"version",
"{",
"var",
"updates",
"[",
"]",
"version",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"versions",
"{",
"if",
"v",
".",
"number",
">... | // getMigrations returns a slice of all updates with a greater number that
// curVersion that need to be applied to sync up with the latest version. | [
"getMigrations",
"returns",
"a",
"slice",
"of",
"all",
"updates",
"with",
"a",
"greater",
"number",
"that",
"curVersion",
"that",
"need",
"to",
"be",
"applied",
"to",
"sync",
"up",
"with",
"the",
"latest",
"version",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtdb/version.go#L35-L44 |
129,095 | lightningnetwork/lnd | watchtower/wtdb/version.go | getDBVersion | func getDBVersion(tx *bbolt.Tx) (uint32, error) {
metadata := tx.Bucket(metadataBkt)
if metadata == nil {
return 0, ErrUninitializedDB
}
versionBytes := metadata.Get(dbVersionKey)
if len(versionBytes) != 4 {
return 0, ErrNoDBVersion
}
return byteOrder.Uint32(versionBytes), nil
} | go | func getDBVersion(tx *bbolt.Tx) (uint32, error) {
metadata := tx.Bucket(metadataBkt)
if metadata == nil {
return 0, ErrUninitializedDB
}
versionBytes := metadata.Get(dbVersionKey)
if len(versionBytes) != 4 {
return 0, ErrNoDBVersion
}
return byteOrder.Uint32(versionBytes), nil
} | [
"func",
"getDBVersion",
"(",
"tx",
"*",
"bbolt",
".",
"Tx",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"metadata",
":=",
"tx",
".",
"Bucket",
"(",
"metadataBkt",
")",
"\n",
"if",
"metadata",
"==",
"nil",
"{",
"return",
"0",
",",
"ErrUninitializedDB",
... | // getDBVersion retrieves the current database version from the metadata bucket
// using the dbVersionKey. | [
"getDBVersion",
"retrieves",
"the",
"current",
"database",
"version",
"from",
"the",
"metadata",
"bucket",
"using",
"the",
"dbVersionKey",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtdb/version.go#L48-L60 |
129,096 | lightningnetwork/lnd | watchtower/wtdb/version.go | initDBVersion | func initDBVersion(tx *bbolt.Tx, version uint32) error {
_, err := tx.CreateBucketIfNotExists(metadataBkt)
if err != nil {
return err
}
return putDBVersion(tx, version)
} | go | func initDBVersion(tx *bbolt.Tx, version uint32) error {
_, err := tx.CreateBucketIfNotExists(metadataBkt)
if err != nil {
return err
}
return putDBVersion(tx, version)
} | [
"func",
"initDBVersion",
"(",
"tx",
"*",
"bbolt",
".",
"Tx",
",",
"version",
"uint32",
")",
"error",
"{",
"_",
",",
"err",
":=",
"tx",
".",
"CreateBucketIfNotExists",
"(",
"metadataBkt",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
... | // initDBVersion initializes the top-level metadata bucket and writes the passed
// version number as the current version. | [
"initDBVersion",
"initializes",
"the",
"top",
"-",
"level",
"metadata",
"bucket",
"and",
"writes",
"the",
"passed",
"version",
"number",
"as",
"the",
"current",
"version",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtdb/version.go#L64-L71 |
129,097 | lightningnetwork/lnd | watchtower/wtdb/version.go | putDBVersion | func putDBVersion(tx *bbolt.Tx, version uint32) error {
metadata := tx.Bucket(metadataBkt)
if metadata == nil {
return ErrUninitializedDB
}
versionBytes := make([]byte, 4)
byteOrder.PutUint32(versionBytes, version)
return metadata.Put(dbVersionKey, versionBytes)
} | go | func putDBVersion(tx *bbolt.Tx, version uint32) error {
metadata := tx.Bucket(metadataBkt)
if metadata == nil {
return ErrUninitializedDB
}
versionBytes := make([]byte, 4)
byteOrder.PutUint32(versionBytes, version)
return metadata.Put(dbVersionKey, versionBytes)
} | [
"func",
"putDBVersion",
"(",
"tx",
"*",
"bbolt",
".",
"Tx",
",",
"version",
"uint32",
")",
"error",
"{",
"metadata",
":=",
"tx",
".",
"Bucket",
"(",
"metadataBkt",
")",
"\n",
"if",
"metadata",
"==",
"nil",
"{",
"return",
"ErrUninitializedDB",
"\n",
"}",
... | // putDBVersion stores the passed database version in the metadata bucket under
// the dbVersionKey. | [
"putDBVersion",
"stores",
"the",
"passed",
"database",
"version",
"in",
"the",
"metadata",
"bucket",
"under",
"the",
"dbVersionKey",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtdb/version.go#L75-L84 |
129,098 | lightningnetwork/lnd | watchtower/lookout/punisher.go | Punish | func (p *BreachPunisher) Punish(desc *JusticeDescriptor, quit <-chan struct{}) error {
justiceTxn, err := desc.CreateJusticeTxn()
if err != nil {
log.Errorf("Unable to create justice txn for "+
"client=%s with breach-txid=%s: %v",
desc.SessionInfo.ID, desc.BreachedCommitTx.TxHash(), err)
return err
}
log... | go | func (p *BreachPunisher) Punish(desc *JusticeDescriptor, quit <-chan struct{}) error {
justiceTxn, err := desc.CreateJusticeTxn()
if err != nil {
log.Errorf("Unable to create justice txn for "+
"client=%s with breach-txid=%s: %v",
desc.SessionInfo.ID, desc.BreachedCommitTx.TxHash(), err)
return err
}
log... | [
"func",
"(",
"p",
"*",
"BreachPunisher",
")",
"Punish",
"(",
"desc",
"*",
"JusticeDescriptor",
",",
"quit",
"<-",
"chan",
"struct",
"{",
"}",
")",
"error",
"{",
"justiceTxn",
",",
"err",
":=",
"desc",
".",
"CreateJusticeTxn",
"(",
")",
"\n",
"if",
"err... | // Punish constructs a justice transaction given a JusticeDescriptor and
// publishes is it to the network. | [
"Punish",
"constructs",
"a",
"justice",
"transaction",
"given",
"a",
"JusticeDescriptor",
"and",
"publishes",
"is",
"it",
"to",
"the",
"network",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/lookout/punisher.go#L33-L57 |
129,099 | lightningnetwork/lnd | lncfg/workers.go | Validate | func (w *Workers) Validate() error {
if w.Read <= 0 {
return fmt.Errorf("number of read workers (%d) must be "+
"positive", w.Read)
}
if w.Write <= 0 {
return fmt.Errorf("number of write workers (%d) must be "+
"positive", w.Write)
}
if w.Sig <= 0 {
return fmt.Errorf("number of sig workers (%d) must be... | go | func (w *Workers) Validate() error {
if w.Read <= 0 {
return fmt.Errorf("number of read workers (%d) must be "+
"positive", w.Read)
}
if w.Write <= 0 {
return fmt.Errorf("number of write workers (%d) must be "+
"positive", w.Write)
}
if w.Sig <= 0 {
return fmt.Errorf("number of sig workers (%d) must be... | [
"func",
"(",
"w",
"*",
"Workers",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"w",
".",
"Read",
"<=",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"w",
".",
"Read",
")",
"\n",
"}",
"\n",
"if",
"w",
"."... | // Validate checks the Workers configuration to ensure that the input values are
// sane. | [
"Validate",
"checks",
"the",
"Workers",
"configuration",
"to",
"ensure",
"that",
"the",
"input",
"values",
"are",
"sane",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lncfg/workers.go#L34-L49 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.