@@ -789,35 +789,50 @@ void CSigSharesManager::ProcessSigShare(const CSigShare& sigShare, const CQuorum
789789 }
790790
791791 if (canTryRecovery) {
792- TryRecoverSig (*quorum, sigShare.getId (), sigShare.getMsgHash ());
792+ auto rs = TryRecoverSig (*quorum, sigShare.getId (), sigShare.getMsgHash ());
793+ if (rs != nullptr ) {
794+ if (sigman.ProcessRecoveredSig (rs)) {
795+ // TODO: remove duplicated code with NetSigning
796+ auto listeners = sigman.GetListeners ();
797+ for (auto & l : listeners) {
798+ m_peerman.PostProcessMessage (l->HandleNewRecoveredSig (*rs));
799+ }
800+
801+ bool proactive_relay = rs->getLlmqType () != Consensus::LLMQType::LLMQ_100_67 &&
802+ rs->getLlmqType () != Consensus::LLMQType::LLMQ_400_60 &&
803+ rs->getLlmqType () != Consensus::LLMQType::LLMQ_400_85;
804+ GetMainSignals ().NotifyRecoveredSig (rs, rs->GetHash ().ToString (), proactive_relay);
805+ }
806+ }
793807 }
794808}
795809
796- void CSigSharesManager::TryRecoverSig (const CQuorum& quorum, const uint256& id, const uint256& msgHash)
810+ std::shared_ptr<CRecoveredSig> CSigSharesManager::TryRecoverSig (const CQuorum& quorum, const uint256& id,
811+ const uint256& msgHash)
797812{
798813 if (sigman.HasRecoveredSigForId (quorum.params .type , id)) {
799- return ;
814+ return nullptr ;
800815 }
801816
802817 std::vector<CBLSSignature> sigSharesForRecovery;
803818 std::vector<CBLSId> idsForRecovery;
804- std::shared_ptr<CRecoveredSig> singleMemberRecoveredSig;
805819 {
806820 LOCK (cs);
807821
808822 auto signHash = SignHash (quorum.params .type , quorum.qc ->quorumHash , id, msgHash).Get ();
809823 const auto * sigSharesForSignHash = sigShares.GetAllForSignHash (signHash);
810824 if (sigSharesForSignHash == nullptr ) {
811- return ;
825+ return nullptr ;
812826 }
813827
828+ std::shared_ptr<CRecoveredSig> singleMemberRecoveredSig;
814829 if (quorum.params .is_single_member ()) {
815830 if (sigSharesForSignHash->empty ()) {
816831 LogPrint (BCLog::LLMQ_SIGS, /* Continued */
817832 " CSigSharesManager::%s -- impossible to recover single-node signature - no shares yet. id=%s, "
818833 " msgHash=%s\n " ,
819834 __func__, id.ToString (), msgHash.ToString ());
820- return ;
835+ return nullptr ;
821836 }
822837 const auto & sigShare = sigSharesForSignHash->begin ()->second ;
823838 CBLSSignature recoveredSig = sigShare.sigShare .Get ();
@@ -838,23 +853,11 @@ void CSigSharesManager::TryRecoverSig(const CQuorum& quorum, const uint256& id,
838853
839854 // check if we can recover the final signature
840855 if (sigSharesForRecovery.size () < size_t (quorum.params .threshold )) {
841- return ;
856+ return nullptr ;
842857 }
843- }
844-
845- // Handle single-member quorum case after releasing the lock
846- if (singleMemberRecoveredSig) {
847- if (sigman.ProcessRecoveredSig (singleMemberRecoveredSig)) {
848- // TODO: remove duplicated code with NetSigning
849- auto listeners = sigman.GetListeners ();
850- for (auto & l : listeners) {
851- m_peerman.PostProcessMessage (l->HandleNewRecoveredSig (*singleMemberRecoveredSig));
852- }
853-
854- GetMainSignals ().NotifyRecoveredSig (singleMemberRecoveredSig,
855- singleMemberRecoveredSig->GetHash ().ToString (), false );
858+ if (quorum.params .is_single_member ()) {
859+ return singleMemberRecoveredSig; // end of single-quorum processing
856860 }
857- return ; // end of single-quorum processing
858861 }
859862
860863 // now recover it
@@ -863,7 +866,7 @@ void CSigSharesManager::TryRecoverSig(const CQuorum& quorum, const uint256& id,
863866 if (!recoveredSig.Recover (sigSharesForRecovery, idsForRecovery)) {
864867 LogPrint (BCLog::LLMQ_SIGS, " CSigSharesManager::%s -- failed to recover signature. id=%s, msgHash=%s, time=%d\n " , __func__,
865868 id.ToString (), msgHash.ToString (), t.count ());
866- return ;
869+ return nullptr ;
867870 }
868871
869872 LogPrint (BCLog::LLMQ_SIGS, " CSigSharesManager::%s -- recovered signature. id=%s, msgHash=%s, time=%d\n " , __func__,
@@ -881,22 +884,10 @@ void CSigSharesManager::TryRecoverSig(const CQuorum& quorum, const uint256& id,
881884 // this should really not happen as we have verified all signature shares before
882885 LogPrintf (" CSigSharesManager::%s -- own recovered signature is invalid. id=%s, msgHash=%s\n " , __func__,
883886 id.ToString (), msgHash.ToString ());
884- return ;
887+ return nullptr ;
885888 }
886889 }
887-
888- if (sigman.ProcessRecoveredSig (rs)) {
889- // TODO: remove duplicated code with NetSigning
890- auto listeners = sigman.GetListeners ();
891- for (auto & l : listeners) {
892- m_peerman.PostProcessMessage (l->HandleNewRecoveredSig (*rs));
893- }
894-
895- auto proactive_relay = rs->getLlmqType () != Consensus::LLMQType::LLMQ_100_67 &&
896- rs->getLlmqType () != Consensus::LLMQType::LLMQ_400_60 &&
897- rs->getLlmqType () != Consensus::LLMQType::LLMQ_400_85;
898- GetMainSignals ().NotifyRecoveredSig (rs, rs->GetHash ().ToString (), proactive_relay);
899- }
890+ return rs;
900891}
901892
902893CDeterministicMNCPtr CSigSharesManager::SelectMemberForRecovery (const CQuorum& quorum, const uint256 &id, int attempt)
0 commit comments