mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Include hp version number on all required places. (#265)
* Adding HP version header to binary files and adding hp table to ledger.sqlite. * Updating hp_version in user challenge message. * Minor improvement.
This commit is contained in:
committed by
GitHub
parent
1eabe7db4a
commit
b45cdb999d
@@ -4,6 +4,8 @@ namespace ledger::sqlite
|
||||
{
|
||||
constexpr const char *LEDGER_TABLE = "ledger";
|
||||
constexpr const char *LEDGER_COLUMNS = "seq_no, time, ledger_hash, prev_ledger_hash, data_hash, state_hash, patch_hash, user_hash, input_hash, output_hash";
|
||||
constexpr const char *HP_VERSION_TABLE = "hp";
|
||||
constexpr const char *HP_VERSION_COLUMN = "hp_version";
|
||||
constexpr const char *COLUMN_DATA_TYPES[]{"INT", "TEXT"};
|
||||
constexpr const char *CREATE_TABLE = "CREATE TABLE IF NOT EXISTS ";
|
||||
constexpr const char *INSERT_INTO = "INSERT INTO ";
|
||||
@@ -233,6 +235,29 @@ namespace ledger::sqlite
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and update the hp table from the hp version when creating a new shard.
|
||||
* @param db Pointer to the db.
|
||||
* @param version Hp version.
|
||||
* @returns returns 0 on success, or -1 on error.
|
||||
*
|
||||
*/
|
||||
int create_hp_version_table_and_update(sqlite3 *db, std::string_view version)
|
||||
{
|
||||
|
||||
const std::vector<table_column_info> column_info{
|
||||
table_column_info(HP_VERSION_COLUMN, COLUMN_DATA_TYPE::TEXT)};
|
||||
|
||||
if (create_table(db, HP_VERSION_TABLE, column_info) == -1)
|
||||
return -1;
|
||||
|
||||
const std::string value_string = "\"" + std::string(version) + "\"";
|
||||
if (insert_value(db, HP_VERSION_TABLE, HP_VERSION_COLUMN, value_string) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a ledger record.
|
||||
* @param db Pointer to the db.
|
||||
|
||||
Reference in New Issue
Block a user