mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Updating hpfs log index on ledger creation (#274)
This commit is contained in:
@@ -15,6 +15,7 @@ namespace hpfs
|
||||
constexpr const char *RO_SESSION_HMAP = "/::hpfs.ro.hmap.";
|
||||
constexpr const char *HMAP_HASH = "::hpfs.hmap.hash";
|
||||
constexpr const char *HMAP_CHILDREN = "::hpfs.hmap.children";
|
||||
constexpr const char *INDEX_UPDATE = "/::hpfs.index";
|
||||
constexpr ino_t ROOT_INO = 1;
|
||||
|
||||
constexpr uint16_t PROCESS_INIT_TIMEOUT = 2000;
|
||||
@@ -391,4 +392,24 @@ namespace hpfs
|
||||
}
|
||||
}
|
||||
|
||||
int hpfs_mount::update_hpfs_log_index()
|
||||
{
|
||||
const std::string index_file = mount_dir + INDEX_UPDATE;
|
||||
|
||||
const int fd = open(index_file.c_str(), O_RDWR);
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
|
||||
// We just send empty buffer with write size 1 to invoke the hpfs index update.
|
||||
// Write syscall isn't invoking with write size 0.
|
||||
if (write(fd, "", 1) == -1)
|
||||
{
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace hpfs
|
||||
@@ -67,6 +67,7 @@ namespace hpfs
|
||||
const std::string physical_path(std::string_view session_name, std::string_view vpath);
|
||||
const util::h32 get_parent_hash(const std::string &parent_vpath);
|
||||
void set_parent_hash(const std::string &parent_vpath, const util::h32 new_state);
|
||||
int update_hpfs_log_index();
|
||||
};
|
||||
|
||||
} // namespace hpfs
|
||||
|
||||
@@ -159,6 +159,13 @@ namespace ledger
|
||||
// Update the last shard hash and shard seqence number tracker when a new ledger is created.
|
||||
ctx.set_last_primary_shard_id(p2p::sequence_hash{primary_shard_seq_no, last_primary_shard_hash});
|
||||
|
||||
// Update the hpfs log index file only in full history mode.
|
||||
if (conf::cfg.node.history == conf::HISTORY::FULL && sc::contract_fs.update_hpfs_log_index() == -1)
|
||||
{
|
||||
LOG_ERROR << errno << ": Error updating the log index file.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Remove old shards that exceeds max shard range.
|
||||
if (conf::cfg.node.history == conf::HISTORY::CUSTOM && primary_shard_seq_no >= conf::cfg.node.history_config.max_primary_shards)
|
||||
{
|
||||
|
||||
BIN
test/bin/hpfs
BIN
test/bin/hpfs
Binary file not shown.
Reference in New Issue
Block a user