最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

p2p - How do I define a ValueType of a Value in OpenDHT so that I could choose how data is stored on the DHT in the C++ implemen

programmeradmin1浏览0评论

I'm working on a P2P messenger for college and cannot seem to figure out how the library works. I apologize if I'm missing something but I don't see how I can use my custom ValueTypes.

This is one of the ValueTypes I have defined which I want to use:

const ValueType FRIEND_REQUEST_TYPE = {
    0x1001, "FriendRequest", std::chrono::hours(24 * 7),
    // Store policy: Verify request is signed
    [](InfoHash id, Sp<Value>& v, const InfoHash&, const SockAddr&) {
        if (!v->isSigned()) return false;
        try {
            // Verify certificate matches the value's owner
            return v->owner && v->owner->getId() == id;
        } catch (...) {
            return false;
        }
    },
    // Edit policy: Only original requester can modify
    [](InfoHash, const Sp<Value>& o, Sp<Value>& n, const InfoHash&, const SockAddr&) {
        try {
            // Compare certificate IDs from value owners
            return o->owner && n->owner && 
                    n->owner->getId() == o->owner->getId() &&
                    n->seq > o->seq;
        } catch (...) {
            return false;
        }
    }
};
发布评论

评论列表(0)

  1. 暂无评论