inital version of touch amendment

This commit is contained in:
Richard Holland
2024-03-15 03:02:02 +00:00
parent d24c134612
commit 247c17215c
6 changed files with 33 additions and 1 deletions

View File

@@ -1079,6 +1079,31 @@ Transactor::checkMultiSign(PreclaimContext const& ctx)
//------------------------------------------------------------------------------
// increment the touch counter on an account
static void
touchAccount(
ApplyView& view,
AccountID const& id,
std::optional<std::shared_ptr<SLE>> sle)
{
if (!view.rules().enabled(featureTouch))
return;
if (!sle)
*sle = view.peek(keylet::account(id));
if (!(*sle))
return;
uint64_t tc = (*sle)->isFieldPresent(sfTouchCount)
? (*sle)->getFieldU64(sfTouchCount)
: 0;
(*sle)->setFieldU64(sfTouchCount, tc + 1);
view.update(*sle);
}
static void
removeUnfundedOffers(
ApplyView& view,
@@ -1511,6 +1536,8 @@ Transactor::doTSH(
if ((!canRollback && strong) || (canRollback && !strong))
continue;
touchAccount(view, tshAccountID, {});
auto klTshHook = keylet::hook(tshAccountID);
auto tshHook = view.read(klTshHook);

View File

@@ -74,7 +74,7 @@ namespace detail {
// Feature.cpp. Because it's only used to reserve storage, and determine how
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
// the actual number of amendments. A LogicError on startup will verify this.
static constexpr std::size_t numFeatures = 68;
static constexpr std::size_t numFeatures = 69;
/** Amendments that this server supports and the default voting behavior.
Whether they are enabled depends on the Rules defined in the validated
@@ -356,6 +356,7 @@ extern uint256 const featureHooksUpdate1;
extern uint256 const fixXahauV1;
extern uint256 const fixXahauV2;
extern uint256 const featureRemit;
extern uint256 const featureTouch;
} // namespace ripple

View File

@@ -433,6 +433,7 @@ extern SF_UINT64 const sfReferenceCount;
extern SF_UINT64 const sfRewardAccumulator;
extern SF_UINT64 const sfAccountCount;
extern SF_UINT64 const sfAccountIndex;
extern SF_UINT64 const sfTouchCount;
// 128-bit
extern SF_UINT128 const sfEmailHash;

View File

@@ -462,6 +462,7 @@ REGISTER_FEATURE(HooksUpdate1, Supported::yes, VoteBehavior::De
REGISTER_FIX (fixXahauV1, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FIX (fixXahauV2, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FEATURE(Remit, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FEATURE(Touch, Supported::yes, VoteBehavior::DefaultNo);
// The following amendments are obsolete, but must remain supported
// because they could potentially get enabled.

View File

@@ -66,6 +66,7 @@ LedgerFormats::LedgerFormats()
{sfGovernanceFlags, soeOPTIONAL},
{sfGovernanceMarks, soeOPTIONAL},
{sfAccountIndex, soeOPTIONAL},
{sfTouchCount, soeOPTIONAL},
},
commonFields);

View File

@@ -183,6 +183,7 @@ CONSTRUCT_TYPED_SFIELD(sfEmitBurden, "EmitBurden", UINT64,
CONSTRUCT_TYPED_SFIELD(sfHookInstructionCount, "HookInstructionCount", UINT64, 17);
CONSTRUCT_TYPED_SFIELD(sfHookReturnCode, "HookReturnCode", UINT64, 18);
CONSTRUCT_TYPED_SFIELD(sfReferenceCount, "ReferenceCount", UINT64, 19);
CONSTRUCT_TYPED_SFIELD(sfTouchCount, "TouchCount", UINT64, 97);
CONSTRUCT_TYPED_SFIELD(sfAccountIndex, "AccountIndex", UINT64, 98);
CONSTRUCT_TYPED_SFIELD(sfAccountCount, "AccountCount", UINT64, 99);
CONSTRUCT_TYPED_SFIELD(sfRewardAccumulator, "RewardAccumulator", UINT64, 100);