mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +02:00
have the OctreeEditPacketSender emit a signal when payment is required
This commit is contained in:
parent
04effabe48
commit
eba92eb517
2 changed files with 21 additions and 4 deletions
|
@ -26,7 +26,10 @@ OctreeEditPacketSender::OctreeEditPacketSender() :
|
|||
_maxPendingMessages(DEFAULT_MAX_PENDING_MESSAGES),
|
||||
_releaseQueuedMessagesPending(false),
|
||||
_serverJurisdictions(NULL),
|
||||
_maxPacketSize(MAX_PACKET_SIZE) {
|
||||
_maxPacketSize(MAX_PACKET_SIZE),
|
||||
_destinationWalletUUID()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
OctreeEditPacketSender::~OctreeEditPacketSender() {
|
||||
|
@ -98,6 +101,12 @@ void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, unsigned c
|
|||
// send packet
|
||||
QByteArray packet(reinterpret_cast<const char*>(buffer), length);
|
||||
queuePacketForSending(node, packet);
|
||||
|
||||
if (hasDestinationWalletUUID() && satoshiCost > 0) {
|
||||
// if we have a destination wallet UUID and a cost associated with this packet, signal that it
|
||||
// needs to be sent
|
||||
emit octreePaymentRequired(satoshiCost, nodeUUID, _destinationWalletUUID);
|
||||
}
|
||||
|
||||
// add packet to history
|
||||
_sentPacketHistories[nodeUUID].packetSent(sequence, packet);
|
||||
|
|
|
@ -82,13 +82,19 @@ public:
|
|||
// you must override these...
|
||||
virtual char getMyNodeType() const = 0;
|
||||
virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { };
|
||||
|
||||
bool hasDestinationWalletUUID() const { return _destinationWalletUUID.isNull(); }
|
||||
void setDestinationWalletUUID(const QUuid& destinationWalletUUID) { _destinationWalletUUID = destinationWalletUUID; }
|
||||
const QUuid& getDestinationWalletUUID() { return _destinationWalletUUID; }
|
||||
|
||||
void processNackPacket(const QByteArray& packet);
|
||||
|
||||
public slots:
|
||||
void nodeKilled(SharedNodePointer node);
|
||||
|
||||
public:
|
||||
void processNackPacket(const QByteArray& packet);
|
||||
|
||||
signals:
|
||||
void octreePaymentRequired(qint64 satoshiAmount, const QUuid& nodeUUID, const QUuid& destinationWalletUUID);
|
||||
|
||||
protected:
|
||||
bool _shouldSend;
|
||||
void queuePacketToNode(const QUuid& nodeID, unsigned char* buffer, ssize_t length, qint64 satoshiCost = 0);
|
||||
|
@ -118,5 +124,7 @@ protected:
|
|||
// TODO: add locks for this and _pendingEditPackets
|
||||
QHash<QUuid, SentPacketHistory> _sentPacketHistories;
|
||||
QHash<QUuid, quint16> _outgoingSequenceNumbers;
|
||||
|
||||
QUuid _destinationWalletUUID;
|
||||
};
|
||||
#endif // hifi_OctreeEditPacketSender_h
|
||||
|
|
Loading…
Reference in a new issue