diff --git a/include/opendht/value.h b/include/opendht/value.h index 7b0020d643637e27938acbe494b8d1702c9886a7..9df6edebe3e6ff2131e6d15cabb8cda62da5d9c1 100644 --- a/include/opendht/value.h +++ b/include/opendht/value.h @@ -268,7 +268,7 @@ struct Value inline bool operator== (const Value& o) { return id == o.id && (isEncrypted() ? cypher == o.cypher : - (owner == o.owner && type == o.type && data == o.data && signature == o.signature)); + (owner == o.owner && type == o.type && data == o.data && user_type == o.user_type && signature == o.signature)); } void setRecipient(const InfoHash& r) { diff --git a/src/dht.cpp b/src/dht.cpp index 4d62f2130df406b72e6604cebfb318b8143679b3..3abec42718a9cd8c5b022640528d905d6b7c96a7 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -197,6 +197,7 @@ Dht::shutdown(ShutdownCallback cb) { for (auto str : store) { *remaining += maintainStorage(str.id, true, str_donecb); } + DHT_WARN("Shuting down node: %u ops remaining.", *remaining); if (!*remaining && cb) { cb(); } } @@ -2617,32 +2618,32 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc } for (const auto& v : msg.values) { if (v->id == Value::INVALID_ID) { - DHT_WARN("[node %s %s] incorrect value id", - msg.id.toString().c_str(), print_addr(from, fromlen).c_str(), - msg.info_hash.toString().c_str(), to_hex(msg.token.data(), msg.token.size()).c_str()); - - DHT_WARN("Incorrect value id "); + DHT_WARN("[value %s %s] incorrect value id", msg.info_hash.toString().c_str(), v->id); sendError(from, fromlen, msg.tid, 203, "Put with invalid id"); continue; } auto lv = getLocalById(msg.info_hash, v->id); std::shared_ptr<Value> vc = v; if (lv) { - const auto& type = getType(lv->type); - if (type.editPolicy(msg.info_hash, lv, vc, msg.id, from, fromlen)) { - DHT_DEBUG("Editing value of type %s belonging to %s at %s.", type.name.c_str(), v->owner.getId().toString().c_str(), msg.info_hash.toString().c_str()); - storageStore(msg.info_hash, vc, msg.created); + if (*lv == *vc) { + DHT_WARN("[value %s %lu] nothing to do.", msg.info_hash.toString().c_str(), lv->id); } else { - DHT_WARN("Rejecting edition of type %s belonging to %s at %s because of storage policy.", type.name.c_str(), v->owner.getId().toString().c_str(), msg.info_hash.toString().c_str()); + const auto& type = getType(lv->type); + if (type.editPolicy(msg.info_hash, lv, vc, msg.id, from, fromlen)) { + DHT_DEBUG("[value %s %lu] editing %s.", msg.info_hash.toString().c_str(), lv->id, vc->toString().c_str()); + storageStore(msg.info_hash, vc, msg.created); + } else { + DHT_DEBUG("[value %s %lu] rejecting edition of %s because of storage policy.", msg.info_hash.toString().c_str(), lv->id, vc->toString().c_str()); + } } } else { // Allow the value to be edited by the storage policy const auto& type = getType(vc->type); if (type.storePolicy(msg.info_hash, vc, msg.id, from, fromlen)) { - DHT_DEBUG("Storing value of type %s belonging to %s at %s.", type.name.c_str(), v->owner.getId().toString().c_str(), msg.info_hash.toString().c_str()); + DHT_DEBUG("[value %s %lu] storing %s.", msg.info_hash.toString().c_str(), lv->id, vc->toString().c_str()); storageStore(msg.info_hash, vc, msg.created); } else { - DHT_WARN("Rejecting storage of type %s belonging to %s at %s because of storage policy.", type.name.c_str(), v->owner.getId().toString().c_str(), msg.info_hash.toString().c_str()); + DHT_DEBUG("[value %s %lu] rejecting storage of %s.", msg.info_hash.toString().c_str(), lv->id, vc->toString().c_str()); } }