Updated hpfs binary and its relevant hpcore changes. (#282)

* Hpfs index file is updated to match the file with the hpfs version.
* Added updated hpfs binary.
* Version log changes because Plog is not initialized at the time of version init.
This commit is contained in:
Savinda Senevirathne
2021-04-02 10:36:29 +05:30
committed by GitHub
parent 5833431157
commit 137d7633e0
4 changed files with 9 additions and 4 deletions

View File

@@ -5,6 +5,7 @@
#include "../util/h32.hpp"
#include "../sc/sc.hpp"
#include "../crypto.hpp"
#include "../util/version.hpp"
namespace hpfs
{
@@ -523,7 +524,7 @@ namespace hpfs
return -1;
}
close(fd);
seq_no = st.st_size / (sizeof(uint64_t) + sizeof(util::h32));
seq_no = (st.st_size - version::HPFS_VERSION_BYTES_LEN) / (sizeof(uint64_t) + sizeof(util::h32));
return 0;
}
@@ -551,7 +552,7 @@ namespace hpfs
return -1;
}
const off_t offset = ((seq_no - 1) * (sizeof(uint64_t) + sizeof(util::h32))) + sizeof(uint64_t);
const off_t offset = version::HPFS_VERSION_BYTES_LEN + ((seq_no - 1) * (sizeof(uint64_t) + sizeof(util::h32))) + sizeof(uint64_t);
// If calculated offset is beyond our file size means,
// Requested seq_no is invalid or we do not have that seq_no in our hpfs log file.
if (offset >= st.st_size)

View File

@@ -34,7 +34,7 @@ namespace version
if (end == std::string::npos)
{
LOG_ERROR << "Invalid version " << version;
std::cerr << "Invalid version " << version << std::endl;
return -1;
}
@@ -45,7 +45,7 @@ namespace version
if (end == std::string::npos)
{
LOG_ERROR << "Invalid version " << version;
std::cerr << "Invalid version " << version << std::endl;
return -1;
}

View File

@@ -18,6 +18,10 @@ namespace version
// 2 bytes each for 3 version components. 2 bytes reserved.
constexpr const size_t VERSION_BYTES_LEN = 8;
// Hpfs version header length. This is currently same length as hpcore version header.
// This value needs to be updated when hpfs version header length changes.
constexpr const size_t HPFS_VERSION_BYTES_LEN = 8;
// Binary representations of the versions. (populated during version init)
extern uint8_t HP_VERSION_BYTES[VERSION_BYTES_LEN];
extern uint8_t LEDGER_VERSION_BYTES[VERSION_BYTES_LEN];

Binary file not shown.