commenced removal of pricing_record touchpoints for MVP release
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2014-2022, The Monero Project
|
||||
// Portions Copyright (c) 2023, Fulmo (author: SRCG)
|
||||
// Portions Copyright (c) 2023, Salvium (author: SRCG)
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
@@ -365,29 +365,29 @@ uint64_t BlockchainDB::add_block( const std::pair<block, blobdata>& blck
|
||||
}
|
||||
|
||||
// SRCG: This is the code that calculates the total slippage for the block
|
||||
// Now convert all of the residual balances into FULM
|
||||
// Now convert all of the residual balances into SAL
|
||||
boost::multiprecision::int128_t slippage_total_128 = 0;
|
||||
uint64_t slippage_total = 0;
|
||||
for (const auto& tally: slippage_counts) {
|
||||
boost::multiprecision::int128_t slippage_amount_128 = 0;
|
||||
if (tally.first == "FULM") {
|
||||
if (tally.first == "SAL") {
|
||||
slippage_amount_128 = tally.second;
|
||||
} else {
|
||||
// Sanity check - do we have a price for both source asset type and FULM in the PR?
|
||||
boost::multiprecision::int128_t fulm_price = blk.pricing_record["FULM"];
|
||||
// Sanity check - do we have a price for both source asset type and SAL in the PR?
|
||||
boost::multiprecision::int128_t sal_price = blk.pricing_record["SAL"];
|
||||
boost::multiprecision::int128_t asset_price = blk.pricing_record[tally.first];
|
||||
if (fulm_price == 0) {
|
||||
if (sal_price == 0) {
|
||||
// No price available - bail out, because block is invalid
|
||||
throw std::runtime_error("Asset type 'FULM' is not present in available pricing record");
|
||||
throw std::runtime_error("Asset type 'SAL' is not present in available pricing record");
|
||||
}
|
||||
if (asset_price == 0) {
|
||||
// No price available - bail out, because block is invalid
|
||||
throw std::runtime_error("Asset type '" + tally.first + "' is not present in available pricing record");
|
||||
}
|
||||
// Convert the FUSD amount into FULM
|
||||
// Convert the VSD amount into SAL
|
||||
boost::multiprecision::int128_t tally_128 = tally.second;
|
||||
tally_128 *= asset_price;
|
||||
tally_128 /= fulm_price;
|
||||
tally_128 /= sal_price;
|
||||
slippage_amount_128 = tally_128.convert_to<int64_t>();
|
||||
}
|
||||
slippage_total_128 += slippage_amount_128;
|
||||
|
||||
@@ -424,8 +424,8 @@ private:
|
||||
* @param cumulative_difficulty the accumulated difficulty after this block
|
||||
* @param coins_generated the number of coins generated total after this block
|
||||
* @param blk_hash the hash of the block
|
||||
* @param slippage_total the total value (expressed in FULM coins) of all slippage for this block
|
||||
* @param yield_total the total of FULM coins that have been locked for yield in this block
|
||||
* @param slippage_total the total value (expressed in SAL coins) of all slippage for this block
|
||||
* @param yield_total the total of SAL coins that have been locked for yield in this block
|
||||
*/
|
||||
virtual void add_block( const block& blk,
|
||||
size_t block_weight,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2014-2023, The Monero Project
|
||||
// Portions Copyright (c) 2023, Fulmo (author: SRCG)
|
||||
// Portions Copyright (c) 2023, Salvium (author: SRCG)
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
@@ -1188,10 +1188,10 @@ uint64_t BlockchainLMDB::add_transaction_data(const crypto::hash& blk_hash, cons
|
||||
boost::multiprecision::int128_t final_source_tally = source_tally - tx.amount_burnt;
|
||||
boost::multiprecision::int128_t coinbase = get_block_already_generated_coins(m_height-1);
|
||||
if (source_tally == 0 && result == MDB_NOTFOUND) {
|
||||
if (tx.source_asset_type == "FULM") {
|
||||
if (tx.source_asset_type == "SAL") {
|
||||
final_source_tally += coinbase;
|
||||
} else {
|
||||
throw0(DB_ERROR("burn underflow - asset balance is zero for non-FULM asset"));
|
||||
throw0(DB_ERROR("burn underflow - asset balance is zero for non-SAL asset"));
|
||||
}
|
||||
}
|
||||
write_circulating_supply_data(m_cur_circ_supply_tally, source_idx, final_source_tally);
|
||||
@@ -1222,7 +1222,7 @@ uint64_t BlockchainLMDB::add_transaction_data(const crypto::hash& blk_hash, cons
|
||||
boost::multiprecision::int128_t final_source_tally = source_tally + asset.second;
|
||||
boost::multiprecision::int128_t coinbase = get_block_already_generated_coins(m_height-1);
|
||||
if (source_tally == 0 && result == MDB_NOTFOUND) {
|
||||
if (tx.source_asset_type == "FULM") {
|
||||
if (tx.source_asset_type == "SAL") {
|
||||
final_source_tally += coinbase;
|
||||
}
|
||||
}
|
||||
@@ -1943,7 +1943,7 @@ void BlockchainLMDB::open(const std::string& filename, const int db_flags)
|
||||
mdb_env_close(m_env);
|
||||
m_open = false;
|
||||
MFATAL("Existing lmdb database needs to be converted, which cannot be done on a read-only database.");
|
||||
MFATAL("Please run fulmod once to convert the database.");
|
||||
MFATAL("Please run salviumd once to convert the database.");
|
||||
return;
|
||||
}
|
||||
// Note that there was a schema change within version 0 as well.
|
||||
@@ -3394,7 +3394,7 @@ std::map<std::string,uint64_t> BlockchainLMDB::get_circulating_supply() const
|
||||
}
|
||||
|
||||
uint64_t m_coinbase = get_block_already_generated_coins(m_height-1);
|
||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__ << " - mined supply for FULM = " << m_coinbase);
|
||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__ << " - mined supply for SAL = " << m_coinbase);
|
||||
check_open();
|
||||
|
||||
TXN_PREFIX_RDONLY();
|
||||
@@ -3420,9 +3420,9 @@ std::map<std::string,uint64_t> BlockchainLMDB::get_circulating_supply() const
|
||||
const std::string currency_label = cryptonote::asset_type_from_id(currency_type);
|
||||
boost::multiprecision::int128_t amount = import_tally_from_cst(cst);
|
||||
|
||||
// Check for FULM - we need to adjust the total for them
|
||||
// Check for SAL - we need to adjust the total for them
|
||||
if (currency_type == 0) {
|
||||
// Get the current circulating supply for FULM
|
||||
// Get the current circulating supply for SAL
|
||||
amount += m_coinbase;
|
||||
}
|
||||
|
||||
@@ -3433,7 +3433,7 @@ std::map<std::string,uint64_t> BlockchainLMDB::get_circulating_supply() const
|
||||
|
||||
// NEAC: check for empty supply tally - only happens prior to first conversion on chain
|
||||
if (circulating_supply.empty()) {
|
||||
circulating_supply["FULM"] = m_coinbase;
|
||||
circulating_supply["SAL"] = m_coinbase;
|
||||
}
|
||||
return circulating_supply;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user