New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UTXO merging #1937
UTXO merging #1937
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/****************************************************************************** | ||
* Copyright © 2013-2022 The Komodo Platform Developers. * | ||
* * | ||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * | ||
* the top-level directory of this distribution for the individual copyright * | ||
* holder information and the developer policies on copyright and licensing. * | ||
* * | ||
* Unless otherwise agreed in a custom licensing agreement, no part of the * | ||
* Komodo Platform software, including this file may be copied, modified, * | ||
* propagated or distributed except according to the terms contained in the * | ||
* LICENSE file * | ||
* * | ||
* Removal or modification of this copyright notice is prohibited. * | ||
* * | ||
******************************************************************************/ | ||
|
||
//! Dependencies Headers | ||
#include <nlohmann/json.hpp> | ||
|
||
//! Project Headers | ||
#include "utxo.merge.params.hpp" | ||
|
||
namespace mm2::api | ||
{ | ||
void | ||
to_json(nlohmann::json& j, const utxo_merge_params& cfg) | ||
{ | ||
j["merge_at"] = cfg.merge_at; | ||
j["check_every"] = cfg.check_every; | ||
j["max_merge_at_once"] = cfg.max_merge_at_once; | ||
} | ||
} // namespace mm2::api |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/****************************************************************************** | ||
* Copyright © 2013-2022 The Komodo Platform Developers. * | ||
* * | ||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * | ||
* the top-level directory of this distribution for the individual copyright * | ||
* holder information and the developer policies on copyright and licensing. * | ||
* * | ||
* Unless otherwise agreed in a custom licensing agreement, no part of the * | ||
* Komodo Platform software, including this file may be copied, modified, * | ||
* propagated or distributed except according to the terms contained in the * | ||
* LICENSE file * | ||
* * | ||
* Removal or modification of this copyright notice is prohibited. * | ||
* * | ||
******************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <nlohmann/json_fwd.hpp> | ||
|
||
namespace mm2::api | ||
{ | ||
struct utxo_merge_params | ||
{ | ||
std::size_t merge_at; | ||
std::size_t check_every; | ||
std::size_t max_merge_at_once; | ||
}; | ||
|
||
void to_json(nlohmann::json& j, const utxo_merge_params& cfg); | ||
} | ||
|
||
namespace atomic_dex | ||
{ | ||
using t_utxo_merge_params = ::mm2::api::utxo_merge_params; | ||
} // namespace atomic_dex |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -641,8 +641,17 @@ namespace atomic_dex | |
request.address_format = nlohmann::json::object(); | ||
request.address_format.value()["format"] = "segwit"; | ||
} | ||
|
||
if (coin_info.utxo_merge.value_or(false)) | ||
{ | ||
t_utxo_merge_params params{.merge_at = 300, .check_every = 60, .max_merge_at_once = 200}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we would have to test if it works with max_merge_at_once=200, i can imagine it would cause issues with some electrums, so maybe it's better to set max_merge_at_once to 100 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I"m happy to tweak the default params - just used those to drop around 3500 RICK utxos into 130 or so relatively quickly. There is a user with 23000 utxos from mining tokel, which will take a while to consolidate either way. From memory, up to 800 or so utxos can be merged in a tx. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, sounds like it will work... there is a difference though, RICK (and all other coins run by me) electrums have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated to use these values: |
||
nlohmann::json j; | ||
mm2::api::to_json(j, params); | ||
request.merge_params = j; | ||
} | ||
nlohmann::json j = ::mm2::api::template_request("electrum"); | ||
::mm2::api::to_json(j, request); | ||
// SPDLOG_INFO("electrum request: {}", j.dump(4)); | ||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
||
batch_array.push_back(j); | ||
} | ||
else | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/****************************************************************************** | ||
* Copyright © 2013-2022 The Komodo Platform Developers. * | ||
* * | ||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * | ||
* the top-level directory of this distribution for the individual copyright * | ||
* holder information and the developer policies on copyright and licensing. * | ||
* * | ||
* Unless otherwise agreed in a custom licensing agreement, no part of the * | ||
* Komodo Platform software, including this file may be copied, modified, * | ||
* propagated or distributed except according to the terms contained in the * | ||
* LICENSE file * | ||
* * | ||
* Removal or modification of this copyright notice is prohibited. * | ||
* * | ||
******************************************************************************/ | ||
|
||
//! Deps | ||
#include "doctest/doctest.h" | ||
#include <nlohmann/json.hpp> | ||
|
||
#include "atomicdex/api/mm2/utxo.merge.params.hpp" | ||
|
||
TEST_CASE("mm2::api::utxo_merge_params serialisation") | ||
{ | ||
const nlohmann::json expected_json = R"( | ||
{ | ||
"merge_at":50, | ||
"check_every":10, | ||
"max_merge_at_once":25 | ||
} | ||
)"_json; | ||
mm2::api::utxo_merge_params request{.merge_at = 50, .check_every = 10, .max_merge_at_once = 25}; | ||
nlohmann::json j; | ||
mm2::api::to_json(j, request); | ||
CHECK_EQ(j, expected_json); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allman style indentation