mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
implement zmqpubrawtxlock
This commit is contained in:
parent
b6d41d22da
commit
339be11fb2
@ -61,6 +61,7 @@ Currently, the following notifications are supported:
|
||||
-zmqpubhashblock=address
|
||||
-zmqpubrawblock=address
|
||||
-zmqpubrawtx=address
|
||||
-zmqpubrawtxlock=address
|
||||
|
||||
The socket type is PUB and the address must be a valid ZeroMQ socket
|
||||
address. The same address can be used in more than one notification.
|
||||
|
@ -484,6 +484,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-zmqpubhashtxlock=<address>", _("Enable publish hash transaction (locked via InstantSend) in <address>"));
|
||||
strUsage += HelpMessageOpt("-zmqpubrawblock=<address>", _("Enable publish raw block in <address>"));
|
||||
strUsage += HelpMessageOpt("-zmqpubrawtx=<address>", _("Enable publish raw transaction in <address>"));
|
||||
strUsage += HelpMessageOpt("-zmqpubrawtxlock=<address>", _("Enable publish raw transaction (locked via InstantSend) in <address>"));
|
||||
#endif
|
||||
|
||||
strUsage += HelpMessageGroup(_("Debugging/Testing options:"));
|
||||
|
@ -406,7 +406,7 @@ void UpdateLockedTransaction(CTransaction& tx, bool fForceNotification) {
|
||||
#endif
|
||||
|
||||
if(nSignatures == INSTANTX_SIGNATURES_REQUIRED || (fForceNotification && nSignatures > INSTANTX_SIGNATURES_REQUIRED)) {
|
||||
GetMainSignals().NotifyTransactionLock(txHash);
|
||||
GetMainSignals().NotifyTransactionLock(tx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ class CValidationInterface {
|
||||
protected:
|
||||
virtual void UpdatedBlockTip(const CBlockIndex *pindex) {}
|
||||
virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock) {}
|
||||
virtual void NotifyTransactionLock(const uint256 &hash) {}
|
||||
virtual void NotifyTransactionLock(const CTransaction &tx) {}
|
||||
virtual void SetBestChain(const CBlockLocator &locator) {}
|
||||
virtual bool UpdatedTransaction(const uint256 &hash) { return false;}
|
||||
virtual void Inventory(const uint256 &hash) {}
|
||||
@ -52,7 +52,7 @@ struct CMainSignals {
|
||||
/** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */
|
||||
boost::signals2::signal<void (const CTransaction &, const CBlock *)> SyncTransaction;
|
||||
/** Notifies listeners of an updated transaction lock without new data. */
|
||||
boost::signals2::signal<void (const uint256 &)> NotifyTransactionLock;
|
||||
boost::signals2::signal<void (const CTransaction &)> NotifyTransactionLock;
|
||||
/** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
|
||||
boost::signals2::signal<bool (const uint256 &)> UpdatedTransaction;
|
||||
/** Notifies listeners of a new active block chain. */
|
||||
|
@ -21,7 +21,7 @@ bool CZMQAbstractNotifier::NotifyTransaction(const CTransaction &/*transaction*/
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CZMQAbstractNotifier::NotifyTransactionLock(const uint256 &/*hash*/)
|
||||
bool CZMQAbstractNotifier::NotifyTransactionLock(const CTransaction &/*transaction*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
|
||||
virtual bool NotifyBlock(const CBlockIndex *pindex);
|
||||
virtual bool NotifyTransaction(const CTransaction &transaction);
|
||||
virtual bool NotifyTransactionLock(const uint256 &hash);
|
||||
virtual bool NotifyTransactionLock(const CTransaction &transaction);
|
||||
|
||||
protected:
|
||||
void *psocket;
|
||||
|
@ -40,6 +40,7 @@ CZMQNotificationInterface* CZMQNotificationInterface::CreateWithArguments(const
|
||||
factories["pubhashtxlock"] = CZMQAbstractNotifier::Create<CZMQPublishHashTransactionLockNotifier>;
|
||||
factories["pubrawblock"] = CZMQAbstractNotifier::Create<CZMQPublishRawBlockNotifier>;
|
||||
factories["pubrawtx"] = CZMQAbstractNotifier::Create<CZMQPublishRawTransactionNotifier>;
|
||||
factories["pubrawtxlock"] = CZMQAbstractNotifier::Create<CZMQPublishRawTransactionLockNotifier>;
|
||||
|
||||
for (std::map<std::string, CZMQNotifierFactory>::const_iterator i=factories.begin(); i!=factories.end(); ++i)
|
||||
{
|
||||
@ -160,12 +161,12 @@ void CZMQNotificationInterface::SyncTransaction(const CTransaction &tx, const CB
|
||||
}
|
||||
}
|
||||
|
||||
void CZMQNotificationInterface::NotifyTransactionLock(const uint256 &hash)
|
||||
void CZMQNotificationInterface::NotifyTransactionLock(const CTransaction &tx)
|
||||
{
|
||||
for (std::list<CZMQAbstractNotifier*>::iterator i = notifiers.begin(); i!=notifiers.end(); )
|
||||
{
|
||||
CZMQAbstractNotifier *notifier = *i;
|
||||
if (notifier->NotifyTransactionLock(hash))
|
||||
if (notifier->NotifyTransactionLock(tx))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ protected:
|
||||
// CValidationInterface
|
||||
void SyncTransaction(const CTransaction &tx, const CBlock *pblock);
|
||||
void UpdatedBlockTip(const CBlockIndex *pindex);
|
||||
void NotifyTransactionLock(const uint256 &hash);
|
||||
void NotifyTransactionLock(const CTransaction &tx);
|
||||
|
||||
private:
|
||||
CZMQNotificationInterface();
|
||||
|
@ -139,8 +139,9 @@ bool CZMQPublishHashTransactionNotifier::NotifyTransaction(const CTransaction &t
|
||||
return rc == 0;
|
||||
}
|
||||
|
||||
bool CZMQPublishHashTransactionLockNotifier::NotifyTransactionLock(const uint256 &hash)
|
||||
bool CZMQPublishHashTransactionLockNotifier::NotifyTransactionLock(const CTransaction &transaction)
|
||||
{
|
||||
uint256 hash = transaction.GetHash();
|
||||
LogPrint("zmq", "zmq: Publish hashtxlock %s\n", hash.GetHex());
|
||||
char data[32];
|
||||
for (unsigned int i = 0; i < 32; i++)
|
||||
@ -180,3 +181,13 @@ bool CZMQPublishRawTransactionNotifier::NotifyTransaction(const CTransaction &tr
|
||||
int rc = zmq_send_multipart(psocket, "rawtx", 5, &(*ss.begin()), ss.size(), 0);
|
||||
return rc == 0;
|
||||
}
|
||||
|
||||
bool CZMQPublishRawTransactionLockNotifier::NotifyTransactionLock(const CTransaction &transaction)
|
||||
{
|
||||
uint256 hash = transaction.GetHash();
|
||||
LogPrint("zmq", "zmq: Publish rawtxlock %s\n", hash.GetHex());
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss << transaction;
|
||||
int rc = zmq_send_multipart(psocket, "rawtxlock", 9, &(*ss.begin()), ss.size(), 0);
|
||||
return rc == 0;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
class CZMQPublishHashTransactionLockNotifier : public CZMQAbstractPublishNotifier
|
||||
{
|
||||
public:
|
||||
bool NotifyTransactionLock(const uint256 &hash);
|
||||
bool NotifyTransactionLock(const CTransaction &transaction);
|
||||
};
|
||||
|
||||
class CZMQPublishRawBlockNotifier : public CZMQAbstractPublishNotifier
|
||||
@ -46,4 +46,10 @@ public:
|
||||
bool NotifyTransaction(const CTransaction &transaction);
|
||||
};
|
||||
|
||||
class CZMQPublishRawTransactionLockNotifier : public CZMQAbstractPublishNotifier
|
||||
{
|
||||
public:
|
||||
bool NotifyTransactionLock(const CTransaction &transaction);
|
||||
};
|
||||
|
||||
#endif // BITCOIN_ZMQ_ZMQPUBLISHNOTIFIER_H
|
||||
|
Loading…
Reference in New Issue
Block a user