@@ -34,10 +34,6 @@ namespace llmq
3434static const std::string DB_QUORUM_SK_SHARE = " q_Qsk" ;
3535static const std::string DB_QUORUM_QUORUM_VVEC = " q_Qqvvec" ;
3636
37- RecursiveMutex cs_data_requests;
38- static std::unordered_map<CQuorumDataRequestKey, CQuorumDataRequest, StaticSaltedHasher> mapQuorumDataRequests GUARDED_BY (cs_data_requests);
39-
40-
4137static uint256 MakeQuorumKey (const CQuorum& q)
4238{
4339 CHashWriter hw (SER_NETWORK, 0 );
@@ -707,18 +703,9 @@ size_t CQuorumManager::GetQuorumRecoveryStartOffset(const CQuorum& quorum, gsl::
707703
708704MessageProcessingResult CQuorumManager::ProcessMessage (CNode& pfrom, CConnman& connman, std::string_view msg_type, CDataStream& vRecv)
709705{
710- auto strFunc = __func__;
711- auto errorHandler = [&](const std::string& strError, int nScore = 10 ) -> MessageProcessingResult {
712- LogPrint (BCLog::LLMQ, " CQuorumManager::%s -- %s: %s, from peer=%d\n " , strFunc, msg_type, strError, pfrom.GetId ());
713- if (nScore > 0 ) {
714- return MisbehavingError{nScore};
715- }
716- return {};
717- };
718-
719706 if (msg_type == NetMsgType::QGETDATA) {
720707 if (m_mn_activeman == nullptr || (pfrom.GetVerifiedProRegTxHash ().IsNull () && !pfrom.qwatch )) {
721- return errorHandler ( " Not a verified masternode or a qwatch connection" ) ;
708+ return MisbehavingError{ 10 , " not a verified masternode or a qwatch connection" } ;
722709 }
723710
724711 CQuorumDataRequest request;
@@ -735,7 +722,7 @@ MessageProcessingResult CQuorumManager::ProcessMessage(CNode& pfrom, CConnman& c
735722 case (CQuorumDataRequest::Errors::QUORUM_NOT_FOUND):
736723 case (CQuorumDataRequest::Errors::MASTERNODE_IS_NO_MEMBER):
737724 case (CQuorumDataRequest::Errors::UNDEFINED):
738- if (request_limit_exceeded) ret = errorHandler ( " Request limit exceeded" , 25 ) ;
725+ if (request_limit_exceeded) ret = MisbehavingError{ 25 , " request limit exceeded" } ;
739726 break ;
740727 case (CQuorumDataRequest::Errors::QUORUM_VERIFICATION_VECTOR_MISSING):
741728 case (CQuorumDataRequest::Errors::ENCRYPTED_CONTRIBUTIONS_MISSING):
@@ -812,7 +799,7 @@ MessageProcessingResult CQuorumManager::ProcessMessage(CNode& pfrom, CConnman& c
812799
813800 if (msg_type == NetMsgType::QDATA) {
814801 if ((m_mn_activeman == nullptr && !m_quorums_watch) || pfrom.GetVerifiedProRegTxHash ().IsNull ()) {
815- return errorHandler ( " Not a verified masternode and -watchquorums is not enabled" ) ;
802+ return MisbehavingError{ 10 , " not a verified masternode and -watchquorums is not enabled" } ;
816803 }
817804
818805 CQuorumDataRequest request;
@@ -823,25 +810,28 @@ MessageProcessingResult CQuorumManager::ProcessMessage(CNode& pfrom, CConnman& c
823810 const CQuorumDataRequestKey key (pfrom.GetVerifiedProRegTxHash (), true , request.GetQuorumHash (), request.GetLLMQType ());
824811 auto it = mapQuorumDataRequests.find (key);
825812 if (it == mapQuorumDataRequests.end ()) {
826- return errorHandler ( " Not requested" ) ;
813+ return MisbehavingError{ 10 , " not requested" } ;
827814 }
828815 if (it->second .IsProcessed ()) {
829- return errorHandler ( " Already received" );
816+ return MisbehavingError ( 10 , " already received" );
830817 }
831818 if (request != it->second ) {
832- return errorHandler ( " Not like requested" );
819+ return MisbehavingError ( 10 , " not like requested" );
833820 }
834821 it->second .SetProcessed ();
835822 }
836823
837824 if (request.GetError () != CQuorumDataRequest::Errors::NONE) {
838- return errorHandler (strprintf (" Error %d (%s)" , request.GetError (), request.GetErrorString ()), 0 );
825+ LogPrint (BCLog::LLMQ, " CQuorumManager::%s -- %s: %s, from peer=%d\n " , __func__, msg_type, strprintf (" Error %d (%s)" , request.GetError (), request.GetErrorString ()), pfrom.GetId ());
826+ return {};
839827 }
840828
841829 CQuorumPtr pQuorum;
842830 {
843831 if (LOCK (cs_map_quorums); !mapQuorumsCache[request.GetLLMQType ()].get (request.GetQuorumHash (), pQuorum)) {
844- return errorHandler (" Quorum not found" , 0 ); // Don't bump score because we asked for it
832+ // Don't bump score because we asked for it
833+ LogPrint (BCLog::LLMQ, " CQuorumManager::%s -- %s: Quorum not found, from peer=%d\n " , __func__, msg_type, pfrom.GetId ());
834+ return {};
845835 }
846836 }
847837
@@ -854,7 +844,7 @@ MessageProcessingResult CQuorumManager::ProcessMessage(CNode& pfrom, CConnman& c
854844 if (pQuorum->SetVerificationVector (verificationVector)) {
855845 StartCachePopulatorThread (pQuorum);
856846 } else {
857- return errorHandler ( " Invalid quorum verification vector" ) ;
847+ return MisbehavingError{ 10 , " invalid quorum verification vector" } ;
858848 }
859849 }
860850
@@ -863,12 +853,16 @@ MessageProcessingResult CQuorumManager::ProcessMessage(CNode& pfrom, CConnman& c
863853 assert (m_mn_activeman);
864854
865855 if (WITH_LOCK (pQuorum->cs_vvec_shShare , return pQuorum->quorumVvec ->size () != size_t (pQuorum->params .threshold ))) {
866- return errorHandler (" No valid quorum verification vector available" , 0 ); // Don't bump score because we asked for it
856+ // Don't bump score because we asked for it
857+ LogPrint (BCLog::LLMQ, " CQuorumManager::%s -- %s: No valid quorum verification vector available, from peer=%d\n " , __func__, msg_type, pfrom.GetId ());
858+ return {};
867859 }
868860
869861 int memberIdx = pQuorum->GetMemberIndex (request.GetProTxHash ());
870862 if (memberIdx == -1 ) {
871- return errorHandler (" Not a member of the quorum" , 0 ); // Don't bump score because we asked for it
863+ // Don't bump score because we asked for it
864+ LogPrint (BCLog::LLMQ, " CQuorumManager::%s -- %s: Not a member of the quorum, from peer=%d\n " , __func__, msg_type, pfrom.GetId ());
865+ return {};
872866 }
873867
874868 std::vector<CBLSIESEncryptedObject<CBLSSecretKey>> vecEncrypted;
@@ -878,13 +872,13 @@ MessageProcessingResult CQuorumManager::ProcessMessage(CNode& pfrom, CConnman& c
878872 vecSecretKeys.resize (vecEncrypted.size ());
879873 for (const auto i : irange::range (vecEncrypted.size ())) {
880874 if (!m_mn_activeman->Decrypt (vecEncrypted[i], memberIdx, vecSecretKeys[i], PROTOCOL_VERSION)) {
881- return errorHandler ( " Failed to decrypt" ) ;
875+ return MisbehavingError{ 10 , " failed to decrypt" } ;
882876 }
883877 }
884878
885879 CBLSSecretKey secretKeyShare = blsWorker.AggregateSecretKeys (vecSecretKeys);
886880 if (!pQuorum->SetSecretKeyShare (secretKeyShare, *m_mn_activeman)) {
887- return errorHandler ( " Invalid secret key share received" ) ;
881+ return MisbehavingError{ 10 , " invalid secret key share received" } ;
888882 }
889883 }
890884 WITH_LOCK (cs_db, pQuorum->WriteContributions (*db));
0 commit comments