-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: migrate ProcessMessage definitions to MessageProcessingResult, drop PeerMsgRet
#6820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f341ef5
f3b98ce
e7b23a2
1bbcb95
93d68b8
ef4a0bb
9f85bd0
6352baf
1d50a1a
8b9bf7c
9084530
0517aff
4822b93
5d1222e
2020757
491ae50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,41 +38,36 @@ using wallet::CoinType; | |
| using wallet::CWallet; | ||
| using wallet::ReserveDestination; | ||
|
|
||
| PeerMsgRet CCoinJoinClientQueueManager::ProcessMessage(const CNode& peer, CConnman& connman, PeerManager& peerman, | ||
| std::string_view msg_type, CDataStream& vRecv) | ||
| MessageProcessingResult CCoinJoinClientQueueManager::ProcessMessage(NodeId from, CConnman& connman, PeerManager& peerman, | ||
| std::string_view msg_type, CDataStream& vRecv) | ||
| { | ||
| if (msg_type != NetMsgType::DSQUEUE) { | ||
| return {}; | ||
| } | ||
|
|
||
| if (m_is_masternode) return {}; | ||
| if (!m_mn_sync.IsBlockchainSynced()) return {}; | ||
|
|
||
| if (msg_type == NetMsgType::DSQUEUE) { | ||
| return CCoinJoinClientQueueManager::ProcessDSQueue(peer, connman, peerman, vRecv); | ||
| } | ||
| return {}; | ||
| } | ||
|
|
||
| PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CConnman& connman, PeerManager& peerman, | ||
| CDataStream& vRecv) | ||
| { | ||
| assert(m_mn_metaman.IsValid()); | ||
|
|
||
| CCoinJoinQueue dsq; | ||
| vRecv >> dsq; | ||
|
|
||
| { | ||
| LOCK(::cs_main); | ||
| peerman.EraseObjectRequest(peer.GetId(), CInv(MSG_DSQ, dsq.GetHash())); | ||
| } | ||
| MessageProcessingResult ret{}; | ||
| ret.m_to_erase = CInv{MSG_DSQ, dsq.GetHash()}; | ||
|
|
||
| if (dsq.masternodeOutpoint.IsNull() && dsq.m_protxHash.IsNull()) { | ||
| return tl::unexpected{100}; | ||
| ret.m_error = MisbehavingError{100}; | ||
| return ret; | ||
| } | ||
|
|
||
| const auto tip_mn_list = m_dmnman.GetListAtChainTip(); | ||
| if (dsq.masternodeOutpoint.IsNull()) { | ||
| if (auto dmn = tip_mn_list.GetValidMN(dsq.m_protxHash)) { | ||
| dsq.masternodeOutpoint = dmn->collateralOutpoint; | ||
| } else { | ||
| return tl::unexpected{10}; | ||
| ret.m_error = MisbehavingError{10}; | ||
| return ret; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -84,31 +79,32 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CConnm | |
| // process every dsq only once | ||
| for (const auto &q: vecCoinJoinQueue) { | ||
| if (q == dsq) { | ||
| return {}; | ||
| return ret; | ||
| } | ||
| if (q.fReady == dsq.fReady && q.masternodeOutpoint == dsq.masternodeOutpoint) { | ||
| // no way the same mn can send another dsq with the same readiness this soon | ||
| LogPrint(BCLog::COINJOIN, /* Continued */ | ||
| "DSQUEUE -- Peer %s is sending WAY too many dsq messages for a masternode with collateral %s\n", | ||
| peer.GetLogString(), dsq.masternodeOutpoint.ToStringShort()); | ||
| return {}; | ||
| "DSQUEUE -- Peer %d is sending WAY too many dsq messages for a masternode with collateral %s\n", | ||
| from, dsq.masternodeOutpoint.ToStringShort()); | ||
| return ret; | ||
| } | ||
| } | ||
|
Comment on lines
84
to
91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainFix clang-format diff failure in this hunk CI flagged style differences here. Please apply the formatter. You can use: 🏁 Script executed: #!/bin/bash
git diff -U0 | contrib/devtools/clang-format-diff.py -p1 -i -vLength of output: 64 🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE=src/coinjoin/client.cpp
echo "=== Git branch ==="
git rev-parse --abbrev-ref HEAD || true
echo
echo "=== Git remotes ==="
git remote -v || true
echo
echo "=== Last commit ==="
git log -1 --oneline || true
echo
if [ ! -f "$FILE" ]; then
echo "FILE_NOT_FOUND: $FILE"
exit 0
fi
echo "=== File snippet ($FILE) ==="
nl -ba "$FILE" | sed -n '1,140p'
echo
# Determine a reasonable base to diff against
BASE=""
for candidate in origin/main origin/master origin/HEAD HEAD~1; do
if git rev-parse --verify "$candidate" >/dev/null 2>&1; then
if git show "$candidate":"$FILE" >/dev/null 2>&1; then
BASE="$candidate"
break
fi
fi
done
if [ -z "$BASE" ]; then
echo "No upstream base found; will diff against HEAD~1"
BASE="HEAD~1"
fi
echo "=== Diff base chosen: $BASE ==="
git rev-parse --short "$BASE" || true
echo
echo "=== Generating diff for $FILE (unified, 0 context) ==="
git diff -U0 "$BASE".."HEAD" -- "$FILE" > /tmp/file.diff || true
if [ ! -s /tmp/file.diff ]; then
echo "Diff is empty (no changes to $FILE between $BASE and HEAD). Showing full diff of HEAD~1..HEAD for the file as fallback."
git diff -U0 HEAD~1..HEAD -- "$FILE" > /tmp/file.diff || true
fi
echo "=== Diff (first 200 lines) ==="
sed -n '1,200p' /tmp/file.diff || true
echo
echo "=== clang-format presence ==="
if command -v clang-format >/dev/null 2>&1; then
echo "clang-format found: $(command -v clang-format)"
else
echo "clang-format NOT found in PATH"
fi
echo
echo "=== Running contrib/devtools/clang-format-diff.py on the diff ==="
python3 contrib/devtools/clang-format-diff.py -p1 -i -v < /tmp/file.diff || echo "clang-format-diff.py exited with non-zero status"Length of output: 796 🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE=src/coinjoin/client.cpp
echo "=== Git branch ==="
git rev-parse --abbrev-ref HEAD || true
echo
echo "=== Last commit ==="
git log -1 --oneline || true
echo
if [ ! -f "$FILE" ]; then
echo "FILE_NOT_FOUND: $FILE"
exit 0
fi
echo "=== File snippet ($FILE) lines 1-200 ==="
awk '{printf("%5d: %s\n", NR, $0)}' "$FILE" | sed -n '1,200p'
echo
# Determine base for diff
BASE=""
for candidate in origin/main origin/master origin/HEAD HEAD~1; do
if git rev-parse --verify "$candidate" >/dev/null 2>&1; then
if git show "$candidate":"$FILE" >/dev/null 2>&1; then
BASE="$candidate"
break
fi
fi
done
if [ -z "$BASE" ]; then
echo "No upstream base found; using HEAD~1"
BASE="HEAD~1"
fi
echo "=== Diff base chosen: $BASE ==="
git rev-parse --short "$BASE" || true
echo
echo "=== Generating diff for $FILE (unified, 0 context) ==="
git diff -U0 "$BASE".."HEAD" -- "$FILE" > /tmp/file.diff || true
if [ ! -s /tmp/file.diff ]; then
echo "Diff empty against $BASE; trying HEAD~1..HEAD"
git diff -U0 HEAD~1..HEAD -- "$FILE" > /tmp/file.diff || true
fi
echo "=== Diff (first 200 lines) ==="
sed -n '1,200p' /tmp/file.diff || true
echo
echo "=== clang-format presence ==="
if command -v clang-format >/dev/null 2>&1; then
echo "clang-format found: $(command -v clang-format)"
else
echo "clang-format NOT found in PATH"
fi
echo
echo "=== Running contrib/devtools/clang-format-diff.py ==="
python3 contrib/devtools/clang-format-diff.py -p1 -i -v < /tmp/file.diff || echo "clang-format-diff.py exited with non-zero status"Length of output: 15308 Apply clang-format to src/coinjoin/client.cpp (hunk around lines 84–91) CI flagged style differences in this hunk. I ran contrib/devtools/clang-format-diff.py but it failed here because clang-format is not available in the environment (FileNotFoundError). Please run the formatter and commit the result.
Suggested fix (run locally and commit the formatted changes):
🧰 Tools🪛 GitHub Actions: Clang Diff Format Check[error] 84-91: Clang-format differences detected by clang-format-diff.py. Apply formatting changes to this file. 🤖 Prompt for AI Agents |
||
| } // cs_vecqueue | ||
|
|
||
| LogPrint(BCLog::COINJOIN, "DSQUEUE -- %s new\n", dsq.ToString()); | ||
|
|
||
| if (dsq.IsTimeOutOfBounds()) return {}; | ||
| if (dsq.IsTimeOutOfBounds()) return ret; | ||
|
|
||
| auto dmn = tip_mn_list.GetValidMNByCollateral(dsq.masternodeOutpoint); | ||
| if (!dmn) return {}; | ||
| if (!dmn) return ret; | ||
|
|
||
| if (dsq.m_protxHash.IsNull()) { | ||
| dsq.m_protxHash = dmn->proTxHash; | ||
| } | ||
|
|
||
| if (!dsq.CheckSignature(dmn->pdmnState->pubKeyOperator.Get())) { | ||
| return tl::unexpected{10}; | ||
| ret.m_error = MisbehavingError{10}; | ||
| return ret; | ||
| } | ||
|
|
||
| // if the queue is ready, submit if we can | ||
|
|
@@ -117,7 +113,7 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CConnm | |
| return clientman->TrySubmitDenominate(dmn->proTxHash, connman); | ||
| })) { | ||
| LogPrint(BCLog::COINJOIN, "DSQUEUE -- CoinJoin queue is ready, masternode=%s, queue=%s\n", dmn->proTxHash.ToString(), dsq.ToString()); | ||
| return {}; | ||
| return ret; | ||
| } else { | ||
| int64_t nLastDsq = m_mn_metaman.GetMetaInfo(dmn->proTxHash)->GetLastDsq(); | ||
| int64_t nDsqThreshold = m_mn_metaman.GetDsqThreshold(dmn->proTxHash, tip_mn_list.GetValidMNsCount()); | ||
|
|
@@ -127,7 +123,7 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CConnm | |
| if (nLastDsq != 0 && nDsqThreshold > m_mn_metaman.GetDsqCount()) { | ||
| LogPrint(BCLog::COINJOIN, "DSQUEUE -- Masternode %s is sending too many dsq messages\n", | ||
| dmn->proTxHash.ToString()); | ||
| return {}; | ||
| return ret; | ||
| } | ||
|
|
||
| m_mn_metaman.AllowMixing(dmn->proTxHash); | ||
|
|
@@ -142,7 +138,7 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CConnm | |
| } | ||
| } // cs_ProcessDSQueue | ||
| peerman.RelayDSQ(dsq); | ||
| return {}; | ||
| return ret; | ||
| } | ||
|
|
||
| void CCoinJoinClientManager::ProcessMessage(CNode& peer, CChainState& active_chainstate, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.