mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added backward compatibility and API extension for RsGxsGrpMetaData
This commit is contained in:
parent
d69f2709c3
commit
2096cd6c52
@ -60,7 +60,7 @@ static const uint32_t INDEX_AUTHEN_ADMIN = 0x00000040; // admin key
|
||||
|
||||
#define GXS_MASK "GXS_MASK_HACK"
|
||||
|
||||
//#define GEN_EXCH_DEBUG 1
|
||||
#define GEN_EXCH_DEBUG 1
|
||||
|
||||
#define MSG_CLEANUP_PERIOD 60*5 // 5 minutes
|
||||
#define INTEGRITY_CHECK_PERIOD 60*30 // 30 minutes
|
||||
|
@ -28,6 +28,11 @@
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
|
||||
static const uint32_t RS_GXS_GRP_META_DATA_VERSION_ID_0001 = 0x0000 ; // change this, and keep old values if the content changes
|
||||
static const uint32_t RS_GXS_GRP_META_DATA_VERSION_ID_0002 = 0xaf01 ; // current API
|
||||
|
||||
static const uint32_t RS_GXS_MSG_META_DATA_VERSION_ID_0001 = 0x0000 ; // current API
|
||||
|
||||
RsGxsGrpMetaData::RsGxsGrpMetaData()
|
||||
{
|
||||
clear();
|
||||
@ -104,7 +109,7 @@ bool RsGxsGrpMetaData::serialise(void *data, uint32_t &pktsize)
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, 0, tlvsize);
|
||||
ok &= setRsItemHeader(data, tlvsize, RS_GXS_GRP_META_DATA_VERSION_ID_0002, tlvsize);
|
||||
|
||||
#ifdef GXS_DEBUG
|
||||
std::cerr << "RsGxsGrpMetaData serialise()" << std::endl;
|
||||
@ -122,7 +127,7 @@ bool RsGxsGrpMetaData::serialise(void *data, uint32_t &pktsize)
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mGroupFlags);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mPublishTs);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mCircleType);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mSignFlags);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mAuthenFlags);
|
||||
ok &= mAuthorId.serialise(data, tlvsize, offset);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, 0, mServiceString);
|
||||
ok &= mCircleId.serialise(data, tlvsize, offset);
|
||||
@ -130,6 +135,7 @@ bool RsGxsGrpMetaData::serialise(void *data, uint32_t &pktsize)
|
||||
ok &= signSet.SetTlv(data, tlvsize, &offset);
|
||||
ok &= keys.SetTlv(data, tlvsize, &offset);
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mSignFlags); // new in API v2. Was previously missing. Kept in the end for backward compatibility
|
||||
|
||||
return ok;
|
||||
}
|
||||
@ -153,13 +159,32 @@ bool RsGxsGrpMetaData::deserialise(void *data, uint32_t &pktsize)
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &mGroupFlags);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &mPublishTs);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &mCircleType);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &mSignFlags);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &mAuthenFlags);
|
||||
|
||||
|
||||
ok &= mAuthorId.deserialise(data, pktsize, offset);
|
||||
ok &= GetTlvString(data, pktsize, &offset, 0, mServiceString);
|
||||
ok &= mCircleId.deserialise(data, pktsize, offset);
|
||||
ok &= signSet.GetTlv(data, pktsize, &offset);
|
||||
ok &= keys.GetTlv(data, pktsize, &offset);
|
||||
|
||||
switch(getRsItemId(data))
|
||||
{
|
||||
case RS_GXS_GRP_META_DATA_VERSION_ID_0002: ok &= getRawUInt32(data, pktsize, &offset, &mSignFlags); // current API
|
||||
break ;
|
||||
|
||||
case RS_GXS_GRP_META_DATA_VERSION_ID_0001: mSignFlags = 0; // old API. Do not leave this uninitialised!
|
||||
break ;
|
||||
|
||||
default:
|
||||
std::cerr << "(EE) RsGxsGrpMetaData::deserialise(): ERROR: unknown API version " << std::hex << getRsItemId(data) << std::dec << std::endl;
|
||||
}
|
||||
|
||||
if(offset != pktsize)
|
||||
{
|
||||
std::cerr << "(EE) RsGxsGrpMetaData::deserialise(): ERROR: unmatched size " << offset << ", expected: " << pktsize << std::dec << std::endl;
|
||||
return false ;
|
||||
}
|
||||
#ifdef DROP_NON_CANONICAL_ITEMS
|
||||
if(mGroupName.length() > RsGxsGrpMetaData::MAX_ALLOWED_STRING_SIZE)
|
||||
{
|
||||
@ -202,7 +227,8 @@ uint32_t RsGxsMsgMetaData::serial_size()
|
||||
|
||||
s += signSet.TlvSize();
|
||||
s += GetTlvStringSize(mMsgName);
|
||||
s += 4;
|
||||
s += 4; // mAuthenFlags
|
||||
s += 4; // mSignFlags
|
||||
s += 4;
|
||||
|
||||
return s;
|
||||
@ -239,7 +265,7 @@ bool RsGxsMsgMetaData::serialise(void *data, uint32_t *size)
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, 0, tlvsize);
|
||||
ok &= setRsItemHeader(data, tlvsize, RS_GXS_MSG_META_DATA_VERSION_ID_0001, tlvsize);
|
||||
|
||||
#ifdef GXS_DEBUG
|
||||
std::cerr << "RsGxsGrpMetaData serialise()" << std::endl;
|
||||
|
@ -133,11 +133,7 @@ static const int ACTIVE_FRIENDS_UPDATE_PERIOD = 600 ; // 10 minu
|
||||
static const int ACTIVE_FRIENDS_ONLINE_DELAY = 86400*7 ; // 1 week.
|
||||
static const int kReputationRequestPeriod = 600; // 10 mins
|
||||
static const int kReputationStoreWait = 180; // 3 minutes.
|
||||
|
||||
static const float REPUTATION_ASSESSMENT_THRESHOLD_X1 = 0.5f ; // reputation under which the peer gets killed
|
||||
static const float REPUTATION_PGP_LINKED_ID_BIAS = 0.2f ;
|
||||
static const float REPUTATION_PGP_KNOWN_ID_BIAS = 0.3f ; // so known pgp-linked ids go up to +0.5f
|
||||
static const float REPUTATION_FRIEND_VARIANCE = 3.0f ;
|
||||
|
||||
|
||||
p3GxsReputation::p3GxsReputation(p3LinkMgr *lm)
|
||||
|
Loading…
Reference in New Issue
Block a user