diff --git a/solana/signer.go b/solana/signer.go index 8a10244..292493b 100644 --- a/solana/signer.go +++ b/solana/signer.go @@ -160,10 +160,10 @@ func (node *Node) loopPendingSessions(ctx context.Context) { panic(fmt.Errorf("node.readKeyByFingerPath(%s) => %s %v", op.Public, public, err)) } call, err := node.store.ReadSystemCallByRequestId(ctx, s.RequestId, 0) - if err != nil { - panic(err) + if err != nil || call == nil { + panic(fmt.Errorf("store.ReadSystemCallByRequestId(%s) => %v %v", s.RequestId, call, err)) } - if call == nil || call.State != common.RequestStatePending { + if call.Signature.Valid || call.State != common.RequestStatePending { err = node.store.MarkSessionDone(ctx, s.Id) logger.Printf("node.MarkSessionDone(%v) => %v", s, err) if err != nil { @@ -742,11 +742,11 @@ func (node *Node) processSignerSignatureResponse(ctx context.Context, req *store if err != nil || s == nil { panic(fmt.Errorf("store.ReadSession(%s) => %v %v", sid, s, err)) } - call, err := node.store.ReadSystemCallByRequestId(ctx, s.RequestId, common.RequestStatePending) + call, err := node.store.ReadSystemCallByRequestId(ctx, s.RequestId, 0) if err != nil || call == nil { panic(fmt.Errorf("store.ReadSystemCallByRequestId(%s) => %v %v", s.RequestId, call, err)) } - if call.State == common.RequestStateFailed || call.Signature.Valid { + if call.Signature.Valid || call.State != common.RequestStatePending { logger.Printf("invalid call %s: %d %s", call.RequestId, call.State, call.Signature.String) return node.failRequest(ctx, req, "") }