Support STN_ARF_UNKNOWN for contexts where the format of a node is not known. Format

is auto-detected.
This commit is contained in:
JoelKatz
2012-06-29 23:19:29 -07:00
parent 0b133749ae
commit 6a9b5ccd7d
2 changed files with 12 additions and 3 deletions

View File

@@ -157,11 +157,12 @@ public:
SHAMapTreeNode(const SHAMapTreeNode& node, uint32 seq); // copy node from older tree
SHAMapTreeNode(const SHAMapNode& nodeID, SHAMapItem::pointer item, TNType type, uint32 seq);
// raw node functions
SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned char>& contents, uint32 seq, int format);
#define STN_ARF_UNKNOWN 0
#define STN_ARF_PREFIXED 1
#define STN_ARF_WIRE 2
// raw node functions
SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned char>& contents, uint32 seq, int format);
void addRaw(Serializer &, int format);
virtual bool isPopulated() const { return true; }

View File

@@ -192,6 +192,14 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& node, SHAMapItem::pointer item,
SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned char>& rawNode, uint32 seq, int format)
: SHAMapNode(id), mSeq(seq), mType(tnERROR), mFullBelow(false)
{
if (format == STN_ARF_UNKNOWN)
{
if ((rawNode.size() < 4) || (rawNode[0] < 10))
format = STN_ARF_WIRE;
else
format = STN_ARF_PREFIXED;
}
if (format == STN_ARF_WIRE)
{
Serializer s(rawNode);