Skip to content

Commit

Permalink
lnc: use DefaultStoreTimetout when interacting with the store
Browse files Browse the repository at this point in the history
  • Loading branch information
positiveblue committed Feb 12, 2024
1 parent bc255c0 commit 5662500
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lnc/lnc.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ func (n *NodeConn) CtxFunc() context.Context {
// NOTE: this function is a callback to be used by the mailbox package during
// the mailbox.NewConnData call.
func (n *NodeConn) onRemoteStatic(key *btcec.PublicKey) error {
remoteKey := key.SerializeCompressed()

ctxt, cancel := context.WithTimeout(
context.Background(), time.Second*10,
context.Background(), DefaultStoreTimetout,
)
defer cancel()

remoteKey := key.SerializeCompressed()

err := n.store.SetRemotePubKey(
ctxt, n.session.PassphraseEntropy, remoteKey,
)
Expand Down Expand Up @@ -226,8 +226,12 @@ func (n *NodeConn) onAuthData(data []byte) error {
// microseconds, but we can store the correct one here.
n.session.Expiry = &expiry

ctxb := context.Background()
err = n.store.SetExpiry(ctxb, n.session.PassphraseEntropy, expiry)
ctxt, cancel := context.WithTimeout(
context.Background(), DefaultStoreTimetout,
)
defer cancel()

err = n.store.SetExpiry(ctxt, n.session.PassphraseEntropy, expiry)
if err != nil {
log.Errorf("unable to set expiry for session(%x): %w",
n.session.PassphraseEntropy, err)
Expand Down

0 comments on commit 5662500

Please sign in to comment.