diff --git a/libraries/octree/src/OctreeEditPacketSender.cpp b/libraries/octree/src/OctreeEditPacketSender.cpp index 634a0bb260..86208c9fd2 100644 --- a/libraries/octree/src/OctreeEditPacketSender.cpp +++ b/libraries/octree/src/OctreeEditPacketSender.cpp @@ -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(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); diff --git a/libraries/octree/src/OctreeEditPacketSender.h b/libraries/octree/src/OctreeEditPacketSender.h index d11aa55963..7b39a1d785 100644 --- a/libraries/octree/src/OctreeEditPacketSender.h +++ b/libraries/octree/src/OctreeEditPacketSender.h @@ -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 _sentPacketHistories; QHash _outgoingSequenceNumbers; + + QUuid _destinationWalletUUID; }; #endif // hifi_OctreeEditPacketSender_h