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;
}
}
};