diff --git a/icon-sdk-cpp b/icon-sdk-cpp index 267474b..77496d4 160000 --- a/icon-sdk-cpp +++ b/icon-sdk-cpp @@ -1 +1 @@ -Subproject commit 267474bcc13880e87fe26aebe45f2724eae434e9 +Subproject commit 77496d49c17f77126306cd737ab065b3aed82ad6 diff --git a/src/aegis/application.h b/src/aegis/application.h index e9e6e67..2266057 100644 --- a/src/aegis/application.h +++ b/src/aegis/application.h @@ -5,7 +5,7 @@ #include "sdk/sdk.h" #include "blockdownloader.h" -#define APP_VERSION "1.2" +#define APP_VERSION "1.3" namespace ICONation::Aegis { diff --git a/src/aegis/blockdownloader.cpp b/src/aegis/blockdownloader.cpp index 0eae3fa..46f7d6c 100644 --- a/src/aegis/blockdownloader.cpp +++ b/src/aegis/blockdownloader.cpp @@ -75,7 +75,7 @@ void Client::download(Block::Height current, Block::Height target) } catch (std::exception &e) { - Common::Dbg::error("Application exception :"); + Common::Dbg::error("Downloader exception :"); Common::Dbg::error(" - Type : {}", typeid(e).name()); Common::Dbg::error(" - Reason : {}", e.what()); Common::Dbg::warn("Retrying to download block {} ...", current); @@ -103,7 +103,7 @@ void Client::download(Block::Height current, Block::Height target) } catch (std::exception &e) { - Common::Dbg::error("Application exception :"); + Common::Dbg::error("Downloader exception :"); Common::Dbg::error(" - Type : {}", typeid(e).name()); Common::Dbg::error(" - Reason : {}", e.what()); Common::Dbg::warn("Retrying to insert block in cache {} ...", lastBlockDownloaded); diff --git a/src/db/db.cpp b/src/db/db.cpp index 7f95621..e8e7052 100644 --- a/src/db/db.cpp +++ b/src/db/db.cpp @@ -13,10 +13,6 @@ Db::Db(const std::string &host, const int port, const std::string &user, const s m_sql = std::make_unique(host, port, user, password, schema); } -static void reset_table(std::unique_ptr &sql, const std::string &table) -{ -} - void Db::disable_foreign_checks(void) { m_sql->session()->sql("SET FOREIGN_KEY_CHECKS=0;").execute(); diff --git a/tests/set_fake_block_height.sh b/tests/set_fake_block_height.sh new file mode 100644 index 0000000..eb367f6 --- /dev/null +++ b/tests/set_fake_block_height.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +function mysql { + /mnt/c/Program\ Files/MySQL/MySQL\ Server\ 8.0/bin/mysql.exe -u icon -picon < <(echo "use iconation; SET FOREIGN_KEY_CHECKS=0;" ; echo "${1};"; echo "SET FOREIGN_KEY_CHECKS=1;") +} + +function disable_foreign_checks { + mysql "SET FOREIGN_KEY_CHECKS=0" +} + +function enable_foreign_checks { + mysql "SET FOREIGN_KEY_CHECKS=1" +} + +function get_block { + tbears blockbyheight ${1} -u https://ctz.solidwallet.io/api/v3 | sed "s/block info : //g" +} + +function get_block_hash { + echo ${1} | jq '.result.block_hash' +} + +function get_prev_block_hash { + echo ${1} | jq '.result.prev_block_hash' +} + +function get_time_stamp { + echo ${1} | jq '.result.time_stamp' +} + +function get_height { + echo ${1} | jq '.result.height' +} + +block=$(get_block ${1}) +hash=$(get_block_hash "$block") +prev_hash=$(get_prev_block_hash "$block") +timestamp=$(get_time_stamp "$block") +height=$(get_height "$block") + +mysql "INSERT INTO block (previous_block, hash, timestamp, height) VALUES (${prev_hash}, ${hash}, '${timestamp}', '${height}')"