Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/instantsend/instantsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <instantsend/db.h>
#include <instantsend/lock.h>
#include <instantsend/signing.h>
#include <unordered_lru_cache.h>

#include <atomic>
Expand Down Expand Up @@ -43,7 +44,7 @@ class CQuorumManager;
class CSigningManager;
class CSigSharesManager;

class CInstantSendManager
class CInstantSendManager final : public instantsend::InstantSendStorage
{
private:
instantsend::CInstantSendDb db;
Expand Down Expand Up @@ -128,9 +129,9 @@ class CInstantSendManager
EXCLUSIVE_LOCKS_REQUIRED(!cs_nonLocked, !cs_pendingRetry);

public:
bool IsLocked(const uint256& txHash) const;
bool IsLocked(const uint256& txHash) const override;
bool IsWaitingForTx(const uint256& txHash) const EXCLUSIVE_LOCKS_REQUIRED(!cs_pendingLocks);
instantsend::InstantSendLockPtr GetConflictingLock(const CTransaction& tx) const;
instantsend::InstantSendLockPtr GetConflictingLock(const CTransaction& tx) const override;

PeerMsgRet ProcessMessage(const CNode& pfrom, PeerManager& peerman, std::string_view msg_type, CDataStream& vRecv);

Expand All @@ -152,12 +153,12 @@ class CInstantSendManager
EXCLUSIVE_LOCKS_REQUIRED(!cs_nonLocked, !cs_pendingRetry);

void RemoveConflictingLock(const uint256& islockHash, const instantsend::InstantSendLock& islock);
void TryEmplacePendingLock(const uint256& hash, const NodeId id, const instantsend::InstantSendLockPtr& islock)
void TryEmplacePendingLock(const uint256& hash, const NodeId id, const instantsend::InstantSendLockPtr& islock) override
EXCLUSIVE_LOCKS_REQUIRED(!cs_pendingLocks);

size_t GetInstantSendLockCount() const;

bool IsInstantSendEnabled() const;
bool IsInstantSendEnabled() const override;
/**
* If true, MN should sign all transactions, if false, MN should not sign
* transactions in mempool, but should sign txes included in a block. This
Expand Down
3 changes: 1 addition & 2 deletions src/instantsend/signing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <util/irange.h>
#include <validation.h>

#include <instantsend/instantsend.h>
#include <llmq/chainlocks.h>
#include <llmq/quorums.h>
#include <masternode/sync.h>
Expand All @@ -31,7 +30,7 @@ namespace instantsend {
static const std::string_view INPUTLOCK_REQUESTID_PREFIX = "inlock";

InstantSendSigner::InstantSendSigner(CChainState& chainstate, llmq::CChainLocksHandler& clhandler,
llmq::CInstantSendManager& isman, llmq::CSigningManager& sigman,
InstantSendStorage& isman, llmq::CSigningManager& sigman,
llmq::CSigSharesManager& shareman, llmq::CQuorumManager& qman,
CSporkManager& sporkman, CTxMemPool& mempool, const CMasternodeSync& mn_sync) :
m_chainstate{chainstate},
Expand Down
23 changes: 17 additions & 6 deletions src/instantsend/signing.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,31 @@ struct Params;
} // namespace Consensus
namespace llmq {
class CChainLocksHandler;
class CInstantSendManager;
class CSigningManager;
class CSigSharesManager;
class CQuorumManager;
} // namespace llmq

namespace instantsend {

class InstantSendStorage
{
public:
virtual ~InstantSendStorage() = default;

virtual bool IsInstantSendEnabled() const = 0;
virtual bool IsLocked(const uint256& txHash) const = 0;
virtual instantsend::InstantSendLockPtr GetConflictingLock(const CTransaction& tx) const = 0;
virtual void TryEmplacePendingLock(const uint256& hash, const NodeId id,
const instantsend::InstantSendLockPtr& islock) = 0;
};

class InstantSendSigner : public llmq::CRecoveredSigsListener
{
private:
CChainState& m_chainstate;
llmq::CChainLocksHandler& m_clhandler;
llmq::CInstantSendManager& m_isman;
InstantSendStorage& m_isman;
llmq::CSigningManager& m_sigman;
llmq::CSigSharesManager& m_shareman;
llmq::CQuorumManager& m_qman;
Expand Down Expand Up @@ -58,10 +70,9 @@ class InstantSendSigner : public llmq::CRecoveredSigsListener
std::unordered_map<uint256, InstantSendLock*, StaticSaltedHasher> txToCreatingInstantSendLocks GUARDED_BY(cs_creating);

public:
explicit InstantSendSigner(CChainState& chainstate, llmq::CChainLocksHandler& clhandler,
llmq::CInstantSendManager& isman, llmq::CSigningManager& sigman,
llmq::CSigSharesManager& shareman, llmq::CQuorumManager& qman, CSporkManager& sporkman,
CTxMemPool& mempool, const CMasternodeSync& mn_sync);
explicit InstantSendSigner(CChainState& chainstate, llmq::CChainLocksHandler& clhandler, InstantSendStorage& isman,
llmq::CSigningManager& sigman, llmq::CSigSharesManager& shareman, llmq::CQuorumManager& qman,
CSporkManager& sporkman, CTxMemPool& mempool, const CMasternodeSync& mn_sync);
~InstantSendSigner();

void Start();
Expand Down
1 change: 0 additions & 1 deletion test/lint/lint-circular-dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"governance/governance -> governance/object -> governance/governance",
"governance/governance -> masternode/sync -> governance/governance",
"governance/governance -> net_processing -> governance/governance",
"instantsend/instantsend -> instantsend/signing -> instantsend/instantsend",
"instantsend/instantsend -> llmq/chainlocks -> instantsend/instantsend",
"instantsend/instantsend -> net_processing -> instantsend/instantsend",
"instantsend/instantsend -> net_processing -> llmq/context -> instantsend/instantsend",
Expand Down
Loading