mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:49:24 +02:00
pass wallet UUID from AC to DS, cleanup noisy timer
This commit is contained in:
parent
899c89eda7
commit
8a1fdf3486
4 changed files with 47 additions and 16 deletions
|
@ -67,9 +67,20 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
||||||
if (argumentIndex != -1) {
|
if (argumentIndex != -1) {
|
||||||
assignmentPool = argumentList[argumentIndex + 1];
|
assignmentPool = argumentList[argumentIndex + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup our _requestAssignment member variable from the passed arguments
|
// setup our _requestAssignment member variable from the passed arguments
|
||||||
_requestAssignment = Assignment(Assignment::RequestCommand, requestAssignmentType, assignmentPool);
|
_requestAssignment = Assignment(Assignment::RequestCommand, requestAssignmentType, assignmentPool);
|
||||||
|
|
||||||
|
// check if we were passed a wallet UUID on the command line
|
||||||
|
// this would represent where the user running AC wants funds sent to
|
||||||
|
|
||||||
|
const QString ASSIGNMENT_WALLET_DESTINATION_ID_OPTION = "--wallet";
|
||||||
|
if ((argumentIndex = argumentList.indexOf(ASSIGNMENT_WALLET_DESTINATION_ID_OPTION)) != -1) {
|
||||||
|
QUuid walletUUID = QString(argumentList[argumentIndex + 1]);
|
||||||
|
qDebug() << "The destination wallet UUID for credits is" << uuidStringWithoutCurlyBraces(walletUUID);
|
||||||
|
_requestAssignment.setWalletUUID(walletUUID);
|
||||||
|
}
|
||||||
|
|
||||||
// create a NodeList as an unassigned client
|
// create a NodeList as an unassigned client
|
||||||
NodeList* nodeList = NodeList::createInstance(NodeType::Unassigned);
|
NodeList* nodeList = NodeList::createInstance(NodeType::Unassigned);
|
||||||
|
|
||||||
|
|
|
@ -564,14 +564,21 @@ void DomainServer::readAvailableDatagrams() {
|
||||||
Assignment requestAssignment(receivedPacket);
|
Assignment requestAssignment(receivedPacket);
|
||||||
|
|
||||||
// Suppress these for Assignment::AgentType to once per 5 seconds
|
// Suppress these for Assignment::AgentType to once per 5 seconds
|
||||||
static quint64 lastNoisyMessage = usecTimestampNow();
|
static QElapsedTimer noisyMessageTimer;
|
||||||
quint64 timeNow = usecTimestampNow();
|
static bool wasNoisyTimerStarted = false;
|
||||||
const quint64 NOISY_TIME_ELAPSED = 5 * USECS_PER_SECOND;
|
|
||||||
bool noisyMessage = false;
|
if (!wasNoisyTimerStarted) {
|
||||||
if (requestAssignment.getType() != Assignment::AgentType || (timeNow - lastNoisyMessage) > NOISY_TIME_ELAPSED) {
|
noisyMessageTimer.start();
|
||||||
|
wasNoisyTimerStarted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const quint64 NOISY_MESSAGE_INTERVAL_MSECS = 5 * 1000;
|
||||||
|
|
||||||
|
if (requestAssignment.getType() != Assignment::AgentType
|
||||||
|
|| noisyMessageTimer.elapsed() > NOISY_MESSAGE_INTERVAL_MSECS) {
|
||||||
qDebug() << "Received a request for assignment type" << requestAssignment.getType()
|
qDebug() << "Received a request for assignment type" << requestAssignment.getType()
|
||||||
<< "from" << senderSockAddr;
|
<< "from" << senderSockAddr;
|
||||||
noisyMessage = true;
|
noisyMessageTimer.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedAssignmentPointer assignmentToDeploy = deployableAssignmentForRequest(requestAssignment);
|
SharedAssignmentPointer assignmentToDeploy = deployableAssignmentForRequest(requestAssignment);
|
||||||
|
@ -589,16 +596,13 @@ void DomainServer::readAvailableDatagrams() {
|
||||||
nodeList->getNodeSocket().writeDatagram(assignmentPacket,
|
nodeList->getNodeSocket().writeDatagram(assignmentPacket,
|
||||||
senderSockAddr.getAddress(), senderSockAddr.getPort());
|
senderSockAddr.getAddress(), senderSockAddr.getPort());
|
||||||
} else {
|
} else {
|
||||||
if (requestAssignment.getType() != Assignment::AgentType || (timeNow - lastNoisyMessage) > NOISY_TIME_ELAPSED) {
|
if (requestAssignment.getType() != Assignment::AgentType
|
||||||
|
|| noisyMessageTimer.elapsed() > NOISY_MESSAGE_INTERVAL_MSECS) {
|
||||||
qDebug() << "Unable to fulfill assignment request of type" << requestAssignment.getType()
|
qDebug() << "Unable to fulfill assignment request of type" << requestAssignment.getType()
|
||||||
<< "from" << senderSockAddr;
|
<< "from" << senderSockAddr;
|
||||||
noisyMessage = true;
|
noisyMessageTimer.restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noisyMessage) {
|
|
||||||
lastNoisyMessage = timeNow;
|
|
||||||
}
|
|
||||||
} else if (!_isUsingDTLS) {
|
} else if (!_isUsingDTLS) {
|
||||||
// not using DTLS, process datagram normally
|
// not using DTLS, process datagram normally
|
||||||
processDatagram(receivedPacket, senderSockAddr);
|
processDatagram(receivedPacket, senderSockAddr);
|
||||||
|
|
|
@ -63,7 +63,8 @@ Assignment::Assignment(Assignment::Command command, Assignment::Type type, const
|
||||||
_pool(pool),
|
_pool(pool),
|
||||||
_location(location),
|
_location(location),
|
||||||
_payload(),
|
_payload(),
|
||||||
_isStatic(false)
|
_isStatic(false),
|
||||||
|
_walletUUID()
|
||||||
{
|
{
|
||||||
if (_command == Assignment::CreateCommand) {
|
if (_command == Assignment::CreateCommand) {
|
||||||
// this is a newly created assignment, generate a random UUID
|
// this is a newly created assignment, generate a random UUID
|
||||||
|
@ -74,7 +75,8 @@ Assignment::Assignment(Assignment::Command command, Assignment::Type type, const
|
||||||
Assignment::Assignment(const QByteArray& packet) :
|
Assignment::Assignment(const QByteArray& packet) :
|
||||||
_pool(),
|
_pool(),
|
||||||
_location(GlobalLocation),
|
_location(GlobalLocation),
|
||||||
_payload()
|
_payload(),
|
||||||
|
_walletUUID()
|
||||||
{
|
{
|
||||||
PacketType packetType = packetTypeForPacket(packet);
|
PacketType packetType = packetTypeForPacket(packet);
|
||||||
|
|
||||||
|
@ -104,6 +106,7 @@ Assignment::Assignment(const Assignment& otherAssignment) {
|
||||||
_location = otherAssignment._location;
|
_location = otherAssignment._location;
|
||||||
_pool = otherAssignment._pool;
|
_pool = otherAssignment._pool;
|
||||||
_payload = otherAssignment._payload;
|
_payload = otherAssignment._payload;
|
||||||
|
_walletUUID = otherAssignment._walletUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
Assignment& Assignment::operator=(const Assignment& rhsAssignment) {
|
Assignment& Assignment::operator=(const Assignment& rhsAssignment) {
|
||||||
|
@ -121,6 +124,7 @@ void Assignment::swap(Assignment& otherAssignment) {
|
||||||
swap(_location, otherAssignment._location);
|
swap(_location, otherAssignment._location);
|
||||||
swap(_pool, otherAssignment._pool);
|
swap(_pool, otherAssignment._pool);
|
||||||
swap(_payload, otherAssignment._payload);
|
swap(_payload, otherAssignment._payload);
|
||||||
|
swap(_walletUUID, otherAssignment._walletUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Assignment::getTypeName() const {
|
const char* Assignment::getTypeName() const {
|
||||||
|
@ -156,6 +160,10 @@ QDebug operator<<(QDebug debug, const Assignment &assignment) {
|
||||||
QDataStream& operator<<(QDataStream &out, const Assignment& assignment) {
|
QDataStream& operator<<(QDataStream &out, const Assignment& assignment) {
|
||||||
out << (quint8) assignment._type << assignment._uuid << assignment._pool << assignment._payload;
|
out << (quint8) assignment._type << assignment._uuid << assignment._pool << assignment._payload;
|
||||||
|
|
||||||
|
if (assignment._command == Assignment::RequestCommand) {
|
||||||
|
out << assignment._walletUUID;
|
||||||
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,5 +174,9 @@ QDataStream& operator>>(QDataStream &in, Assignment& assignment) {
|
||||||
|
|
||||||
in >> assignment._uuid >> assignment._pool >> assignment._payload;
|
in >> assignment._uuid >> assignment._pool >> assignment._payload;
|
||||||
|
|
||||||
|
if (assignment._command == Assignment::RequestCommand) {
|
||||||
|
in >> assignment._walletUUID;
|
||||||
|
}
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,9 @@ public:
|
||||||
void setIsStatic(bool isStatic) { _isStatic = isStatic; }
|
void setIsStatic(bool isStatic) { _isStatic = isStatic; }
|
||||||
bool isStatic() const { return _isStatic; }
|
bool isStatic() const { return _isStatic; }
|
||||||
|
|
||||||
|
void setWalletUUID(const QUuid& walletUUID) { _walletUUID = walletUUID; }
|
||||||
|
const QUuid& getWalletUUID() const { return _walletUUID; }
|
||||||
|
|
||||||
const char* getTypeName() const;
|
const char* getTypeName() const;
|
||||||
|
|
||||||
// implement parseData to return 0 so we can be a subclass of NodeData
|
// implement parseData to return 0 so we can be a subclass of NodeData
|
||||||
|
@ -98,6 +101,7 @@ protected:
|
||||||
Assignment::Location _location; /// the location of the assignment, allows a domain to preferentially use local ACs
|
Assignment::Location _location; /// the location of the assignment, allows a domain to preferentially use local ACs
|
||||||
QByteArray _payload; /// an optional payload attached to this assignment, a maximum for 1024 bytes will be packed
|
QByteArray _payload; /// an optional payload attached to this assignment, a maximum for 1024 bytes will be packed
|
||||||
bool _isStatic; /// defines if this assignment needs to be re-queued in the domain-server if it stops being fulfilled
|
bool _isStatic; /// defines if this assignment needs to be re-queued in the domain-server if it stops being fulfilled
|
||||||
|
QUuid _walletUUID; /// the UUID for the wallet that should be paid for this assignment
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Assignment_h
|
#endif // hifi_Assignment_h
|
||||||
|
|
Loading…
Reference in a new issue