mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-07 20:25:49 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b277c353a8 |
@@ -30,10 +30,8 @@ DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes)
|
|||||||
/* Data format:
|
/* Data format:
|
||||||
|
|
||||||
Bytes
|
Bytes
|
||||||
|
0 uint8 One of NodeObjectType
|
||||||
0...7 Unused
|
1...end The body of the object data
|
||||||
8 char One of NodeObjectType
|
|
||||||
9...end The body of the object data
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
m_success = false;
|
m_success = false;
|
||||||
@@ -41,19 +39,17 @@ DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes)
|
|||||||
// VFALCO NOTE Ledger indexes should have started at 1
|
// VFALCO NOTE Ledger indexes should have started at 1
|
||||||
m_objectType = hotUNKNOWN;
|
m_objectType = hotUNKNOWN;
|
||||||
m_objectData = nullptr;
|
m_objectData = nullptr;
|
||||||
m_dataBytes = std::max(0, valueBytes - 9);
|
m_dataBytes = std::max(0, valueBytes - 1);
|
||||||
|
|
||||||
// VFALCO NOTE What about bytes 4 through 7 inclusive?
|
if (valueBytes != 0)
|
||||||
|
|
||||||
if (valueBytes > 8)
|
|
||||||
{
|
{
|
||||||
unsigned char const* byte = static_cast<unsigned char const*>(value);
|
unsigned char const* byte = static_cast<unsigned char const*>(value);
|
||||||
m_objectType = safe_cast<NodeObjectType>(byte[8]);
|
m_objectType = safe_cast<NodeObjectType>(byte[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valueBytes > 9)
|
if (valueBytes > 1)
|
||||||
{
|
{
|
||||||
m_objectData = static_cast<unsigned char const*>(value) + 9;
|
m_objectData = static_cast<unsigned char const*>(value) + 1;
|
||||||
|
|
||||||
switch (m_objectType)
|
switch (m_objectType)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,14 +28,11 @@ EncodedBlob::prepare(std::shared_ptr<NodeObject> const& object)
|
|||||||
{
|
{
|
||||||
m_key = object->getHash().begin();
|
m_key = object->getHash().begin();
|
||||||
|
|
||||||
auto ret = m_data.alloc(object->getData().size() + 9);
|
auto ret = m_data.alloc(object->getData().size() + 1);
|
||||||
|
|
||||||
// the first 8 bytes are unused
|
ret[0] = static_cast<std::uint8_t>(object->getType());
|
||||||
std::memset(ret, 0, 8);
|
|
||||||
|
|
||||||
ret[8] = static_cast<std::uint8_t>(object->getType());
|
std::memcpy(ret + 1, object->getData().data(), object->getData().size());
|
||||||
|
|
||||||
std::memcpy(ret + 9, object->getData().data(), object->getData().size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace NodeStore
|
} // namespace NodeStore
|
||||||
|
|||||||
Reference in New Issue
Block a user