mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-04 18:55:49 +00:00
Update reward.c hook (#111)
* fix include * fix include * update invariant * update comment * Update reward.c * Update reward.c * Update reward.c
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
#include "hookapi.h"
|
||||
#define DEFAULT_REWARD_DELAY 6199553087261802496ULL
|
||||
// 2600000
|
||||
#define DEFAULT_REWARD_RATE 6038156834009797973ULL
|
||||
//0.00333333333f
|
||||
// 0.00333333333f
|
||||
|
||||
#define L1SEATS 20U
|
||||
#define MAXUNL 128U
|
||||
@@ -88,10 +89,10 @@ uint8_t member_count_key[2] = {'M', 'C'};
|
||||
|
||||
uint8_t unlreport_keylet[34] =
|
||||
{
|
||||
0,0,0x61U,0xE3U,0x2EU,0x7AU,0x24U,0xA2U,0x38U,0xF1U,0xC6U,0x19U,
|
||||
0xD5U,0xF9U,0xDDU,0xCCU,0x41U,0xA9U,0x4BU,0x33U,0xB6U,0x6CU,
|
||||
0x01U,0x63U,0xF7U,0xEFU,0xCCU,0x8AU,0x19U,0xC9U,0xFDU,0x6FU,
|
||||
0x28U,0xDCU
|
||||
0x00U,0x52U,0x61U,0xE3U,0x2EU,0x7AU,0x24U,0xA2U,0x38U,
|
||||
0xF1U,0xC6U,0x19U,0xD5U,0xF9U,0xDDU,0xCCU,0x41U,0xA9U,
|
||||
0x4BU,0x33U,0xB6U,0x6CU,0x01U,0x63U,0xF7U,0xEFU,0xCCU,
|
||||
0x8AU,0x19U,0xC9U,0xFDU,0x6FU,0x28U,0xDCU
|
||||
};
|
||||
|
||||
uint8_t msg_buf[] = "You must wait 0000000 seconds";
|
||||
@@ -132,7 +133,7 @@ int64_t hook(uint32_t r)
|
||||
|
||||
if (required_delay < 0 || float_sign(xfl_rr) != 0 ||
|
||||
float_compare(xfl_rr, float_one(), COMPARE_GREATER) ||
|
||||
float_compare(xfl_rd, float_one(), COMPARE_GREATER))
|
||||
float_compare(xfl_rd, float_one(), COMPARE_LESS))
|
||||
rollback(SBUF("Reward: Rewards incorrectly configured by governance or unrecoverable error."), __LINE__);
|
||||
|
||||
// get the account root keylet
|
||||
@@ -229,16 +230,18 @@ int64_t hook(uint32_t r)
|
||||
|
||||
uint64_t l1_drops = reward_drops / L1SEATS;
|
||||
|
||||
int64_t otxn_slot_num = otxn_slot(10);
|
||||
ASSERT(otxn_slot_num == 10);
|
||||
|
||||
otxn_slot(1);
|
||||
slot_subfield(1, sfFee, 2);
|
||||
int64_t xfl_fee = slot_float(2);
|
||||
int64_t fee_slot_num = slot_subfield(10, sfFee, 11);
|
||||
ASSERT(fee_slot_num == 11);
|
||||
|
||||
int64_t xfl_fee = slot_float(11);
|
||||
|
||||
// user gets back the fee they spent running the hook
|
||||
if (xfl_fee > 0)
|
||||
reward_drops += float_int(xfl_fee, 6, 1);
|
||||
|
||||
|
||||
TEMPLATE_DROPS(reward_drops);
|
||||
|
||||
uint8_t* upto = txn_mint + 209U;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/app/ledger/LedgerMaster.h>
|
||||
#include <ripple/app/tx/impl/ClaimReward.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/core/Config.h>
|
||||
|
||||
@@ -217,7 +217,7 @@ XRPNotCreated::finalize(
|
||||
int64_t drops = dropsAdded.drops() - fee.drops();
|
||||
|
||||
// catch any overflow or funny business
|
||||
if (drops > dropsAdded.drops() || drops > fee.drops())
|
||||
if (drops > dropsAdded.drops())
|
||||
return false;
|
||||
|
||||
// We should never allow more than the max supply in totalCoins.
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace XahauGenesis
|
||||
// 1.003274 -xfl-> 6089869970204910592 -le-> 0x00E461EE78908354
|
||||
{{'I', 'R', 'R'}, {0x00U, 0xE4U, 0x61U, 0xEEU, 0x78U, 0x90U, 0x83U, 0x54U}},
|
||||
|
||||
// initial reward delay is xfl le -> 00806AACAF3C0956 -> 2600000 dec
|
||||
// 2600000 -xfl-> 6199553087261802496 -le-> 0x00806AACAF3C0956
|
||||
{{'I', 'R', 'D'}, {0x00U, 0x80U, 0x6AU, 0xACU, 0xAFU, 0x3CU, 0x09U, 0x56U}}
|
||||
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <ripple/basics/BasicConfig.h>
|
||||
#include <ripple/core/ConfigSections.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <test/jtx.h>
|
||||
#include <test/jtx/Env.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user