Skip to content

Commit ec4e929

Browse files
committed
lnc: use DefaultStoreTimetout when interacting with the store
1 parent 2e13b87 commit ec4e929

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lnc/lnc.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,13 @@ func (n *NodeConn) CtxFunc() context.Context {
163163
// NOTE: this function is a callback to be used by the mailbox package during
164164
// the mailbox.NewConnData call.
165165
func (n *NodeConn) onRemoteStatic(key *btcec.PublicKey) error {
166+
remoteKey := key.SerializeCompressed()
167+
166168
ctxt, cancel := context.WithTimeout(
167-
context.Background(), time.Second*10,
169+
context.Background(), DefaultStoreTimetout,
168170
)
169171
defer cancel()
170172

171-
remoteKey := key.SerializeCompressed()
172-
173173
err := n.store.SetRemotePubKey(
174174
ctxt, n.session.PassphraseEntropy, remoteKey,
175175
)
@@ -226,8 +226,12 @@ func (n *NodeConn) onAuthData(data []byte) error {
226226
// microseconds, but we can store the correct one here.
227227
n.session.Expiry = &expiry
228228

229-
ctxb := context.Background()
230-
err = n.store.SetExpiry(ctxb, n.session.PassphraseEntropy, expiry)
229+
ctxt, cancel := context.WithTimeout(
230+
context.Background(), DefaultStoreTimetout,
231+
)
232+
defer cancel()
233+
234+
err = n.store.SetExpiry(ctxt, n.session.PassphraseEntropy, expiry)
231235
if err != nil {
232236
log.Errorf("unable to set expiry for session(%x): %w",
233237
n.session.PassphraseEntropy, err)

0 commit comments

Comments
 (0)