remaining code for nxs sync optimisation

- still needs testing

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs_finale@6903 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2013-11-16 13:40:04 +00:00
parent 2e886bf443
commit f74aacd759
7 changed files with 678 additions and 59 deletions

View file

@ -24,15 +24,11 @@
*/
#include "rsgxsupdateitems.h"
#include "rsbaseserial.h"
RsGxsGrpUpdateItem::RsGxsGrpUpdateItem() {
}
RsGxsGrpUpdateItem::~RsGxsGrpUpdateItem() {
}
void RsGxsGrpUpdateItem::clear()
{
@ -45,12 +41,7 @@ std::ostream& RsGxsGrpUpdateItem::print(std::ostream& out, uint16_t indent)
}
RsGxsMsgUpdateItem::RsGxsMsgUpdateItem()
{
}
RsGxsMsgUpdateItem::~RsGxsMsgUpdateItem() {
}
void RsGxsMsgUpdateItem::clear()
{
@ -66,12 +57,20 @@ uint32_t RsGxsUpdateSerialiser::size(RsItem* item)
{
RsGxsMsgUpdateItem* mui = NULL;
RsGxsGrpUpdateItem* gui = NULL;
RsGxsServerGrpUpdateItem* gsui = NULL;
RsGxsServerMsgUpdateItem* msui = NULL;
if((mui = dynamic_cast<RsGxsMsgUpdateItem*>(item)) != NULL)
{
return sizeGxsMsgUpdate(mui);
}else if(( gui = dynamic_cast<RsGxsGrpUpdateItem*>(item)) != NULL){
return sizeGxsGrpUpdate(gui);
}else if((gsui = dynamic_cast<RsGxsServerGrpUpdateItem*>(item)) != NULL)
{
return sizeGxsServerGrpUpdate(gsui);
}else if((msui = dynamic_cast<RsGxsServerMsgUpdateItem*>(item)) != NULL)
{
return sizeGxsServerMsgUpdate(msui);
}else
{
#ifdef RSSERIAL_DEBUG
@ -85,19 +84,41 @@ uint32_t RsGxsUpdateSerialiser::size(RsItem* item)
bool RsGxsUpdateSerialiser::serialise(RsItem* item, void* data,
uint32_t* size)
{
RsGxsMsgUpdateItem* mui;
RsGxsGrpUpdateItem* gui;
RsGxsServerGrpUpdateItem* gsui;
RsGxsServerMsgUpdateItem* msui;
if((mui = dynamic_cast<RsGxsMsgUpdateItem*>(item)) != NULL)
return serialiseGxsMsgUpdate(mui, data, size);
else if((gui = dynamic_cast<RsGxsGrpUpdateItem*>(item)) != NULL)
return serialiseGxsGrpUpdate(gui, data, size);
else if((msui = dynamic_cast<RsGxsServerMsgUpdateItem*>(item)) != NULL)
return serialiseGxsServerMsgUpdate(msui, data, size);
else if((gsui = dynamic_cast<RsGxsServerGrpUpdateItem*>(item)) != NULL)
return serialiseGxsServerGrpUpdate(gsui, data, size);
else
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::serialise() item does not caste to known type"
<< std::endl;
#endif
return false;
}
}
RsItem* RsGxsUpdateSerialiser::deserialise(void* data, uint32_t* size)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsNxsSerialiser::deserialise()" << std::endl;
std::cerr << "RsGxsUpdateSerialiser::deserialise()" << std::endl;
#endif
/* get the type and size */
uint32_t rstype = getRsItemId(data);
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
(SERVICE_TYPE != getRsItemService(rstype)))
(SERVICE_TYPE != getRsItemService(rstype)))
{
return NULL; /* wrong type */
}
@ -109,6 +130,10 @@ RsItem* RsGxsUpdateSerialiser::deserialise(void* data, uint32_t* size)
return deserialGxsMsgUpdate(data, size);
case RS_PKT_SUBTYPE_GXS_GRP_UPDATE:
return deserialGxsGrpUpddate(data, size);
case RS_PKT_SUBTYPE_GXS_SERVER_GRP_UPDATE:
return deserialGxsServerGrpUpddate(data, size);
case RS_PKT_SUBTYPE_GXS_SERVER_MSG_UPDATE:
return deserialGxsServerMsgUpdate(data, size);
default:
{
#ifdef RSSERIAL_DEBUG
@ -129,6 +154,13 @@ uint32_t RsGxsUpdateSerialiser::sizeGxsGrpUpdate(RsGxsGrpUpdateItem* item)
return s;
}
uint32_t RsGxsUpdateSerialiser::sizeGxsServerGrpUpdate(RsGxsServerGrpUpdateItem* item)
{
uint32_t s = 8; // header size
s += 4; // time stamp
return s;
}
bool RsGxsUpdateSerialiser::serialiseGxsGrpUpdate(RsGxsGrpUpdateItem* item,
void* data, uint32_t* size)
{
@ -155,7 +187,7 @@ bool RsGxsUpdateSerialiser::serialiseGxsGrpUpdate(RsGxsGrpUpdateItem* item,
/* skip the header */
offset += 8;
/* RsNxsSyncm */
/* RsGxsGrpUpdateItem */
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_PEERID, item->peerId);
@ -178,10 +210,182 @@ bool RsGxsUpdateSerialiser::serialiseGxsGrpUpdate(RsGxsGrpUpdateItem* item,
return ok;
}
bool RsGxsUpdateSerialiser::serialiseGxsServerGrpUpdate(RsGxsServerGrpUpdateItem* item,
void* data, uint32_t* size)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::serialiseGxsServerGrpUpdate()" << std::endl;
#endif
uint32_t tlvsize = sizeGxsServerGrpUpdate(item);
uint32_t offset = 0;
if(*size < tlvsize){
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::serialiseGxsServerGrpUpdate() size do not match" << std::endl;
#endif
return false;
}
*size = tlvsize;
bool ok = true;
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
/* skip the header */
offset += 8;
/* RsGxsServerGrpUpdateItem */
ok &= setRawUInt32(data, *size, &offset, item->grpUpdateTS);
if(offset != tlvsize){
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::serialiseGxsServerGrpUpdate() FAIL Size Error! " << std::endl;
#endif
ok = false;
}
#ifdef RSSERIAL_DEBUG
if (!ok)
{
std::cerr << "RsGxsUpdateSerialiser::serialiseGxsServerGrpUpdate() NOK" << std::endl;
}
#endif
return ok;
}
RsGxsGrpUpdateItem* RsGxsUpdateSerialiser::deserialGxsGrpUpddate(void* data,
uint32_t* size)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsServerGrpUpdate()" << std::endl;
#endif
/* get the type and size */
uint32_t rstype = getRsItemId(data);
uint32_t rssize = getRsItemSize(data);
uint32_t offset = 0;
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
(SERVICE_TYPE != getRsItemService(rstype)) ||
(RS_PKT_SUBTYPE_GXS_GRP_UPDATE != getRsItemSubType(rstype)))
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsGrpUpdate() FAIL wrong type" << std::endl;
#endif
return NULL; /* wrong type */
}
if (*size < rssize) /* check size */
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsGrpUpdate() FAIL wrong size" << std::endl;
#endif
return NULL; /* not enough data */
}
/* set the packet length */
*size = rssize;
bool ok = true;
RsGxsGrpUpdateItem* item = new RsGxsGrpUpdateItem(getRsItemService(rstype));
/* skip the header */
offset += 8;
ok &= getRawUInt32(data, *size, &offset, &(item->grpUpdateTS));
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_PEERID, item->peerId);
if (offset != rssize)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxxGrpUpdate() FAIL size mismatch" << std::endl;
#endif
/* error */
delete item;
return NULL;
}
if (!ok)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsGrpUpdate() NOK" << std::endl;
#endif
delete item;
return NULL;
}
return item;
}
RsGxsServerGrpUpdateItem* RsGxsUpdateSerialiser::deserialGxsServerGrpUpddate(void* data,
uint32_t* size)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsServerGrpUpdate()" << std::endl;
#endif
/* get the type and size */
uint32_t rstype = getRsItemId(data);
uint32_t rssize = getRsItemSize(data);
uint32_t offset = 0;
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
(SERVICE_TYPE != getRsItemService(rstype)) ||
(RS_PKT_SUBTYPE_GXS_SERVER_GRP_UPDATE != getRsItemSubType(rstype)))
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsServerGrpUpdate() FAIL wrong type" << std::endl;
#endif
return NULL; /* wrong type */
}
if (*size < rssize) /* check size */
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsServerGrpUpdate() FAIL wrong size" << std::endl;
#endif
return NULL; /* not enough data */
}
/* set the packet length */
*size = rssize;
bool ok = true;
RsGxsServerGrpUpdateItem* item = new RsGxsServerGrpUpdateItem(getRsItemService(rstype));
/* skip the header */
offset += 8;
ok &= getRawUInt32(data, *size, &offset, &(item->grpUpdateTS));
if (offset != rssize)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsServerGrpUpdate() FAIL size mismatch" << std::endl;
#endif
/* error */
delete item;
return NULL;
}
if (!ok)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsServerGrpUpdate() NOK" << std::endl;
#endif
delete item;
return NULL;
}
return item;
}
uint32_t RsGxsUpdateSerialiser::sizeGxsMsgUpdate(RsGxsMsgUpdateItem* item)
@ -203,6 +407,15 @@ uint32_t RsGxsUpdateSerialiser::sizeGxsMsgUpdate(RsGxsMsgUpdateItem* item)
return s;
}
uint32_t RsGxsUpdateSerialiser::sizeGxsServerMsgUpdate(RsGxsServerMsgUpdateItem* item)
{
uint32_t s = 8; // header size
s += GetTlvStringSize(item->grpId);
s += 4; // grp TS
return s;
}
bool RsGxsUpdateSerialiser::serialiseGxsMsgUpdate(RsGxsMsgUpdateItem* item,
void* data, uint32_t* size)
{
@ -229,7 +442,7 @@ bool RsGxsUpdateSerialiser::serialiseGxsMsgUpdate(RsGxsMsgUpdateItem* item,
/* skip the header */
offset += 8;
/* RsNxsSyncm */
/* RsGxsMsgUpdateItem */
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_PEERID, item->peerId);
@ -263,6 +476,55 @@ bool RsGxsUpdateSerialiser::serialiseGxsMsgUpdate(RsGxsMsgUpdateItem* item,
return ok;
}
bool RsGxsUpdateSerialiser::serialiseGxsServerMsgUpdate(RsGxsServerMsgUpdateItem* item,
void* data, uint32_t* size)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::serialiseGxsServerMsgUpdate()" << std::endl;
#endif
uint32_t tlvsize = sizeGxsServerMsgUpdate(item);
uint32_t offset = 0;
if(*size < tlvsize){
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::serialiseGxsServerMsgUpdate() size do not match" << std::endl;
#endif
return false;
}
*size = tlvsize;
bool ok = true;
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
/* skip the header */
offset += 8;
/* RsNxsSyncm */
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
ok &= setRawUInt32(data, *size, &offset, item->msgUpdateTS);
if(offset != tlvsize){
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::serialiseGxsServerMsgUpdate() FAIL Size Error! " << std::endl;
#endif
ok = false;
}
#ifdef RSSERIAL_DEBUG
if (!ok)
{
std::cerr << "RsGxsUpdateSerialiser::serialiseGxsServerMsgUpdate() NOK" << std::endl;
}
#endif
return ok;
}
RsGxsMsgUpdateItem* RsGxsUpdateSerialiser::deserialGxsMsgUpdate(void* data,
uint32_t* size)
{
@ -278,7 +540,7 @@ RsGxsMsgUpdateItem* RsGxsUpdateSerialiser::deserialGxsMsgUpdate(void* data,
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
(SERVICE_TYPE != getRsItemService(rstype)) ||
(RS_PKT_SUBTYPE_NXS_SYNC_MSG != getRsItemSubType(rstype)))
(RS_PKT_SUBTYPE_GXS_MSG_UPDATE != getRsItemSubType(rstype)))
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsMsgUpdate() FAIL wrong type" << std::endl;
@ -304,10 +566,10 @@ RsGxsMsgUpdateItem* RsGxsUpdateSerialiser::deserialGxsMsgUpdate(void* data,
/* skip the header */
offset += 8;
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_HASH_SHA1, item->peerId);
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_PEERID, item->peerId);
uint32_t numUpdateItems;
ok &= getRawUInt32(data, *size, &offset, &(numUpdateItems));
std::map<std::string, uint32_t>& msgUpdateItem = item->grpUpdateTS;
std::map<std::string, uint32_t>& msgUpdateItem = item->msgUpdateTS;
std::string grpId;
uint32_t updateTS;
for(uint32_t i; i < numUpdateItems; i++)
@ -346,3 +608,70 @@ RsGxsMsgUpdateItem* RsGxsUpdateSerialiser::deserialGxsMsgUpdate(void* data,
return item;
}
RsGxsServerMsgUpdateItem* RsGxsUpdateSerialiser::deserialGxsServerMsgUpdate(void* data,
uint32_t* size)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsServerMsgUpdate()" << std::endl;
#endif
/* get the type and size */
uint32_t rstype = getRsItemId(data);
uint32_t rssize = getRsItemSize(data);
uint32_t offset = 0;
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
(SERVICE_TYPE != getRsItemService(rstype)) ||
(RS_PKT_SUBTYPE_GXS_SERVER_MSG_UPDATE != getRsItemSubType(rstype)))
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsServerMsgUpdate() FAIL wrong type" << std::endl;
#endif
return NULL; /* wrong type */
}
if (*size < rssize) /* check size */
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsServerMsgUpdate() FAIL wrong size" << std::endl;
#endif
return NULL; /* not enough data */
}
/* set the packet length */
*size = rssize;
bool ok = true;
RsGxsServerMsgUpdateItem* item = new RsGxsServerMsgUpdateItem(getRsItemService(rstype));
/* skip the header */
offset += 8;
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
ok &= getRawUInt32(data, *size, &offset, &(item->msgUpdateTS));
if (offset != rssize)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsServerMsgUpdate() FAIL size mismatch" << std::endl;
#endif
/* error */
delete item;
return NULL;
}
if (!ok)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsGxsUpdateSerialiser::deserialGxsServerMsgUpdate() NOK" << std::endl;
#endif
delete item;
return NULL;
}
return item;
}

View file

@ -37,13 +37,17 @@
#include "gxs/rsgxsdata.h"
const uint8_t RS_PKT_SUBTYPE_GXS_GRP_UPDATE = 0x0001;
const uint8_t RS_PKT_SUBTYPE_GXS_MSG_UPDATE = 0x0002;
const uint8_t RS_PKT_SUBTYPE_GXS_GRP_UPDATE = 0x0001;
const uint8_t RS_PKT_SUBTYPE_GXS_MSG_UPDATE = 0x0002;
const uint8_t RS_PKT_SUBTYPE_GXS_SERVER_GRP_UPDATE = 0x0004;
const uint8_t RS_PKT_SUBTYPE_GXS_SERVER_MSG_UPDATE = 0x0008;
class RsGxsGrpUpdateItem : public RsItem {
public:
RsGxsGrpUpdateItem();
virtual ~RsGxsGrpUpdateItem();
RsGxsGrpUpdateItem(uint16_t servType) : RsItem(RS_PKT_VERSION_SERVICE, servType,
RS_PKT_SUBTYPE_GXS_GRP_UPDATE)
{}
virtual ~RsGxsGrpUpdateItem() {}
virtual void clear();
virtual std::ostream &print(std::ostream &out, uint16_t indent);
@ -52,10 +56,24 @@ public:
uint32_t grpUpdateTS;
};
class RsGxsServerGrpUpdateItem : public RsItem {
public:
RsGxsServerGrpUpdateItem(uint16_t servType) : RsItem(RS_PKT_VERSION_SERVICE, servType,
RS_PKT_SUBTYPE_GXS_SERVER_GRP_UPDATE)
{}
virtual ~RsGxsServerGrpUpdateItem();
virtual void clear();
virtual std::ostream &print(std::ostream &out, uint16_t indent);
uint32_t grpUpdateTS;
};
class RsGxsMsgUpdateItem : public RsItem
{
public:
RsGxsMsgUpdateItem();
RsGxsMsgUpdateItem(uint16_t servType) : RsItem(RS_PKT_VERSION_SERVICE, servType, RS_PKT_SUBTYPE_GXS_MSG_UPDATE)
{}
virtual ~RsGxsMsgUpdateItem();
virtual void clear();
@ -65,6 +83,20 @@ public:
std::map<std::string, uint32_t> msgUpdateTS;
};
class RsGxsServerMsgUpdateItem : public RsItem
{
public:
RsGxsServerMsgUpdateItem(uint16_t servType) : RsItem(RS_PKT_VERSION_SERVICE,
servType, RS_PKT_SUBTYPE_GXS_SERVER_MSG_UPDATE)
{}
virtual ~RsGxsServerMsgUpdateItem();
virtual void clear();
virtual std::ostream &print(std::ostream &out, uint16_t indent);
std::string grpId;
uint32_t msgUpdateTS; // the last time this group received a new msg
};
class RsGxsUpdateSerialiser : public RsSerialType
@ -89,12 +121,24 @@ private:
virtual bool serialiseGxsGrpUpdate(RsGxsGrpUpdateItem *item, void *data, uint32_t *size);
virtual RsGxsGrpUpdateItem* deserialGxsGrpUpddate(void *data, uint32_t *size);
/* for RS_PKT_SUBTYPE_GXS_ */
/* for RS_PKT_SUBTYPE_GRP_SERVER_UPDATE_ITEM */
virtual uint32_t sizeGxsServerGrpUpdate(RsGxsServerGrpUpdateItem* item);
virtual bool serialiseGxsServerGrpUpdate(RsGxsServerGrpUpdateItem *item, void *data, uint32_t *size);
virtual RsGxsServerGrpUpdateItem* deserialGxsServerGrpUpddate(void *data, uint32_t *size);
/* for RS_PKT_SUBTYPE_GXS_MSG_UPDATE_ITEM */
virtual uint32_t sizeGxsMsgUpdate(RsGxsMsgUpdateItem* item);
virtual bool serialiseGxsMsgUpdate(RsGxsMsgUpdateItem *item, void *data, uint32_t *size);
virtual RsGxsMsgUpdateItem* deserialGxsMsgUpdate(void *data, uint32_t *size);
/* for RS_PKT_SUBTYPE_GXS_SERVER_UPDATE_ITEM */
virtual uint32_t sizeGxsServerMsgUpdate(RsGxsServerMsgUpdateItem* item);
virtual bool serialiseGxsServerMsgUpdate(RsGxsServerMsgUpdateItem *item, void *data, uint32_t *size);
virtual RsGxsServerMsgUpdateItem* deserialGxsServerMsgUpdate(void *data, uint32_t *size);
private:
const uint16_t SERVICE_TYPE;

View file

@ -354,8 +354,9 @@ bool RsNxsSerialiser::serialiseNxsSyncGrp(RsNxsSyncGrp *item, void *data, uint32
ok &= setRawUInt32(data, *size, &offset, item->transactionNumber);
ok &= setRawUInt8(data, *size, &offset, item->flag);
ok &= setRawUInt32(data, *size, &offset, item->syncAge);
ok &= setRawUInt32(data, *size, &offset, item->createdSince);
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_HASH_SHA1, item->syncHash);
ok &= setRawUInt32(data, *size, &offset, item->updateTS);
if(offset != tlvsize){
#ifdef RSSERIAL_DEBUG
@ -403,7 +404,7 @@ bool RsNxsSerialiser::serialiseNxsTrans(RsNxsTransac *item, void *data, uint32_t
ok &= setRawUInt32(data, *size, &offset, item->transactionNumber);
ok &= setRawUInt16(data, *size, &offset, item->transactFlag);
ok &= setRawUInt32(data, *size, &offset, item->nItems);
ok &= setRawUInt32(data, *size, &offset, item->timestamp);
ok &= setRawUInt32(data, *size, &offset, item->updateTS);
@ -501,7 +502,7 @@ bool RsNxsSerialiser::serialiseNxsSyncMsg(RsNxsSyncMsg *item, void *data, uint32
ok &= setRawUInt32(data, *size, &offset, item->transactionNumber);
ok &= setRawUInt8(data, *size, &offset, item->flag);
ok &= setRawUInt32(data, *size, &offset, item->syncAge);
ok &= setRawUInt32(data, *size, &offset, item->createdSince);
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_HASH_SHA1, item->syncHash);
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
@ -710,8 +711,9 @@ RsNxsSyncGrp* RsNxsSerialiser::deserialNxsSyncGrp(void *data, uint32_t *size){
ok &= getRawUInt32(data, *size, &offset, &(item->transactionNumber));
ok &= getRawUInt8(data, *size, &offset, &(item->flag));
ok &= getRawUInt32(data, *size, &offset, &(item->syncAge));
ok &= getRawUInt32(data, *size, &offset, &(item->createdSince));
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_HASH_SHA1, item->syncHash);
ok &= getRawUInt32(data, *size, &offset, &(item->updateTS));
if (offset != rssize)
{
@ -846,7 +848,7 @@ RsNxsTransac* RsNxsSerialiser::deserialNxsTrans(void *data, uint32_t *size){
ok &= getRawUInt32(data, *size, &offset, &(item->transactionNumber));
ok &= getRawUInt16(data, *size, &offset, &(item->transactFlag));
ok &= getRawUInt32(data, *size, &offset, &(item->nItems));
ok &= getRawUInt32(data, *size, &offset, &(item->timestamp));
ok &= getRawUInt32(data, *size, &offset, &(item->updateTS));
if (offset != rssize)
{
@ -984,9 +986,10 @@ RsNxsSyncMsg* RsNxsSerialiser::deserialNxsSyncMsg(void *data, uint32_t *size)
ok &= getRawUInt32(data, *size, &offset, &(item->transactionNumber));
ok &= getRawUInt8(data, *size, &offset, &(item->flag));
ok &= getRawUInt32(data, *size, &offset, &(item->syncAge));
ok &= getRawUInt32(data, *size, &offset, &(item->createdSince));
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_HASH_SHA1, item->syncHash);
ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
ok &= getRawUInt32(data, *size, &offset, &(item->updateTS));
if (offset != rssize)
{
@ -1057,6 +1060,7 @@ uint32_t RsNxsSerialiser::sizeNxsSyncGrp(RsNxsSyncGrp *item)
s += 1; // flag
s += 4; // sync age
s += GetTlvStringSize(item->syncHash);
s += 4; // updateTS
return s;
}
@ -1086,6 +1090,7 @@ uint32_t RsNxsSerialiser::sizeNxsSyncMsg(RsNxsSyncMsg *item)
s += 4; // age
s += GetTlvStringSize(item->grpId);
s += GetTlvStringSize(item->syncHash);
s += 4; // updateTS
return s;
}
@ -1111,7 +1116,7 @@ uint32_t RsNxsSerialiser::sizeNxsTrans(RsNxsTransac *item){
s += 4; // transaction number
s += 2; // flag
s += 4; // nMsgs
s += 4; // timeout
s += 4; // updateTS
return s;
}
@ -1141,16 +1146,18 @@ void RsNxsGrp::clear()
void RsNxsSyncGrp::clear()
{
flag = 0;
syncAge = 0;
createdSince = 0;
syncHash.clear();
updateTS = 0;
}
void RsNxsSyncMsg::clear()
{
grpId.clear();
flag = 0;
syncAge = 0;
createdSince = 0;
syncHash.clear();
updateTS = 0;
}
void RsNxsSyncGrpItem::clear()
@ -1172,6 +1179,7 @@ void RsNxsSyncMsgItem::clear()
void RsNxsTransac::clear(){
transactFlag = 0;
nItems = 0;
updateTS = 0;
timestamp = 0;
transactionNumber = 0;
}
@ -1185,10 +1193,11 @@ std::ostream& RsNxsSyncGrp::print(std::ostream &out, uint16_t indent)
printIndent(out , int_Indent);
out << "Hash: " << syncHash << std::endl;
printIndent(out , int_Indent);
out << "Sync Age: " << syncAge << std::endl;
out << "Sync Age: " << createdSince << std::endl;
printIndent(out , int_Indent);
out << "flag" << flag << std::endl;
printIndent(out , int_Indent);
out << "updateTS" << updateTS << std::endl;
printRsItemEnd(out ,"RsNxsSyncGrp", indent);
@ -1217,11 +1226,13 @@ std::ostream& RsNxsSyncMsg::print(std::ostream &out, uint16_t indent)
printIndent(out , int_Indent);
out << "GrpId: " << grpId << std::endl;
printIndent(out , int_Indent);
out << "syncAge: " << syncAge << std::endl;
out << "createdSince: " << createdSince << std::endl;
printIndent(out , int_Indent);
out << "syncHash: " << syncHash << std::endl;
printIndent(out , int_Indent);
out << "flag: " << flag << std::endl;
printIndent(out , int_Indent);
out << "updateTS: " << updateTS << std::endl;
printRsItemEnd(out, "RsNxsSyncMsg", indent);
return out;
@ -1316,6 +1327,8 @@ std::ostream& RsNxsTransac::print(std::ostream &out, uint16_t indent){
printIndent(out , int_Indent);
out << "timeout: " << timestamp << std::endl;
printIndent(out , int_Indent);
out << "updateTS: " << updateTS << std::endl;
printIndent(out , int_Indent);
out << "transactionNumber: " << transactionNumber << std::endl;
printIndent(out , int_Indent);

View file

@ -100,7 +100,8 @@ public:
virtual std::ostream &print(std::ostream &out, uint16_t indent);
uint8_t flag; // advises whether to use sync hash
uint32_t syncAge; // how far back to sync data
uint32_t createdSince; // how far back to sync data
uint32_t updateTS; // time of last group update
std::string syncHash; // use to determine if changes that have occured since last hash
@ -146,6 +147,9 @@ public:
uint16_t transactFlag;
uint32_t nItems;
uint32_t updateTS;
// not serialised
uint32_t timestamp;
};
@ -235,7 +239,8 @@ public:
std::string grpId;
uint8_t flag;
uint32_t syncAge;
uint32_t createdSince;
uint32_t updateTS; // time of last update
std::string syncHash;
};