Compare commits

..

358 Commits

Author SHA1 Message Date
Vladislav Vysokikh
5490b6dc97 Add repro tests: ValidVault fee-sponsor false positive, SponsorshipTransfer tecINTERNAL 2026-07-06 11:20:41 +01:00
Mayukha Vadari
60702858a1 refactor: Move SponsorHelpers code to SponsorHelpers.cpp (#7713) 2026-07-03 21:00:42 -04:00
Mayukha Vadari
c7b10a3153 refactor: Rename checkInsufficientReserve to checkReserve (#7712) 2026-07-03 21:00:16 -04:00
Olek
cd5ce8dc50 Payment tx fee payer ID (#7682) 2026-07-02 22:08:37 -04:00
Peter Chen
12cf66259c Fix legacy SignerList sponsorship reserve mismatch (#7703) 2026-07-02 14:08:15 -07:00
yinyiqian1
ed65de1489 fix SponsorshipTransfer preflight (#7683) 2026-07-02 15:54:04 -04:00
yinyiqian1
11e6d65b30 support sponsor delegation integration (#7665) 2026-07-02 15:18:30 -04:00
Mayukha Vadari
cecea82835 refactor: Use ApplyViewContext everywhere instead of ApplyView+STTx (#7618) 2026-07-02 13:22:04 -04:00
Peter Chen
0240203060 fix STAmount (#7697) 2026-07-02 08:41:11 -07:00
Ayaz Salikhov
ad5bc87d1f Merge pull request #7700 from mathbunnyru/merge_develop_in_sponsor
chore: Merge develop to sponsor
2026-07-02 12:31:44 +01:00
Ayaz Salikhov
6c902777ee Add missing include 2026-07-02 11:48:43 +01:00
Ayaz Salikhov
bd42a05275 Merge branch 'develop' into xrplf/sponsor 2026-07-02 11:22:19 +01:00
Mayukha Vadari
1c9168b29f refactor: Adjustment struct (#7680) 2026-07-01 18:17:29 -04:00
Mayukha Vadari
76acc2c92b refactor: Move baseAccountReserve back to Fees.h (#7688) 2026-07-01 18:03:07 -04:00
Mayukha Vadari
61896fd53d Merge pull request #7694 from XRPLF/mvadari/sponsor/merge-01-01
merge from develop
2026-07-01 18:02:27 -04:00
Mayukha Vadari
cbf44b8436 fix clang-tidy 2026-07-01 17:28:03 -04:00
Mayukha Vadari
909f7ff102 fix forreal 2026-07-01 17:15:29 -04:00
Mayukha Vadari
b664847d59 one more fingers crossed 2026-07-01 17:10:08 -04:00
Mayukha Vadari
5c17e879f7 more fixes 2026-07-01 16:47:15 -04:00
Peter Chen
b590672929 Rename adjustOwnerCount and adjustOwnerCountObj (#7676) 2026-07-01 13:18:39 -07:00
Peter Chen
b4bac1db65 SponsorshipSet Cleanup (#7679) 2026-07-01 13:13:08 -07:00
Mayukha Vadari
dd489172c3 fix renames 2026-07-01 16:06:08 -04:00
Mayukha Vadari
da31106aa5 more fixes 2026-07-01 15:51:51 -04:00
Mayukha Vadari
d9c683d822 fix build 2026-07-01 15:47:47 -04:00
Mayukha Vadari
5b714a79c0 Merge branch 'develop' of https://github.com/XRPLF/rippled into xrplf/sponsor 2026-07-01 15:36:15 -04:00
Mayukha Vadari
7817245314 refactor: Switch checkInsufficientReserve from ReadView to ApplyView (#7667) 2026-07-01 13:18:20 -04:00
Mayukha Vadari
730e526080 fix: Better handling of txs that send XRP + charge reserve (#7671) 2026-07-01 11:37:45 -04:00
Kassaking7
4e6f8f334f fix: add missing tests to cover all scenario for sponsor reserve (#7574) 2026-06-30 17:24:33 -04:00
Mayukha Vadari
140d5ec297 fix: crash in reset (#7675) 2026-06-30 17:20:07 -04:00
yinyiqian1
efeedcdc60 fix: Disallow sponsored tx to be queued (#7674) 2026-06-30 14:21:10 -04:00
Mayukha Vadari
09b5cd9879 refactor: Move SponsorshipTransfer code around, add some comments (#7662) 2026-06-30 14:06:20 -04:00
Peter Chen
f9af579690 Sponsor edge cases (#7558) 2026-06-30 09:41:44 -07:00
Mayukha Vadari
5bb979b2e5 feat: Add checks to block reserve sponsorship on OOS txs (#7605) 2026-06-30 12:39:09 -04:00
Zhiyuan Wang
12cafc87db fix: some fixes on test logic, style and comments (#7668) 2026-06-29 18:59:19 -04:00
Olek
e42c7c8551 Revert back to simple and inconsistent reserve calculations. (#7633) 2026-06-29 16:50:30 -04:00
Mayukha Vadari
35e1a6ef25 refactor: Move reserve checks from preclaim to doApply where relevant (#7607) 2026-06-29 16:04:38 -04:00
Zhiyuan Wang
5029c08f12 fix: bunch of fixes on RPC (#7557) 2026-06-29 14:08:47 -04:00
Mayukha Vadari
132ced7d51 fix: 2 free token exception is not applicable for sponsor (#7644) 2026-06-29 11:43:51 -04:00
yinyiqian1
03d4e30378 Cut ticket scope (#7621) 2026-06-25 18:21:54 -04:00
Peter Chen
5eff397170 Remove AMM and Offer reserve from Sponsor (#7617) 2026-06-25 12:32:42 -07:00
Olek
86484cfa39 Remove sponsorship from vault and loan (#7628) 2026-06-25 14:36:46 -04:00
Mayukha Vadari
ac86cdada7 feat: remove XChainBridge from scope (#7615) 2026-06-25 13:25:09 -04:00
Peter Chen
c6889666c9 Remove Credential/oracle/PD/DID from sponsor (#7620) 2026-06-25 09:34:04 -07:00
yinyiqian1
9a7d1a114c Cut NFT out of scope (#7616) 2026-06-25 12:30:04 -04:00
Mayukha Vadari
6ecf413c64 refactor: Clean up spf flag usage (#7608)
Co-authored-by: xrplf-ai-reviewer[bot] <266832837+xrplf-ai-reviewer[bot]@users.noreply.github.com>
2026-06-24 10:25:15 -04:00
Mayukha Vadari
8c98b50de8 refactor: Simplify variable names (#7604) 2026-06-23 20:15:04 -04:00
Mayukha Vadari
2b727cd292 fix: Remove callback in getPageForToken (#7576) 2026-06-23 17:28:50 -04:00
Mayukha Vadari
05bb41056d refactor: rename STTx::getFeePayer to getInitiator (#7603) 2026-06-23 15:48:51 -04:00
yinyiqian1
51264617f3 Merge pull request #7599 from yinyiqian1/merge-develop-sponsor
Merge develop sponsor and apply permissions.macro
2026-06-23 12:42:17 -04:00
Mayukha Vadari
05d3614a19 nit: fix spacing (#7594) 2026-06-23 00:17:32 -04:00
yinyiqian1
494391b4ab replace sponsorshipSet checkPermission with macro 2026-06-22 20:58:57 -04:00
yinyiqian1
fba4ba6ebd Merge remote-tracking branch 'origin/develop' into merge-develop-sponsor 2026-06-22 20:00:11 -04:00
yinyiqian1
018e736a3b Fix sponsor reserve accounting edge cases (#7575) 2026-06-22 15:18:22 -04:00
Mayukha Vadari
4a3abc0407 fix: Assorted AI comments (#7569) 2026-06-22 15:16:14 -04:00
Mayukha Vadari
1eef7473d3 Revert "Sponsorship should be non-obligated for sponsee (#7552)" (#7577) 2026-06-22 14:42:53 -04:00
Mayukha Vadari
c3b3bce35d feat: Update to keylet::sponsorship and sfRemainingOwnerCount (#7578) 2026-06-22 11:07:59 -04:00
Mayukha Vadari
d1a77b453e Merge branch 'develop' of https://github.com/XRPLF/rippled into xrplf/sponsor 2026-06-17 17:50:49 -04:00
Mayukha Vadari
c2ab83c960 fix: Fix UBSan issue (#7554) 2026-06-17 17:50:17 -04:00
yinyiqian1
aac6be218a fix new CI rule switch fallthrough (#7568) 2026-06-17 17:39:12 -04:00
yinyiqian1
14986cc043 Sponsorship should be non-obligated for sponsee (#7552) 2026-06-17 14:08:06 -04:00
Oleksandr
4fc781ef93 Merge remote-tracking branch 'ripp/develop' into xrplf/sponsor 2026-06-15 18:37:38 -04:00
Oleksandr
e52113956e clang-tidy 2026-06-15 18:21:33 -04:00
Oleksandr
f650d52ada Merge remote-tracking branch 'ripple/develop' into xrplf/sponsor 2026-06-15 12:54:37 -04:00
Oleksandr
64159eb040 Revert clang-tidy 2026-06-03 22:40:10 -04:00
Oleksandr
942a950e93 Codegen update 2026-06-03 19:48:20 -04:00
Oleksandr
d70eca3d7d Merge remote-tracking branch 'ripple/develop' into xrplf/sponsor 2026-06-03 19:47:19 -04:00
Oleksandr
7e5ac6f8cb Merge remote-tracking branch 'ripple/develop' into xrplf/sponsor 2026-06-03 19:31:46 -04:00
Oleksandr
03fb6d1e0c Codegen update 2026-06-03 18:29:55 -04:00
Oleksandr
9ef1949309 Merge remote-tracking branch 'ripple/develop' into xrplf/sponsor 2026-05-28 15:19:29 -04:00
Oleksandr
595b612589 Merge fixes 2026-05-28 01:54:20 -04:00
Oleksandr
d561f0d84d Merge remote-tracking branch 'tequ/sponsor' into spns5 2026-05-26 17:06:36 -04:00
Oleksandr
3859fcad73 clang-tidy fixes 2026-05-26 17:06:36 -04:00
Oleksandr
8d905ac21b Merge remote-tracking branch 'ripp/develop' into spns5 2026-05-26 17:06:36 -04:00
Oleksandr
0997b92de3 Merge fixes 2026-05-26 17:04:16 -04:00
Oleksandr
9e5b7281cf Merge remote-tracking branch 'ripple/develop' into spns5 2026-05-26 17:00:29 -04:00
Oleksandr
0bfdfa73ff Merge fixes 2026-05-26 15:50:54 -04:00
Oleksandr
39e819927f Merge remote-tracking branch 'ripple/develop' into spns5 2026-05-26 15:49:42 -04:00
Oleksandr
08357b196f sponsor AccountID -> sponsorSle 2026-05-26 15:42:03 -04:00
tequ
bb4c443fe5 fix ReserveCount Inflation via Co-Signed + Pre-Funded Interaction
fix #6864
2026-05-26 15:39:50 -04:00
tequ
a669099f21 fix 2026-05-26 15:39:50 -04:00
tequ
7624c18c76 fix: XChainAddAccountCreateAttestation redirects relayer sponsorship to door-owned claim objects 2026-05-26 15:39:50 -04:00
tequ
ab7bbac8f9 Merge remote-tracking branch 'oleks-rip/dev_rename_merge' into sponsor 2026-05-26 15:39:49 -04:00
Oleksandr
960aaec91e merge fixes 2026-05-26 15:39:46 -04:00
Oleksandr
f042cd8e25 Merge remote-tracking branch 'ripple/develop' into dev_rename_merge 2026-05-26 15:37:34 -04:00
tequ
9d4c4968ad fix tidy error 2026-05-26 14:47:54 -04:00
Oleksandr
b76652bdf4 XRPL_ASSERT -> Throw 2026-05-26 14:47:54 -04:00
tequ
405b314842 fix clang-tidy error 2026-05-26 14:47:54 -04:00
tequ
77ebc2921e clang-format 2026-05-26 14:47:54 -04:00
tequ
c72fd59539 clang-tidy 2026-05-26 14:47:54 -04:00
tequ
6f4365557d Merge branch 'develop' into sponsor 2026-05-26 14:47:54 -04:00
Oleksandr
d792e03468 adjustOwnerCountObj, more checks, some fixes 2026-05-26 14:47:53 -04:00
Oleksandr
2b4ce0fc21 Merge fixes 2026-05-26 14:47:53 -04:00
Oleksandr
eb88c0ef6b Fix clang-format, some refactoring 2026-05-26 14:46:41 -04:00
tequ
50d5e2d996 Merge remote-tracking branch 'upstream/develop' into sponsor 2026-05-26 14:46:41 -04:00
tequ
bca6d8e515 fix not to payback ReserveCount 2026-05-26 14:46:41 -04:00
tequ
86c90c8e5c clang-tidy 2026-05-26 14:46:41 -04:00
tequ
0c683bfd66 levelization 2026-05-26 14:46:41 -04:00
tequ
33be9abbef clang-format 2026-05-26 14:46:41 -04:00
tequ
aa70d6051b Merge remote-tracking branch 'upstream/develop' into sponsor 2026-05-26 14:46:41 -04:00
tequ
d057f07d0e fix: setSponsorFieldU32 silently clamps to 0 on underflow instead of failing 2026-05-26 14:40:07 -04:00
tequ
688e568e39 fix: getLedgerEntryOwner missing ltLOAN_BROKER and ltLOAN prevents object sponsorship 2026-05-26 14:40:07 -04:00
tequ
3ad93af34d fix: Sponsor's MaxFee cap is bypassed in reset() path, allowing sponsee to drain entire pre-funded FeeAmount in a single tec-failing transaction 2026-05-26 14:40:07 -04:00
Oleksandr
c5941d6b14 Unify accountReserve, ownerCount, ownerReserve 2026-05-26 14:40:07 -04:00
Oleksandr
ee8d9ca73e More universal adjustSponsorOwnerCountHlp 2026-05-26 14:40:07 -04:00
Oleksandr
462a0b2338 Read/const_ref 2026-05-26 14:40:06 -04:00
Oleksandr
9b4ab67864 Fix delegable test 2026-05-26 14:40:06 -04:00
Oleksandr
84bffad2bf merge_fix 2026-05-26 14:40:06 -04:00
tequ
b153213e83 run pre-commit 2026-04-28 17:20:00 +09:00
tequ
c12eff6646 apply tidy diff 2026-04-28 17:09:57 +09:00
tequ
fbff1c065c levelization 2026-04-28 17:04:14 +09:00
tequ
e8deaa12d8 pre-commit run 2026-04-28 16:55:07 +09:00
tequ
6ee071c5b0 fix: An incorrect available XRP balance check in AMM deposit allows reserve-locked funds to be used as adding liquidity 2026-04-28 15:57:49 +09:00
tequ
381094498d Merge remote-tracking branch 'upstream/develop' into sponsor 2026-04-28 09:49:52 +09:00
tequ
c072b125a0 fix: No invariant verifying sfSponsor field on objects matches sponsoring/sponsored count deltas #6897 2026-04-21 18:59:36 +09:00
tequ
b2b2babe1e fix: PermissionedDomain invariant skips credential validation for SponsorshipTransfer #6902 2026-04-21 18:28:09 +09:00
tequ
bb27479686 fix: TrustSet free trust line check uses sponsor's ownerCount, skipping sponsor reserve validation #6901 2026-04-21 17:51:50 +09:00
tequ
278e25d8ad fix: Preclaim XRP reserve overestimate for sponsored checks #6899 2026-04-21 17:25:33 +09:00
tequ
773acf0af7 fix: SponsoringAccountCount has no overflow protection #6898 2026-04-21 17:20:22 +09:00
tequ
7639bd9061 fix: MPTokenIssuanceDestroy reads sponsor from erased SLE #6895 2026-04-21 16:27:33 +09:00
tequ
207a33d3da fix: SponsorshipSet Update FeeAmount Lacks Reserve Floor Check 2026-04-21 15:56:28 +09:00
tequ
52e7cdc24d fix: Sponsored account creation double-counts base reserve #6894 2026-04-21 13:48:07 +09:00
tequ
dd82977e6c Merge remote-tracking branch 'upstream/develop' into sponsor 2026-04-13 18:08:30 +09:00
tequ
31bc25973a fix SponsorshipSet Update FeeAmount Lacks Reserve Floor Check 2026-04-13 15:56:29 +09:00
tequ
021eaa81bf fix Co-Signed Sponsoring Bypasses Sponsor Balance Check 2026-04-13 15:30:33 +09:00
tequ
84e84fbadf fix Sponsor able to provide sponsorship with just base reserve 2026-04-13 14:03:37 +09:00
tequ
b6b317597f add test for insufficient balance to sponsor fee 2026-04-10 21:43:35 +09:00
tequ
525adf122f fix reset() Does Not makeFieldAbsent for Zero FeeAmount 2026-04-10 18:28:28 +09:00
tequ
16e4f24226 fix XRPL_ASSERT(false) to UNREACHABLE 2026-04-10 17:59:25 +09:00
tequ
3df1e668da fix Unchecked std::optional Dereference in SponsorshipSet Create Path 2026-04-10 17:55:40 +09:00
tequ
9264136b36 fix deleteAMMTrustLine Reads Sponsor Fields After They Are Erased 2026-04-10 17:41:33 +09:00
tequ
6bd2e911eb fix Wrong Account in Sponsorship Keylet Lookup Causes Reserve Count
Leakage
2026-04-10 17:07:36 +09:00
tequ
828b4753fe fix Wrong Account Passed to getLedgerEntryOwner in doApply 2026-04-10 15:57:15 +09:00
tequ
d524670bcd fix SponsorshipEnd Bypass 2026-04-10 15:54:16 +09:00
tequ
25de0ce1b1 fix comment 2026-04-10 14:21:05 +09:00
tequ
4026af175b format 2026-04-10 14:13:55 +09:00
tequ
a115d73c56 return tecHAS_OBLIGATIONS for any conditions when deleting account linked to ltSponsorship 2026-04-10 14:13:25 +09:00
tequ
71003699dc Add test for no SponsorFlag with valid sponsor 2026-04-10 13:45:14 +09:00
tequ
831f99862d clang-tidy 2026-04-10 05:51:22 +09:00
tequ
4d2945323d fix AccountObjects_test.cpp error 2026-04-10 04:21:11 +09:00
tequ
700a528a25 Merge remote-tracking branch 'upstream/develop' into sponsor 2026-04-10 03:38:07 +09:00
tequ
07d0887efb fix path 2026-04-09 00:46:20 +09:00
tequ
3ea0067e6a clang-format 2026-04-08 12:03:12 +09:00
tequ
5a195d2585 fix path 2026-04-08 11:55:35 +09:00
tequ
3f4e88c300 Merge remote-tracking branch 'xrplf/develop' into sponsor 2026-04-08 11:47:16 +09:00
tequ
7c3ca98bd5 Merge remote-tracking branch 'upstream/develop' into sponsor 2026-03-31 14:22:49 +09:00
tequ
2505fa86f7 fix 2026-03-30 17:52:36 +09:00
tequ
d0d4f1d153 Merge remote-tracking branch 'upstream/develop' into sponsor 2026-03-30 17:25:14 +09:00
tequ
41429dcc99 Merge remote-tracking branch 'upstream/develop' into sponsor 2026-03-25 11:59:44 +09:00
tequ
aacb8e4a68 return tem error when SponsorReserve flag is set in Batch OuterTxn 2026-03-23 13:31:36 +09:00
tequ
98257d3b96 Fix SponsorshipSet targeting Pseudo Accounts to return an error 2026-03-23 13:07:28 +09:00
tequ
afcc3c6464 Merge remote-tracking branch 'upstream/develop' into sponsor 2026-03-23 12:46:27 +09:00
tequ
fd393685dd fix L20 2026-03-23 12:46:17 +09:00
tequ
de64bc7855 fix L18 2026-03-23 12:34:33 +09:00
tequ
1adaeac8a7 fix L14 2026-03-23 12:14:44 +09:00
tequ
7ddda1b1e6 fix L5 2026-03-23 12:01:30 +09:00
tequ
5280a185d0 fix L4 2026-03-23 11:59:46 +09:00
tequ
64f699a974 fix M17 2026-03-23 11:14:41 +09:00
tequ
968493f43b fix M16 2026-03-23 11:10:45 +09:00
tequ
22bfc5e743 fix M15 2026-03-23 11:02:59 +09:00
tequ
2f0adfae3b fix M11 2026-03-23 10:55:42 +09:00
tequ
53bdfb2bc7 Add comment to clarify that the door account should not have a sponsor in the reserve check 2026-03-23 10:28:27 +09:00
tequ
b695b4bf9b Add comments for PreFunded sponsor reserve checks on TrustSet 2026-03-23 10:27:18 +09:00
tequ
6d7ffcbb91 fix M7 2026-03-19 15:39:55 +09:00
tequ
d1346fa3f6 fix M6 2026-03-19 15:14:14 +09:00
tequ
d6803868a1 fix M5 2026-03-19 15:00:09 +09:00
tequ
9a6432dd66 fix M3 2026-03-19 14:50:09 +09:00
tequ
f8a8c2301c fix M2 2026-03-19 14:33:55 +09:00
tequ
e40e15a866 fix C2, C4 2026-03-19 14:01:11 +09:00
tequ
6555001cd9 make sponsor helpers inline 2026-03-19 11:50:55 +09:00
tequ
f13945eff9 Merge remote-tracking branch 'upstream/develop' into sponsor 2026-03-19 11:10:44 +09:00
tequ
b32ff18c21 refactor getFeePayer() 2026-03-18 00:19:21 +09:00
tequ
8baec5634c pre-commit run --all-files 2026-03-18 00:03:31 +09:00
tequ
37c95ead69 Merge remote-tracking branch 'upstream/develop' into sponsor 2026-03-18 00:02:57 +09:00
tequ
234d2e5414 Refactor ownerCount and calculateReserve to use SLE::const_ref 2026-03-17 21:38:25 +09:00
tequ
024ab07eb4 minor fixes 2026-03-17 21:35:08 +09:00
tequ
d95b6e41e5 Refactor variable declarations in xrpLiquid 2026-03-17 21:15:41 +09:00
tequ
8d75f3bdc6 remove asfDisallowIncomingSponsor 2026-03-17 21:13:35 +09:00
tequ
eb7e01de7e Remove unused tx parameter from removeEmptyHolding() 2026-03-17 21:04:40 +09:00
tequ
c79814a037 remove unused Sponsor.h 2026-03-17 20:39:57 +09:00
tequ
15be71469d remove unnecessary reserveCount check 2026-03-17 20:35:50 +09:00
tequ
c9666d7b45 refactor adjustOwnerCount() to use adjustSponsorOwnerCountHlp() 2026-03-17 20:28:01 +09:00
tequ
839ba17dae Refactor: sponsorship-related helpers 2026-03-17 20:11:49 +09:00
tequ
85e1f2b16c Rename [sponsor|sponsee]Acc,[sponsor|sponsee]Account to [sponsor|sponsee]AccountID for clarity 2026-03-17 18:32:30 +09:00
tequ
8a05e3d93b remove unnecessary #endif in Sponsor.h and sponsor.h 2026-03-17 18:14:48 +09:00
tequ
8c8ecffe1f remove tx parameter from adjustOwnerCount() 2026-03-17 18:14:24 +09:00
tequ
b9f1c97518 format SetTrust.cpp 2026-03-17 17:43:35 +09:00
tequ
d1eb22b403 fix transactions.macro format 2026-03-17 17:38:04 +09:00
tequ
fb86735800 use pragma once 2026-03-17 17:26:13 +09:00
tequ
53f407e1bd Merge remote-tracking branch 'upstream/develop' into sponsor 2026-03-17 17:22:54 +09:00
tequ
99618877e4 clang-format 2026-02-23 23:55:25 +09:00
tequ
062ece321b Merge remote-tracking branch 'upstream/develop' into sponsor 2026-02-23 23:20:21 +09:00
tequ
1ad6dd1846 Add tests for deleting Sponsor Account with ltSponsorship 2026-02-23 11:10:46 +09:00
tequ
4a91351bcd Add sfSponsee to ttSponsorshipTransfer 2026-02-22 17:21:04 +09:00
tequ
f86b255e73 Add SponsorshipEnd/Create/Reassign flags for SponsorshipTransfer 2026-02-22 02:41:01 +09:00
tequ
178bb8f7e9 Allow zero value for ReserveCount, FeeAmount, MaxFee 2026-02-22 00:01:56 +09:00
tequ
293394fbc6 audit 14 2026-02-18 17:22:23 +09:00
tequ
dcfcb1f3fd audit 13 2026-02-18 16:33:32 +09:00
tequ
2fd8e1be3c audit 12 2026-02-18 15:55:10 +09:00
tequ
fe5fab00ed audit 11 2026-02-18 15:18:17 +09:00
tequ
9cde57d284 audit 10 2026-02-18 15:09:12 +09:00
tequ
9859ba85a8 audit 9 2026-02-18 15:01:35 +09:00
tequ
f6d79f74d6 audit 8 2026-02-18 14:53:21 +09:00
tequ
bf4fa37937 audit 7 2026-02-18 14:48:51 +09:00
tequ
686f945909 audit 6 2026-02-18 14:46:03 +09:00
tequ
c1e1be510f audit 5 2026-02-18 14:39:27 +09:00
tequ
d1d613da27 audit 4 2026-02-18 14:19:40 +09:00
tequ
392a913631 audit 3 2026-02-18 14:09:11 +09:00
tequ
446681dc3d Merge remote-tracking branch 'upstream/develop' into sponsor 2026-02-18 13:39:57 +09:00
tequ
e1aee43359 address review 2026-02-03 14:45:55 +09:00
tequ
fe075470f8 address review 2026-02-02 18:57:04 +09:00
tequ
49c52695cb sfSponsorAccount -> sfSponsor/sfCounterpartySponsor 2026-02-02 12:51:35 +09:00
tequ
37f4ea94cb Add tests for Loan 2026-02-02 12:30:06 +09:00
tequ
f8209087a3 Add tests for LoanBroker transactions 2026-02-01 20:38:37 +09:00
tequ
d390bc7a87 clang-format 2026-01-31 01:33:36 +09:00
tequ
4e87de7303 add test for Sponsored trustline 2026-01-31 01:31:37 +09:00
tequ
8d24afe59d Merge remote-tracking branch 'upstream/develop' into sponsor 2026-01-30 23:29:56 +09:00
tequ
527d7bbede fix to return error if FeeAmount > Balance on SponsorshipSet 2026-01-30 23:24:50 +09:00
tequ
4a205eb9d8 add checks to accountReserve and fix sponsored owner count for xrpLiquid 2026-01-30 22:23:45 +09:00
tequ
0a410024a5 refactor SponsorshipSet flag checks 2026-01-30 22:22:09 +09:00
tequ
8f8fc03800 Add InvariantChecks for if OwnerCount < SponsoredOwnerCount 2026-01-30 21:21:38 +09:00
tequ
40cf5993c1 Add sanity check for sponsoringAccountCount = 0 2026-01-30 20:36:43 +09:00
tequ
7cdaa24e63 Fixed the minimum amount for creating a Sponsored Account. 2026-01-30 20:27:46 +09:00
tequ
175a2dfd28 chang sfFeeAmount to soeOPTIONAL 2026-01-30 20:03:24 +09:00
tequ
4cd8d0d178 fix simulate test 2026-01-30 19:51:07 +09:00
tequ
5155a94015 Add sponsor tests for Batch innerTxn 2026-01-30 17:20:15 +09:00
tequ
c0de722cfa sfHigh/LowSponsorAccount -> High/LowSponsor 2026-01-30 12:32:48 +09:00
tequ
d7ab1b48e1 Separate test suite 2026-01-30 11:43:45 +09:00
tequ
65768237cd Payback ReserveCount 2026-01-30 11:36:56 +09:00
tequ
5f385e0f9b update to use sfSponsorFlags 2026-01-30 10:36:48 +09:00
tequ
ab1de456cc add comment 2026-01-29 13:52:19 +09:00
tequ
8be44c7fc4 Merge remote-tracking branch 'upstream/develop' into sponsor 2026-01-29 11:22:42 +09:00
tequ
87718bdb3b remove unused HashPrefix 2026-01-29 10:58:06 +09:00
tequ
88e870b1c6 change sfSponsor to STAccount, Sponsor flags as global flags 2026-01-27 12:38:01 +09:00
tequ
ce8049a17f fix parseSponsorship 2026-01-27 11:34:08 +09:00
tequ
990627fc9e Merge remote-tracking branch 'upstream/develop' into sponsor 2026-01-27 10:38:24 +09:00
tequ
1823d70b21 refactor Oracle Reserve calculation 2026-01-27 10:34:15 +09:00
tequ
f333dd1b2e add signature existence check, consume ReserveCount if pre-funded sponsoring 2026-01-27 10:33:52 +09:00
tequ
204138fb0e Revert the use of calculateReserve in xrpLiquid 2026-01-15 18:48:35 +09:00
tequ
52ae31bb17 Merge commit 'c9458b72cab68d3cbbf533cc87d14309c2eb93b7' into sponsor 2026-01-15 16:34:24 +09:00
tequ
c3e5bcfafd address review (DeleteAccount) 2026-01-15 15:53:29 +09:00
tequ
3568df43c4 add calculateReserve helper 2026-01-15 15:01:55 +09:00
tequ
c321e1070d address reviews 2026-01-15 14:51:05 +09:00
tequ
9e65dba253 fix redundant co-signed sponsor check 2026-01-15 14:32:47 +09:00
tequ
5b91d815d1 address revew (std::optional + std::shared_ptr<SLE>) 2026-01-15 14:29:37 +09:00
tequ
f885f02ede address spec changes (sfReserveCount, sfFeeAmount) 2026-01-14 19:28:10 +09:00
tequ
1bc5a1bb43 address spec changes (payment flags/ iou amount) 2026-01-14 12:49:49 +09:00
tequ
ec05613472 fix typo 2026-01-09 16:45:12 +09:00
tequ
f88e964dac allow sponsee on cspell 2026-01-09 16:40:15 +09:00
tequ
ffb538242a Merge remote-tracking branch 'upstream/develop' into sponsor 2026-01-09 16:38:44 +09:00
tequ
1e8f6ce1b5 address reviews 2026-01-09 16:31:22 +09:00
tequ
82b146bf03 fix ripple -> xrpl 2026-01-07 17:16:50 +09:00
tequ
0791ca164a fix template exception 2026-01-07 16:42:18 +09:00
tequ
dc325a93e7 Merge branch 'develop' into sponsor 2026-01-07 12:35:47 +09:00
tequ
edddf3fe4b address review 2026-01-07 12:34:51 +09:00
tequ
cf03c4cb8f change Sponsor related fields to soeDEFAULT 2026-01-07 12:31:01 +09:00
tequ
2813fea294 address review 2026-01-07 11:39:56 +09:00
tequ
163a2acbf5 add sfPreviousTxnID and sfPreviousTxnLgrSeq to ltSponsorship 2026-01-07 11:27:10 +09:00
tequ
198f3f83db remove unused insSponsorCoSigning args 2026-01-07 11:14:01 +09:00
tequ
0f36de8ef5 Merge remote-tracking branch 'upstream/develop' into sponsor 2026-01-07 10:58:21 +09:00
tequ
ea29fe5ede Merge remote-tracking branch 'upstream/develop' into sponsor 2025-12-11 10:31:48 +09:00
tequ
f5e2195bbb address reviews 2025-12-11 10:31:30 +09:00
tequ
e49d338cd8 address SponsorshipSet reviews 2025-11-26 17:48:35 +09:00
tequ
d96998ce47 Merge remote-tracking branch 'upstream/develop' into sponsor 2025-11-26 17:20:19 +09:00
tequ
a9629ae325 address reviews 2025-11-21 17:44:05 +09:00
tequ
7f0a940a43 Merge remote-tracking branch 'upstream/develop' into sponsor 2025-11-21 17:18:20 +09:00
tequ
c38cb902ad Merge remote-tracking branch 'upstream/develop' into sponsor 2025-11-21 17:17:48 +09:00
tequ
b5db59644a update Sponsored VaultCreate test 2025-11-17 18:29:22 +09:00
tequ
9d1b5eb373 Merge remote-tracking branch 'upstream/develop' into sponsor 2025-11-17 18:19:30 +09:00
tequ
af9d91bc72 add tests fro SponsorshipTransfer 2025-11-10 22:22:32 +09:00
tequ
3f9673510a fix comment for LCOV 2025-11-10 21:50:31 +09:00
tequ
a49cb91c73 add tests 2025-11-10 12:11:42 +09:00
tequ
fbf403aaa4 add tests for sponsor field 2025-11-10 00:55:39 +09:00
tequ
e03c7a9c96 add sponsor transfer test 2025-11-10 00:40:15 +09:00
tequ
cd62f7f4cf remove copyright 2025-11-06 21:08:51 +09:00
tequ
297083e27b fix: specify type for adjust variable in SetOracle transaction processing 2025-11-06 18:36:17 +09:00
tequ
13145f6db2 fix header name 2025-11-06 18:34:24 +09:00
tequ
3e6d6c6f80 Merge remote-tracking branch 'upstream/develop' into sponsor 2025-11-06 18:08:13 +09:00
tequ
b4188a887a address reviews 2025-11-06 17:53:07 +09:00
tequ
774917db22 Merge remote-tracking branch 'upstream/develop' into sponsor 2025-10-31 11:24:47 +09:00
tequ
965ecd3f27 Add sponsored outer batch 2025-10-28 21:07:20 +09:00
tequ
d0bcca6bf1 Fix the behavior of co-sign + pre-fund 2025-10-28 17:18:38 +09:00
tequ
4fe7e87b4f Merge remote-tracking branch 'upstream/develop' into sponsor 2025-10-17 19:21:24 +09:00
tequ
2337d340e5 Allow delegation for Sponsorship transactions 2025-10-17 18:56:46 +09:00
tequ
5d597e3b69 Merge remote-tracking branch 'upstream/develop' into sponsor 2025-10-16 22:08:42 +09:00
tequ
d8dc000488 add prefunded sponsor tests 2025-10-09 19:12:14 +09:00
tequ
a65cf6e07d add tests for sponsor flags 2025-10-08 14:09:02 +09:00
tequ
7f922c4919 reserve co-signing 2025-10-08 02:50:08 +09:00
tequ
754f597078 Support sfSponsorSignature autofilling in Simulate RPC 2025-10-07 16:02:02 +09:00
tequ
32cc7825f2 Merge branch 'refactor-simulate-autofill' into sponsor 2025-10-07 15:30:48 +09:00
tequ
a6b0efff87 typo 2025-10-07 11:19:31 +09:00
tequ
28c5cadbea fix transactions.macro format 2025-10-07 10:45:30 +09:00
tequ
9df0ad64d1 Merge branch 'sponsor-new-signing' into sponsor 2025-10-07 09:24:58 +09:00
tequ
1441abcf01 use sfSponsorSignature 2025-10-07 09:01:45 +09:00
Ed Hennis
8d32b0f856 Add jtx, STObject, and RPC support for sig object fields 2025-10-07 08:41:43 +09:00
tequ
d59772657e refactor: signature autofilling for Simulate RPC 2025-10-04 14:37:06 +09:00
Ed Hennis
bc71d9c138 Add support for extra transaction signature validation
- Restructures `STTx` signature checking code to be able to handle
  a `sigObject`, which may be the full transaction, or may be an object
  field containing a separate signature. Either way, the `sigObject` can
  be a single- or multi-sign signature.
- This is distinct from 550f90a75e (#5594), which changed the check in
  Transactor, which validates whether a given account is allowed to sign
  for the given transaction. This cryptographically checks the signature
  validity.
2025-10-04 13:22:56 +09:00
tequ
101b70f0e8 add assert when adding/removing sponsor field to LedgerEntry 2025-10-03 15:07:46 +09:00
tequ
ee385e9d3b fix bad merge 2025-10-03 15:04:33 +09:00
tequ
4126d53978 Merge remote-tracking branch 'origin/develop' into sponsor 2025-10-03 09:39:47 +09:00
tequ
59c3d5bddc add insufficient reserve check for xchain, vault 2025-10-02 23:37:44 +09:00
tequ
bc1ef1e839 add tests for XChainBridge 2025-10-02 18:29:12 +09:00
tequ
5b64ff0dd6 address 5594, 5592 changes 2025-09-30 18:30:38 +09:00
tequ
1ee250881b Merge remote-tracking branch 'upstream/develop' into sponsor 2025-09-30 12:06:09 +09:00
tequ
75aaeb5aae Merge remote-tracking branch 'upstream/develop' into sponsor 2025-09-26 18:26:40 +09:00
tequ
b09666210d add InvariantChecks for pseudo-account 2025-09-26 18:25:49 +09:00
tequ
dbbfc1354c test for Vault 2025-09-26 18:21:24 +09:00
tequ
e82c300de7 test Sponsor Reserve checks for AMM 2025-09-26 10:15:00 +09:00
tequ
d5a1314c47 test Sponsor Reserve checks for TrustSet 2025-09-24 19:05:22 +09:00
tequ
699297f01a test Sponsor Reserve checks for SignerListSet 2025-09-24 18:59:16 +09:00
tequ
71b81b743e test Sponsor Reserve checks for PayChan, PermissionedDomain, Oracle 2025-09-24 17:35:23 +09:00
tequ
ec11763def test Sponsor Reserve checks for NFToken 2025-09-24 17:12:02 +09:00
tequ
cc4b07dbd6 test Sponsor Reserve checks for DID, Escrow 2025-09-24 16:18:09 +09:00
tequ
b78885d98c test Sponsor Reserve checks for DepositPreauth 2025-09-24 15:59:06 +09:00
tequ
0c93bd6f08 test Sponsor Reserve checks for DelegateSet 2025-09-24 15:57:49 +09:00
tequ
9694de92da test Sponsor Reserve checks for Credentials 2025-09-24 15:54:48 +09:00
tequ
c4b798e8ed test Sponsor Reserve checks for TicketCreate 2025-09-24 15:41:58 +09:00
tequ
350130911a test Sponsor Reserve checks for OfferCreate 2025-09-24 15:34:55 +09:00
tequ
ab4ac64c92 test Sponsor Reserve checks for Checks 2025-09-24 15:05:31 +09:00
tequ
aeaf679deb Merge remote-tracking branch 'upstream/develop' into sponsor 2025-09-24 13:42:57 +09:00
tequ
ea72198a1d Transfer Trustline Sponsorship 2025-09-24 13:42:05 +09:00
tequ
6eb453f07d Merge branch 'develop' into sponsor 2025-09-20 23:08:53 +09:00
tequ
d4947386d7 Fully Support NFTokenMint/Burn 2025-09-20 17:03:20 +09:00
tequ
fed56b2eeb address SponsorAccount/Sponsee field changes 2025-09-20 14:29:33 +09:00
tequ
f7e1d4bbb9 add AccountTx tests for Sponsorship 2025-09-20 12:20:29 +09:00
tequ
613fe48d54 update account_objects for sponsorship 2025-09-20 11:44:47 +09:00
tequ
5dc63b64eb fix SponsorshipTransfer 2025-09-20 10:34:46 +09:00
tequ
cc5e063438 add Credential sponsor test 2025-09-19 21:25:46 +09:00
tequ
453fd23512 add Sponsor Oracle 2025-09-19 21:12:34 +09:00
tequ
89af81745b add tests 2025-09-19 01:36:45 +09:00
tequ
a43ae9a3ce add InvariantCheck for sponsor count 2025-09-18 18:49:53 +09:00
tequ
2afe5707ab High/Low SponsorAccount 2025-09-18 16:32:50 +09:00
tequ
759f843020 Sponsor permissions 2025-09-16 23:11:19 +09:00
tequ
5ac7bbf51b test SponsorshipRequire flags 2025-09-15 22:48:40 +09:00
tequ
2a27280f1a fix test error 2025-09-15 22:07:43 +09:00
tequ
6c0732ccbe test checks 2025-09-15 20:29:58 +09:00
tequ
20bce64946 test AccountDelete for sponsorship 2025-09-15 19:09:57 +09:00
tequ
110b222579 add MaxFee test 2025-09-15 18:52:42 +09:00
tequ
1cdf7bb745 feePayer 2025-09-15 16:25:16 +09:00
tequ
4abd94e7ac MaxFee 2025-09-15 11:04:47 +09:00
tequ
6aa0331ffe sfAccount to sfOwner 2025-09-13 22:40:19 +09:00
tequ
4eea76ca92 Create Sponsored Account / AccountDelete with ltSponsorship, Sponsored Account 2025-09-13 22:34:54 +09:00
tequ
8e895a3e7d fullly rename 2025-09-13 09:49:30 +09:00
tequ
e589b71ee0 v2. SponsorSet 2025-09-13 09:36:38 +09:00
tequ
02d8f9fbef Sponsor signing 2025-09-08 00:20:14 +09:00
tequ
9ff71aa109 Merge remote-tracking branch 'upstream/develop' into sponsor 2025-09-06 23:11:10 +09:00
tequ
2071b39d6a use helper 2025-08-01 18:33:19 +09:00
tequ
5e65813a52 add reserve checks for SponsorTransfer 2025-08-01 18:21:44 +09:00
tequ
abd8620c97 Add SponsorTransfer 2025-08-01 13:23:41 +09:00
tequ
6e01f233e4 fix fees().accountReserve(0) to fees().reserve 2025-08-01 01:59:08 +09:00
tequ
0bddc95444 clang-format 2025-08-01 01:19:37 +09:00
tequ
67bdd099c8 check reserve 2025-08-01 00:44:11 +09:00
tequ
f0addd81a1 fix addEmptyHolding 2025-07-31 17:43:54 +09:00
tequ
a798c60a08 test Disabled 2025-07-31 00:12:23 +09:00
tequ
198ed72fe3 fix OwnerCount 2025-07-31 00:12:09 +09:00
tequ
d40f8cc232 SponsorReserve,SponsorAccount
- not fully tested
- need to modify: Reserve check where using sfOwnerCount
2025-07-30 23:39:14 +09:00
tequ
5b9c767b07 Merge remote-tracking branch 'upstream/develop' into sponsor 2025-07-29 22:58:03 +09:00
Mayukha Vadari
43c16f35f7 PoC for sponsored reserve 2025-06-17 11:35:23 +09:00
Mayukha Vadari
cad305ac7e PoC for sponsored fees 2025-06-17 11:32:13 +09:00
387 changed files with 18320 additions and 6952 deletions

View File

@@ -9,43 +9,90 @@ Checks: "-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-capturing-lambda-coroutines,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-avoid-reference-coroutine-parameters,
-cppcoreguidelines-c-copy-assignment-signature,
-cppcoreguidelines-explicit-virtual-functions,
-cppcoreguidelines-interfaces-global-init,
-cppcoreguidelines-macro-to-enum,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-missing-std-forward,
-cppcoreguidelines-narrowing-conversions,
-cppcoreguidelines-no-malloc,
-cppcoreguidelines-noexcept-destructor,
-cppcoreguidelines-noexcept-move-operations,
-cppcoreguidelines-noexcept-swap,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-prefer-member-initializer,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-const-cast,
-cppcoreguidelines-pro-type-cstyle-cast,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-slicing,
-cppcoreguidelines-special-member-functions,
llvm-namespace-comment,
misc-*,
-misc-anonymous-namespace-in-header,
-misc-confusable-identifiers,
-misc-coroutine-hostile-raii,
-misc-misleading-bidirectional,
-misc-misleading-identifier,
-misc-multiple-inheritance,
-misc-new-delete-overloads,
-misc-no-recursion,
-misc-non-copyable-objects,
-misc-non-private-member-variables-in-classes,
-misc-override-with-different-visibility,
-misc-predictable-rand,
-misc-unconventional-assign-operator,
-misc-uniqueptr-reset-release,
-misc-unused-parameters,
-misc-use-anonymous-namespace,
-misc-use-internal-linkage,
modernize-*,
-modernize-avoid-bind,
-modernize-avoid-c-arrays,
-modernize-avoid-c-style-cast,
-modernize-avoid-setjmp-longjmp,
-modernize-avoid-variadic-functions,
-modernize-deprecated-ios-base-aliases,
-modernize-loop-convert,
-modernize-macro-to-enum,
-modernize-min-max-use-initializer-list,
-modernize-raw-string-literal,
-modernize-redundant-void-arg,
-modernize-replace-auto-ptr,
-modernize-replace-disallow-copy-and-assign-macro,
-modernize-replace-random-shuffle,
-modernize-return-braced-init-list,
-modernize-shrink-to-fit,
-modernize-unary-static-assert,
-modernize-use-auto,
-modernize-use-bool-literals,
-modernize-use-constraints,
-modernize-use-default-member-init,
-modernize-use-integer-sign-comparison,
-modernize-use-noexcept,
-modernize-use-nullptr,
-modernize-use-std-format,
-modernize-use-std-print,
-modernize-use-trailing-return-type,
-modernize-use-transparent-functors,
-modernize-use-uncaught-exceptions,
performance-*,
-performance-avoid-endl,

View File

@@ -72,6 +72,7 @@ test.app > xrpl.server
test.app > xrpl.shamap
test.app > xrpl.tx
test.basics > test.jtx
test.basics > test.unit_test
test.basics > xrpl.basics
test.basics > xrpl.core
test.basics > xrpld.rpc
@@ -161,6 +162,9 @@ test.protocol > test.unit_test
test.protocol > xrpl.basics
test.protocol > xrpl.json
test.protocol > xrpl.protocol
test.resource > test.unit_test
test.resource > xrpl.basics
test.resource > xrpl.resource
test.rpc > test.jtx
test.rpc > xrpl.basics
test.rpc > xrpl.config
@@ -184,6 +188,12 @@ test.server > xrpld.core
test.server > xrpl.json
test.server > xrpl.protocol
test.server > xrpl.server
test.shamap > test.unit_test
test.shamap > xrpl.basics
test.shamap > xrpl.config
test.shamap > xrpl.nodestore
test.shamap > xrpl.protocol
test.shamap > xrpl.shamap
test.unit_test > xrpl.basics
test.unit_test > xrpl.protocol
tests.libxrpl > xrpl.basics
@@ -195,7 +205,6 @@ tests.libxrpl > xrpl.net
tests.libxrpl > xrpl.nodestore
tests.libxrpl > xrpl.protocol
tests.libxrpl > xrpl.protocol_autogen
tests.libxrpl > xrpl.resource
tests.libxrpl > xrpl.server
tests.libxrpl > xrpl.shamap
tests.libxrpl > xrpl.tx

View File

@@ -90,19 +90,20 @@ repos:
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: ea11f9efc0bec520073405bc30552da887ba71bc # frozen: v10.0.1
hooks:
- id: cspell
name: check changed files spelling
- id: cspell # Spell check changed files
exclude: |
(?x)^(
\.cspell\.config\.yaml|
.config/cspell.config.yaml|
include/xrpl/protocol_autogen/(transactions|ledger_entries)/.*
)$
- id: cspell
- id: cspell # Spell check the commit message
name: check commit message spelling
args:
- --no-must-find-files
- --no-progress
- --no-summary
- --files
- .git/COMMIT_EDITMSG
stages: [commit-msg]
- repo: local

View File

@@ -25,7 +25,7 @@ You can verify that the required tools are installed and runnable with:
| ----------- | --------------- |
| GCC | 15.2 |
| Clang | 22 |
| Apple Clang | 21 |
| Apple Clang | 17 |
| MSVC | 19.44[^windows] |
## Operating Systems

View File

@@ -17,11 +17,9 @@ import subprocess
import sys
from pathlib import Path
CLANG_TIDY_VERSION = 22
def find_run_clang_tidy() -> str | None:
for candidate in (f"run-clang-tidy-{CLANG_TIDY_VERSION}", "run-clang-tidy"):
for candidate in ("run-clang-tidy-21", "run-clang-tidy"):
if path := shutil.which(candidate):
return path
return None
@@ -46,8 +44,8 @@ def main():
run_clang_tidy = find_run_clang_tidy()
if not run_clang_tidy:
print(
f"clang-tidy check failed: TIDY is enabled but neither "
f"'run-clang-tidy-{CLANG_TIDY_VERSION}' nor 'run-clang-tidy' was found in PATH.",
"clang-tidy check failed: TIDY is enabled but neither "
"'run-clang-tidy-21' nor 'run-clang-tidy' was found in PATH.",
file=sys.stderr,
)
return 1

View File

@@ -36,7 +36,9 @@ overrides:
- /'[^']*'/g # single-quoted strings
- /`[^`]*`/g # backtick strings
suggestWords:
- unsynched->unsynced
- xprl->xrpl
- xprld->xrpld # cspell: disable-line not sure what this problem is....
- unsynched->unsynced # cspell: disable-line not sure what this problem is....
- synched->synced
- synch->sync
words:
@@ -279,6 +281,8 @@ words:
- sles
- soci
- socidb
- sponsee
- sponsees
- SRPMS
- sslws
- statsd
@@ -327,6 +331,7 @@ words:
- unserviced
- unshareable
- unshares
- unsponsored
- unsquelch
- unsquelched
- unsquelching

View File

@@ -211,17 +211,15 @@ operator<<(Stream& s, Slice const& v)
}
template <class T, std::size_t N>
Slice
std::enable_if_t<std::is_same_v<T, char> || std::is_same_v<T, unsigned char>, Slice>
makeSlice(std::array<T, N> const& a)
requires(std::is_same_v<T, char> || std::is_same_v<T, unsigned char>)
{
return Slice(a.data(), a.size());
}
template <class T, class Alloc>
Slice
std::enable_if_t<std::is_same_v<T, char> || std::is_same_v<T, unsigned char>, Slice>
makeSlice(std::vector<T, Alloc> const& v)
requires(std::is_same_v<T, char> || std::is_same_v<T, unsigned char>)
{
return Slice(v.data(), v.size());
}

View File

@@ -212,13 +212,11 @@ public:
*/
template <class ReturnType = bool>
auto
insert(key_type const& key, T const& value) -> ReturnType
requires(!IsKeyCache);
insert(key_type const& key, T const& value) -> std::enable_if_t<!IsKeyCache, ReturnType>;
template <class ReturnType = bool>
auto
insert(key_type const& key) -> ReturnType
requires IsKeyCache;
insert(key_type const& key) -> std::enable_if_t<IsKeyCache, ReturnType>;
// VFALCO NOTE It looks like this returns a copy of the data in
// the output parameter 'data'. This could be expensive.

View File

@@ -57,10 +57,7 @@ inline TaggedCache<
beast::insight::Collector::ptr const& collector)
: journal_(journal)
, clock_(clock)
, stats_(
name,
[this] { collectMetrics(); },
collector)
, stats_(name, std::bind(&TaggedCache::collectMetrics, this), collector)
, name_(name)
, targetSize_(size)
, targetAge_(expiration)
@@ -503,8 +500,7 @@ template <
template <class ReturnType>
inline auto
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
insert(key_type const& key, T const& value) -> ReturnType
requires(!IsKeyCache)
insert(key_type const& key, T const& value) -> std::enable_if_t<!IsKeyCache, ReturnType>
{
static_assert(
std::is_same_v<std::shared_ptr<T>, SharedPointerType> ||
@@ -534,8 +530,7 @@ template <
template <class ReturnType>
inline auto
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
insert(key_type const& key) -> ReturnType
requires IsKeyCache
insert(key_type const& key) -> std::enable_if_t<IsKeyCache, ReturnType>
{
std::scoped_lock const lock(mutex_);
clock_type::time_point const now(clock_.now());

View File

@@ -12,9 +12,8 @@ namespace xrpl {
*/
template <class T>
std::string
std::enable_if_t<std::is_arithmetic_v<T>, std::string>
to_string(T t) // NOLINT(readability-identifier-naming)
requires(std::is_arithmetic_v<T>)
{
return std::to_string(t);
}

View File

@@ -97,7 +97,7 @@ public:
//
static constexpr std::size_t kBytes = Bits / 8;
static_assert(sizeof(data_) == kBytes);
static_assert(sizeof(data_) == kBytes, "");
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
@@ -280,11 +280,12 @@ public:
{
}
template <class Container>
explicit BaseUInt(Container const& c)
requires(
template <
class Container,
class = std::enable_if_t<
detail::IsContiguousContainer<Container>::value &&
std::is_trivially_copyable_v<typename Container::value_type>)
std::is_trivially_copyable_v<typename Container::value_type>>>
explicit BaseUInt(Container const& c)
{
// Use AlwaysFalseT so the static_assert condition is dependent
// and only triggers when this constructor template is instantiated.
@@ -294,12 +295,13 @@ public:
"Use base_uint::fromRaw instead.");
}
template <class Container>
template <
class Container,
class = std::enable_if_t<
detail::IsContiguousContainer<Container>::value &&
std::is_trivially_copyable_v<typename Container::value_type>>>
static BaseUInt
fromRaw(Container const& c)
requires(
detail::IsContiguousContainer<Container>::value &&
std::is_trivially_copyable_v<typename Container::value_type>)
{
BaseUInt result;
XRPL_ASSERT(
@@ -310,11 +312,11 @@ public:
}
template <class Container>
BaseUInt&
std::enable_if_t<
detail::IsContiguousContainer<Container>::value &&
std::is_trivially_copyable_v<typename Container::value_type>,
BaseUInt&>
operator=(Container const& c)
requires(
detail::IsContiguousContainer<Container>::value &&
std::is_trivially_copyable_v<typename Container::value_type>)
{
XRPL_ASSERT(
c.size() * sizeof(typename Container::value_type) == size(),

View File

@@ -0,0 +1,54 @@
#pragma once
#include <functional>
namespace xrpl {
#ifdef _MSC_VER
/*
* MSVC 2019 version 16.9.0 added [[nodiscard]] to the std comparison
* operator() functions. boost::bimap checks that the comparator is a
* BinaryFunction, in part by calling the function and ignoring the value.
* These two things don't play well together. These wrapper classes simply
* strip [[nodiscard]] from operator() for use in boost::bimap.
*
* See also:
* https://www.boost.org/doc/libs/1_75_0/libs/bimap/doc/html/boost_bimap/the_tutorial/controlling_collection_types.html
*/
template <class T = void>
struct less
{
using result_type = bool;
constexpr bool
operator()(T const& left, T const& right) const
{
return std::less<T>()(left, right);
}
};
template <class T = void>
struct equal_to
{
using result_type = bool;
constexpr bool
operator()(T const& left, T const& right) const
{
return std::equal_to<T>()(left, right);
}
};
#else
template <class T = void>
using less = std::less<T>;
template <class T = void>
using equal_to = std::equal_to<T>;
#endif
} // namespace xrpl

View File

@@ -138,8 +138,11 @@ public:
{
}
ConstIterator(Iterator const& orig) : map(orig.map), ait(orig.ait), mit(orig.mit)
ConstIterator(Iterator const& orig)
{
map = orig.map;
ait = orig.ait;
mit = orig.mit;
}
const_reference
@@ -228,11 +231,11 @@ private:
public:
PartitionedUnorderedMap(std::optional<std::size_t> partitions = std::nullopt)
{
// Set partitions to the number of hardware threads if the parameter
// is either empty or set to 0.
: partitions_(
partitions && (*partitions != 0u) ? *partitions : std::thread::hardware_concurrency())
{
partitions_ =
partitions && (*partitions != 0u) ? *partitions : std::thread::hardware_concurrency();
map_.resize(partitions_);
XRPL_ASSERT(
partitions_,

View File

@@ -91,9 +91,8 @@ defaultPrng()
*/
/** @{ */
template <class Engine, class Integral>
Integral
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
randInt(Engine& engine, Integral min, Integral max)
requires(std::is_integral_v<Integral> && detail::is_engine<Engine>::value)
{
XRPL_ASSERT(max > min, "xrpl::randInt : max over min inputs");
@@ -104,41 +103,36 @@ randInt(Engine& engine, Integral min, Integral max)
}
template <class Integral>
Integral
std::enable_if_t<std::is_integral_v<Integral>, Integral>
randInt(Integral min, Integral max)
requires(std::is_integral_v<Integral>)
{
return randInt(defaultPrng(), min, max);
}
template <class Engine, class Integral>
Integral
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
randInt(Engine& engine, Integral max)
requires(std::is_integral_v<Integral> && detail::is_engine<Engine>::value)
{
return randInt(engine, Integral(0), max);
}
template <class Integral>
Integral
std::enable_if_t<std::is_integral_v<Integral>, Integral>
randInt(Integral max)
requires(std::is_integral_v<Integral>)
{
return randInt(defaultPrng(), max);
}
template <class Integral, class Engine>
Integral
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
randInt(Engine& engine)
requires(std::is_integral_v<Integral> && detail::is_engine<Engine>::value)
{
return randInt(engine, std::numeric_limits<Integral>::max());
}
template <class Integral = int>
Integral
std::enable_if_t<std::is_integral_v<Integral>, Integral>
randInt()
requires(std::is_integral_v<Integral>)
{
return randInt(defaultPrng(), std::numeric_limits<Integral>::max());
}
@@ -147,20 +141,19 @@ randInt()
/** Return a random byte */
/** @{ */
template <class Byte, class Engine>
Byte
std::enable_if_t<
(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>) &&
detail::is_engine<Engine>::value,
Byte>
randByte(Engine& engine)
requires(
(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>) &&
detail::is_engine<Engine>::value)
{
return static_cast<Byte>(randInt<Engine, std::uint32_t>(
engine, std::numeric_limits<Byte>::min(), std::numeric_limits<Byte>::max()));
}
template <class Byte = std::uint8_t>
Byte
std::enable_if_t<(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>), Byte>
randByte()
requires(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>)
{
return randByte<Byte>(defaultPrng());
}

View File

@@ -1,7 +1,5 @@
#pragma once
#include <xrpl/beast/utility/instrumentation.h> // IWYU pragma: keep
#include <type_traits>
namespace xrpl {
@@ -17,9 +15,8 @@ concept SafeToCast = (std::is_integral_v<Src> && std::is_integral_v<Dest>) &&
: sizeof(Dest) >= sizeof(Src));
template <class Dest, class Src>
constexpr Dest
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_integral_v<Src>, Dest>
safeCast(Src s) noexcept
requires(std::is_integral_v<Dest> && std::is_integral_v<Src>)
{
static_assert(
std::is_signed_v<Dest> || std::is_unsigned_v<Src>, "Cannot cast signed to unsigned");
@@ -31,17 +28,15 @@ safeCast(Src s) noexcept
}
template <class Dest, class Src>
constexpr Dest
constexpr std::enable_if_t<std::is_enum_v<Dest> && std::is_integral_v<Src>, Dest>
safeCast(Src s) noexcept
requires(std::is_enum_v<Dest> && std::is_integral_v<Src>)
{
return static_cast<Dest>(safeCast<std::underlying_type_t<Dest>>(s));
}
template <class Dest, class Src>
constexpr Dest
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_enum_v<Src>, Dest>
safeCast(Src s) noexcept
requires(std::is_integral_v<Dest> && std::is_enum_v<Src>)
{
return safeCast<Dest>(static_cast<std::underlying_type_t<Src>>(s));
}
@@ -51,9 +46,8 @@ safeCast(Src s) noexcept
// underlying types become safe, it can be converted to a safe_cast.
template <class Dest, class Src>
constexpr Dest
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_integral_v<Src>, Dest>
unsafeCast(Src s) noexcept
requires(std::is_integral_v<Dest> && std::is_integral_v<Src>)
{
static_assert(
!SafeToCast<Src, Dest>,
@@ -63,17 +57,15 @@ unsafeCast(Src s) noexcept
}
template <class Dest, class Src>
constexpr Dest
constexpr std::enable_if_t<std::is_enum_v<Dest> && std::is_integral_v<Src>, Dest>
unsafeCast(Src s) noexcept
requires(std::is_enum_v<Dest> && std::is_integral_v<Src>)
{
return static_cast<Dest>(unsafeCast<std::underlying_type_t<Dest>>(s));
}
template <class Dest, class Src>
constexpr Dest
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_enum_v<Src>, Dest>
unsafeCast(Src s) noexcept
requires(std::is_integral_v<Dest> && std::is_enum_v<Src>)
{
return unsafeCast<Dest>(static_cast<std::underlying_type_t<Src>>(s));
}

View File

@@ -46,9 +46,11 @@ public:
operator=(ScopeExit&&) = delete;
template <class EFP>
explicit ScopeExit(EFP&& f) noexcept
requires(
!std::is_same_v<std::remove_cv_t<EFP>, ScopeExit> && std::is_constructible_v<EF, EFP>)
explicit ScopeExit(
EFP&& f,
std::enable_if_t<
!std::is_same_v<std::remove_cv_t<EFP>, ScopeExit> &&
std::is_constructible_v<EF, EFP>>* = 0) noexcept
: exitFunction_{std::forward<EFP>(f)}
{
static_assert(std::is_nothrow_constructible_v<EF, decltype(std::forward<EFP>(f))>);
@@ -91,9 +93,11 @@ public:
operator=(ScopeFail&&) = delete;
template <class EFP>
explicit ScopeFail(EFP&& f) noexcept
requires(
!std::is_same_v<std::remove_cv_t<EFP>, ScopeFail> && std::is_constructible_v<EF, EFP>)
explicit ScopeFail(
EFP&& f,
std::enable_if_t<
!std::is_same_v<std::remove_cv_t<EFP>, ScopeFail> &&
std::is_constructible_v<EF, EFP>>* = 0) noexcept
: exitFunction_{std::forward<EFP>(f)}
{
static_assert(std::is_nothrow_constructible_v<EF, decltype(std::forward<EFP>(f))>);
@@ -136,11 +140,12 @@ public:
operator=(ScopeSuccess&&) = delete;
template <class EFP>
explicit ScopeSuccess(EFP&& f) noexcept(
std::is_nothrow_constructible_v<EF, EFP> || std::is_nothrow_constructible_v<EF, EFP&>)
requires(
explicit ScopeSuccess(
EFP&& f,
std::enable_if_t<
!std::is_same_v<std::remove_cv_t<EFP>, ScopeSuccess> &&
std::is_constructible_v<EF, EFP>)
std::is_constructible_v<EF, EFP>>* =
0) noexcept(std::is_nothrow_constructible_v<EF, EFP> || std::is_nothrow_constructible_v<EF, EFP&>)
: exitFunction_{std::forward<EFP>(f)}
{
}

View File

@@ -43,10 +43,10 @@ public:
TaggedInteger() = default;
template <class OtherInt>
explicit constexpr TaggedInteger(OtherInt value) noexcept
requires(std::is_integral_v<OtherInt> && sizeof(OtherInt) <= sizeof(Int))
: value_(value)
template <
class OtherInt,
class = std::enable_if_t<std::is_integral_v<OtherInt> && sizeof(OtherInt) <= sizeof(Int)>>
explicit constexpr TaggedInteger(OtherInt value) noexcept : value_(value)
{
static_assert(sizeof(TaggedInteger) == sizeof(Int), "tagged_integer is adding padding");
}

View File

@@ -4,14 +4,14 @@
#include <chrono>
#include <cstddef>
#include <type_traits>
namespace beast {
/** Expire aged container items past the specified age. */
template <class AgedContainer, class Rep, class Period>
std::size_t
std::enable_if_t<IsAgedContainer<AgedContainer>::value, std::size_t>
expire(AgedContainer& c, std::chrono::duration<Rep, Period> const& age)
requires(IsAgedContainer<AgedContainer>::value)
{
std::size_t n(0);
auto const expired(c.clock().now() - age);

View File

@@ -30,19 +30,20 @@ public:
// Disable constructing a const_iterator from a non-const_iterator.
// Converting between reverse and non-reverse iterators should be explicit.
template <bool OtherIsConst, class OtherIterator>
explicit AgedContainerIterator(AgedContainerIterator<OtherIsConst, OtherIterator> const& other)
requires(
template <
bool OtherIsConst,
class OtherIterator,
class = std::enable_if_t<
(!OtherIsConst || IsConst) &&
!static_cast<bool>(std::is_same_v<Iterator, OtherIterator>))
!static_cast<bool>(std::is_same_v<Iterator, OtherIterator>)>>
explicit AgedContainerIterator(AgedContainerIterator<OtherIsConst, OtherIterator> const& other)
: iter_(other.iter_)
{
}
// Disable constructing a const_iterator from a non-const_iterator.
template <bool OtherIsConst>
template <bool OtherIsConst, class = std::enable_if_t<!OtherIsConst || IsConst>>
AgedContainerIterator(AgedContainerIterator<OtherIsConst, Iterator> const& other)
requires(!OtherIsConst || IsConst)
: iter_(other.iter_)
{
}
@@ -51,8 +52,7 @@ public:
template <bool OtherIsConst, class OtherIterator>
auto
operator=(AgedContainerIterator<OtherIsConst, OtherIterator> const& other)
-> AgedContainerIterator&
requires(!OtherIsConst || IsConst)
-> std::enable_if_t<!OtherIsConst || IsConst, AgedContainerIterator&>
{
iter_ = other.iter_;
return *this;

View File

@@ -111,9 +111,10 @@ private:
{
}
template <class... Args>
template <
class... Args,
class = std::enable_if_t<std::is_constructible_v<value_type, Args...>>>
Element(time_point const& when, Args&&... args)
requires(std::is_constructible_v<value_type, Args...>)
: value(std::forward<Args>(args)...), when(when)
{
}
@@ -359,7 +360,6 @@ private:
deleteElement(Element const* p)
{
ElementAllocatorTraits::destroy(config_.alloc(), p);
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
ElementAllocatorTraits::deallocate(config_.alloc(), const_cast<Element*>(p), 1);
}
@@ -608,25 +608,35 @@ public:
//
//--------------------------------------------------------------------------
template <class K, bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
template <
class K,
bool MaybeMulti = IsMulti,
bool MaybeMap = IsMap,
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
std::conditional_t<IsMap, T, void*>&
at(K const& k)
requires(MaybeMap && !MaybeMulti);
at(K const& k);
template <class K, bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
template <
class K,
bool MaybeMulti = IsMulti,
bool MaybeMap = IsMap,
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
std::conditional<IsMap, T, void*>::type const&
at(K const& k) const
requires(MaybeMap && !MaybeMulti);
at(K const& k) const;
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
template <
bool MaybeMulti = IsMulti,
bool MaybeMap = IsMap,
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
std::conditional_t<IsMap, T, void*>&
operator[](Key const& key)
requires(MaybeMap && !MaybeMulti);
operator[](Key const& key);
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
template <
bool MaybeMulti = IsMulti,
bool MaybeMap = IsMap,
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
std::conditional_t<IsMap, T, void*>&
operator[](Key&& key)
requires(MaybeMap && !MaybeMulti);
operator[](Key&& key);
//--------------------------------------------------------------------------
//
@@ -760,40 +770,35 @@ public:
// map, set
template <bool MaybeMulti = IsMulti>
auto
insert(value_type const& value) -> std::pair<iterator, bool>
requires(!MaybeMulti);
insert(value_type const& value) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>;
// multimap, multiset
template <bool MaybeMulti = IsMulti>
auto
insert(value_type const& value) -> iterator
requires MaybeMulti;
insert(value_type const& value) -> std::enable_if_t<MaybeMulti, iterator>;
// set
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
auto
insert(value_type&& value) -> std::pair<iterator, bool>
requires(!MaybeMulti && !MaybeMap);
insert(value_type&& value)
-> std::enable_if_t<!MaybeMulti && !MaybeMap, std::pair<iterator, bool>>;
// multiset
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
auto
insert(value_type&& value) -> iterator
requires(MaybeMulti && !MaybeMap);
insert(value_type&& value) -> std::enable_if_t<MaybeMulti && !MaybeMap, iterator>;
//---
// map, set
template <bool MaybeMulti = IsMulti>
auto
insert(const_iterator hint, value_type const& value) -> iterator
requires(!MaybeMulti);
insert(const_iterator hint, value_type const& value) -> std::enable_if_t<!MaybeMulti, iterator>;
// multimap, multiset
template <bool MaybeMulti = IsMulti>
iterator
std::enable_if_t<MaybeMulti, iterator>
insert(const_iterator /*hint*/, value_type const& value)
requires MaybeMulti
{
// VFALCO TODO Figure out how to utilize 'hint'
return insert(value);
@@ -802,14 +807,12 @@ public:
// map, set
template <bool MaybeMulti = IsMulti>
auto
insert(const_iterator hint, value_type&& value) -> iterator
requires(!MaybeMulti);
insert(const_iterator hint, value_type&& value) -> std::enable_if_t<!MaybeMulti, iterator>;
// multimap, multiset
template <bool MaybeMulti = IsMulti>
iterator
std::enable_if_t<MaybeMulti, iterator>
insert(const_iterator /*hint*/, value_type&& value)
requires MaybeMulti
{
// VFALCO TODO Figure out how to utilize 'hint'
return insert(std::move(value));
@@ -817,18 +820,20 @@ public:
// map, multimap
template <class P, bool MaybeMap = IsMap>
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>
std::enable_if_t<
MaybeMap && std::is_constructible_v<value_type, P&&>,
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
insert(P&& value)
requires(MaybeMap && std::is_constructible_v<value_type, P &&>)
{
return emplace(std::forward<P>(value));
}
// map, multimap
template <class P, bool MaybeMap = IsMap>
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>
std::enable_if_t<
MaybeMap && std::is_constructible_v<value_type, P&&>,
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
insert(const_iterator hint, P&& value)
requires(MaybeMap && std::is_constructible_v<value_type, P &&>)
{
return emplaceHint(hint, std::forward<P>(value));
}
@@ -850,45 +855,46 @@ public:
// map, set
template <bool MaybeMulti = IsMulti, class... Args>
auto
emplace(Args&&... args) -> std::pair<iterator, bool>
requires(!MaybeMulti);
emplace(Args&&... args) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>;
// multiset, multimap
template <bool MaybeMulti = IsMulti, class... Args>
auto
emplace(Args&&... args) -> iterator
requires MaybeMulti;
emplace(Args&&... args) -> std::enable_if_t<MaybeMulti, iterator>;
// map, set
template <bool MaybeMulti = IsMulti, class... Args>
auto
emplaceHint(const_iterator hint, Args&&... args) -> std::pair<iterator, bool>
requires(!MaybeMulti);
emplaceHint(const_iterator hint, Args&&... args)
-> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>;
// multiset, multimap
template <bool MaybeMulti = IsMulti, class... Args>
iterator
std::enable_if_t<MaybeMulti, iterator>
emplaceHint(const_iterator /*hint*/, Args&&... args)
requires MaybeMulti
{
// VFALCO TODO Figure out how to utilize 'hint'
return emplace<MaybeMulti>(std::forward<Args>(args)...);
}
// The constraint prevents erase (reverse_iterator pos) from compiling
template <bool IsConst, class Iterator>
// enable_if prevents erase (reverse_iterator pos) from compiling
template <
bool IsConst,
class Iterator,
class = std::enable_if_t<!IsBoostReverseIterator<Iterator>::value>>
beast::detail::AgedContainerIterator<false, Iterator>
erase(beast::detail::AgedContainerIterator<IsConst, Iterator> pos)
requires(!IsBoostReverseIterator<Iterator>::value);
erase(beast::detail::AgedContainerIterator<IsConst, Iterator> pos);
// The constraint prevents erase (reverse_iterator first, reverse_iterator last)
// enable_if prevents erase (reverse_iterator first, reverse_iterator last)
// from compiling
template <bool IsConst, class Iterator>
template <
bool IsConst,
class Iterator,
class = std::enable_if_t<!IsBoostReverseIterator<Iterator>::value>>
beast::detail::AgedContainerIterator<false, Iterator>
erase(
beast::detail::AgedContainerIterator<IsConst, Iterator> first,
beast::detail::AgedContainerIterator<IsConst, Iterator> last)
requires(!IsBoostReverseIterator<Iterator>::value);
beast::detail::AgedContainerIterator<IsConst, Iterator> last);
template <class K>
auto
@@ -899,11 +905,13 @@ public:
//--------------------------------------------------------------------------
// The constraint prevents touch (reverse_iterator pos) from compiling
template <bool IsConst, class Iterator>
// enable_if prevents touch (reverse_iterator pos) from compiling
template <
bool IsConst,
class Iterator,
class = std::enable_if_t<!IsBoostReverseIterator<Iterator>::value>>
void
touch(beast::detail::AgedContainerIterator<IsConst, Iterator> pos)
requires(!IsBoostReverseIterator<Iterator>::value)
{
touch(pos, clock().now());
}
@@ -1134,25 +1142,25 @@ public:
}
private:
// The constraint prevents erase (reverse_iterator pos, now) from compiling
template <bool IsConst, class Iterator>
// enable_if prevents erase (reverse_iterator pos, now) from compiling
template <
bool IsConst,
class Iterator,
class = std::enable_if_t<!IsBoostReverseIterator<Iterator>::value>>
void
touch(
beast::detail::AgedContainerIterator<IsConst, Iterator> pos,
clock_type::time_point const& now)
requires(!IsBoostReverseIterator<Iterator>::value);
clock_type::time_point const& now);
template <
bool MaybePropagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
void
swapData(AgedOrderedContainer& other) noexcept
requires MaybePropagate;
std::enable_if_t<MaybePropagate>
swapData(AgedOrderedContainer& other) noexcept;
template <
bool MaybePropagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
void
swapData(AgedOrderedContainer& other) noexcept
requires(!MaybePropagate);
std::enable_if_t<!MaybePropagate>
swapData(AgedOrderedContainer& other) noexcept;
private:
ConfigT config_;
@@ -1361,10 +1369,9 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operato
//------------------------------------------------------------------------------
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
template <class K, bool MaybeMulti, bool MaybeMap>
template <class K, bool MaybeMulti, bool MaybeMap, class>
std::conditional_t<IsMap, T, void*>&
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K const& k)
requires(MaybeMap && !MaybeMulti)
{
auto const iter(cont_.find(k, std::cref(config_.keyCompare())));
if (iter == cont_.end())
@@ -1373,10 +1380,9 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K co
}
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
template <class K, bool MaybeMulti, bool MaybeMap>
template <class K, bool MaybeMulti, bool MaybeMap, class>
std::conditional<IsMap, T, void*>::type const&
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K const& k) const
requires(MaybeMap && !MaybeMulti)
{
auto const iter(cont_.find(k, std::cref(config_.keyCompare())));
if (iter == cont_.end())
@@ -1385,10 +1391,9 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K co
}
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
template <bool MaybeMulti, bool MaybeMap>
template <bool MaybeMulti, bool MaybeMap, class>
std::conditional_t<IsMap, T, void*>&
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operator[](Key const& key)
requires(MaybeMap && !MaybeMulti)
{
typename cont_type::insert_commit_data d;
auto const result(cont_.insert_check(key, std::cref(config_.keyCompare()), d));
@@ -1404,10 +1409,9 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operato
}
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
template <bool MaybeMulti, bool MaybeMap>
template <bool MaybeMulti, bool MaybeMap, class>
std::conditional_t<IsMap, T, void*>&
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operator[](Key&& key)
requires(MaybeMap && !MaybeMulti)
{
typename cont_type::insert_commit_data d;
auto const result(cont_.insert_check(key, std::cref(config_.keyCompare()), d));
@@ -1441,8 +1445,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
template <bool MaybeMulti>
auto
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
value_type const& value) -> std::pair<iterator, bool>
requires(!MaybeMulti)
value_type const& value) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>
{
typename cont_type::insert_commit_data d;
auto const result(cont_.insert_check(extract(value), std::cref(config_.keyCompare()), d));
@@ -1461,8 +1464,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
template <bool MaybeMulti>
auto
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
value_type const& value) -> iterator
requires MaybeMulti
value_type const& value) -> std::enable_if_t<MaybeMulti, iterator>
{
auto const before(cont_.upper_bound(extract(value), std::cref(config_.keyCompare())));
Element* const p(newElement(value));
@@ -1476,8 +1478,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
template <bool MaybeMulti, bool MaybeMap>
auto
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(value_type&& value)
-> std::pair<iterator, bool>
requires(!MaybeMulti && !MaybeMap)
-> std::enable_if_t<!MaybeMulti && !MaybeMap, std::pair<iterator, bool>>
{
typename cont_type::insert_commit_data d;
auto const result(cont_.insert_check(extract(value), std::cref(config_.keyCompare()), d));
@@ -1496,8 +1497,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
template <bool MaybeMulti, bool MaybeMap>
auto
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(value_type&& value)
-> iterator
requires(MaybeMulti && !MaybeMap)
-> std::enable_if_t<MaybeMulti && !MaybeMap, iterator>
{
auto const before(cont_.upper_bound(extract(value), std::cref(config_.keyCompare())));
Element* const p(newElement(std::move(value)));
@@ -1514,8 +1514,7 @@ template <bool MaybeMulti>
auto
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
const_iterator hint,
value_type const& value) -> iterator
requires(!MaybeMulti)
value_type const& value) -> std::enable_if_t<!MaybeMulti, iterator>
{
typename cont_type::insert_commit_data d;
auto const result(
@@ -1536,8 +1535,7 @@ template <bool MaybeMulti>
auto
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
const_iterator hint,
value_type&& value) -> iterator
requires(!MaybeMulti)
value_type&& value) -> std::enable_if_t<!MaybeMulti, iterator>
{
typename cont_type::insert_commit_data d;
auto const result(
@@ -1557,8 +1555,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
template <bool MaybeMulti, class... Args>
auto
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace(Args&&... args)
-> std::pair<iterator, bool>
requires(!MaybeMulti)
-> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>
{
// VFALCO NOTE Its unfortunate that we need to
// construct element here
@@ -1580,8 +1577,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
template <bool MaybeMulti, class... Args>
auto
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace(Args&&... args)
-> iterator
requires MaybeMulti
-> std::enable_if_t<MaybeMulti, iterator>
{
Element* const p(newElement(std::forward<Args>(args)...));
auto const before(cont_.upper_bound(extract(p->value), std::cref(config_.keyCompare())));
@@ -1596,8 +1592,7 @@ template <bool MaybeMulti, class... Args>
auto
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplaceHint(
const_iterator hint,
Args&&... args) -> std::pair<iterator, bool>
requires(!MaybeMulti)
Args&&... args) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>
{
// VFALCO NOTE Its unfortunate that we need to
// construct element here
@@ -1616,23 +1611,21 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace
}
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
template <bool IsConst, class Iterator>
template <bool IsConst, class Iterator, class>
beast::detail::AgedContainerIterator<false, Iterator>
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::erase(
beast::detail::AgedContainerIterator<IsConst, Iterator> pos)
requires(!IsBoostReverseIterator<Iterator>::value)
{
unlinkAndDeleteElement(&*((pos++).iterator()));
return beast::detail::AgedContainerIterator<false, Iterator>(pos.iterator());
}
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
template <bool IsConst, class Iterator>
template <bool IsConst, class Iterator, class>
beast::detail::AgedContainerIterator<false, Iterator>
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::erase(
beast::detail::AgedContainerIterator<IsConst, Iterator> first,
beast::detail::AgedContainerIterator<IsConst, Iterator> last)
requires(!IsBoostReverseIterator<Iterator>::value)
{
for (; first != last;)
unlinkAndDeleteElement(&*((first++).iterator()));
@@ -1735,12 +1728,11 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operato
//------------------------------------------------------------------------------
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
template <bool IsConst, class Iterator>
template <bool IsConst, class Iterator, class>
void
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::touch(
beast::detail::AgedContainerIterator<IsConst, Iterator> pos,
clock_type::time_point const& now)
requires(!IsBoostReverseIterator<Iterator>::value)
{
auto& e(*pos.iterator());
e.when = now;
@@ -1750,10 +1742,9 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::touch(
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
template <bool MaybePropagate>
void
std::enable_if_t<MaybePropagate>
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swapData(
AgedOrderedContainer& other) noexcept
requires MaybePropagate
{
std::swap(config_.keyCompare(), other.config_.keyCompare());
std::swap(config_.alloc(), other.config_.alloc());
@@ -1762,10 +1753,9 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swapDat
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
template <bool MaybePropagate>
void
std::enable_if_t<!MaybePropagate>
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swapData(
AgedOrderedContainer& other) noexcept
requires(!MaybePropagate)
{
std::swap(config_.keyCompare(), other.config_.keyCompare());
std::swap(config_.clock, other.config_.clock);

View File

@@ -117,9 +117,10 @@ private:
{
}
template <class... Args>
template <
class... Args,
class = std::enable_if_t<std::is_constructible_v<value_type, Args...>>>
Element(time_point const& when, Args&&... args)
requires(std::is_constructible_v<value_type, Args...>)
: value(std::forward<Args>(args)...), when(when)
{
}
@@ -528,7 +529,6 @@ private:
deleteElement(Element const* p)
{
ElementAllocatorTraits::destroy(config_.alloc(), p);
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
ElementAllocatorTraits::deallocate(config_.alloc(), const_cast<Element*>(p), 1);
}
@@ -841,25 +841,35 @@ public:
//
//--------------------------------------------------------------------------
template <class K, bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
template <
class K,
bool MaybeMulti = IsMulti,
bool MaybeMap = IsMap,
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
std::conditional_t<IsMap, T, void*>&
at(K const& k)
requires(MaybeMap && !MaybeMulti);
at(K const& k);
template <class K, bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
template <
class K,
bool MaybeMulti = IsMulti,
bool MaybeMap = IsMap,
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
std::conditional<IsMap, T, void*>::type const&
at(K const& k) const
requires(MaybeMap && !MaybeMulti);
at(K const& k) const;
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
template <
bool MaybeMulti = IsMulti,
bool MaybeMap = IsMap,
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
std::conditional_t<IsMap, T, void*>&
operator[](Key const& key)
requires(MaybeMap && !MaybeMulti);
operator[](Key const& key);
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
template <
bool MaybeMulti = IsMulti,
bool MaybeMap = IsMap,
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
std::conditional_t<IsMap, T, void*>&
operator[](Key&& key)
requires(MaybeMap && !MaybeMulti);
operator[](Key&& key);
//--------------------------------------------------------------------------
//
@@ -957,32 +967,28 @@ public:
// map, set
template <bool MaybeMulti = IsMulti>
auto
insert(value_type const& value) -> std::pair<iterator, bool>
requires(!MaybeMulti);
insert(value_type const& value) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>;
// multimap, multiset
template <bool MaybeMulti = IsMulti>
auto
insert(value_type const& value) -> iterator
requires MaybeMulti;
insert(value_type const& value) -> std::enable_if_t<MaybeMulti, iterator>;
// map, set
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
auto
insert(value_type&& value) -> std::pair<iterator, bool>
requires(!MaybeMulti && !MaybeMap);
insert(value_type&& value)
-> std::enable_if_t<!MaybeMulti && !MaybeMap, std::pair<iterator, bool>>;
// multimap, multiset
template <bool MaybeMulti = IsMulti, bool MaybeMap = IsMap>
auto
insert(value_type&& value) -> iterator
requires(MaybeMulti && !MaybeMap);
insert(value_type&& value) -> std::enable_if_t<MaybeMulti && !MaybeMap, iterator>;
// map, set
template <bool MaybeMulti = IsMulti>
iterator
std::enable_if_t<!MaybeMulti, iterator>
insert(const_iterator /*hint*/, value_type const& value)
requires(!MaybeMulti)
{
// Hint is ignored but we provide the interface so
// callers may use ordered and unordered interchangeably.
@@ -991,9 +997,8 @@ public:
// multimap, multiset
template <bool MaybeMulti = IsMulti>
iterator
std::enable_if_t<MaybeMulti, iterator>
insert(const_iterator /*hint*/, value_type const& value)
requires MaybeMulti
{
// VFALCO TODO The hint could be used to let
// the client order equal ranges
@@ -1002,9 +1007,8 @@ public:
// map, set
template <bool MaybeMulti = IsMulti>
iterator
std::enable_if_t<!MaybeMulti, iterator>
insert(const_iterator /*hint*/, value_type&& value)
requires(!MaybeMulti)
{
// Hint is ignored but we provide the interface so
// callers may use ordered and unordered interchangeably.
@@ -1013,9 +1017,8 @@ public:
// multimap, multiset
template <bool MaybeMulti = IsMulti>
iterator
std::enable_if_t<MaybeMulti, iterator>
insert(const_iterator /*hint*/, value_type&& value)
requires MaybeMulti
{
// VFALCO TODO The hint could be used to let
// the client order equal ranges
@@ -1024,18 +1027,20 @@ public:
// map, multimap
template <class P, bool MaybeMap = IsMap>
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>
std::enable_if_t<
MaybeMap && std::is_constructible_v<value_type, P&&>,
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
insert(P&& value)
requires(MaybeMap && std::is_constructible_v<value_type, P &&>)
{
return emplace(std::forward<P>(value));
}
// map, multimap
template <class P, bool MaybeMap = IsMap>
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>
std::enable_if_t<
MaybeMap && std::is_constructible_v<value_type, P&&>,
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
insert(const_iterator hint, P&& value)
requires(MaybeMap && std::is_constructible_v<value_type, P &&>)
{
return emplaceHint(hint, std::forward<P>(value));
}
@@ -1056,26 +1061,23 @@ public:
// set, map
template <bool MaybeMulti = IsMulti, class... Args>
auto
emplace(Args&&... args) -> std::pair<iterator, bool>
requires(!MaybeMulti);
emplace(Args&&... args) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>;
// multiset, multimap
template <bool MaybeMulti = IsMulti, class... Args>
auto
emplace(Args&&... args) -> iterator
requires MaybeMulti;
emplace(Args&&... args) -> std::enable_if_t<MaybeMulti, iterator>;
// set, map
template <bool MaybeMulti = IsMulti, class... Args>
auto
emplaceHint(const_iterator /*hint*/, Args&&... args) -> std::pair<iterator, bool>
requires(!MaybeMulti);
emplaceHint(const_iterator /*hint*/, Args&&... args)
-> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>;
// multiset, multimap
template <bool MaybeMulti = IsMulti, class... Args>
iterator
std::enable_if_t<MaybeMulti, iterator>
emplaceHint(const_iterator /*hint*/, Args&&... args)
requires MaybeMulti
{
// VFALCO TODO The hint could be used for multi, to let
// the client order equal ranges
@@ -1306,7 +1308,7 @@ public:
class OtherHash,
class OtherAllocator,
bool MaybeMulti = IsMulti>
bool
std::enable_if_t<!MaybeMulti, bool>
operator==(AgedUnorderedContainer<
false,
OtherIsMap,
@@ -1315,8 +1317,7 @@ public:
OtherDuration,
OtherHash,
KeyEqual,
OtherAllocator> const& other) const
requires(!MaybeMulti);
OtherAllocator> const& other) const;
template <
bool OtherIsMap,
@@ -1326,7 +1327,7 @@ public:
class OtherHash,
class OtherAllocator,
bool MaybeMulti = IsMulti>
bool
std::enable_if_t<MaybeMulti, bool>
operator==(AgedUnorderedContainer<
true,
OtherIsMap,
@@ -1335,8 +1336,7 @@ public:
OtherDuration,
OtherHash,
KeyEqual,
OtherAllocator> const& other) const
requires MaybeMulti;
OtherAllocator> const& other) const;
template <
bool OtherIsMulti,
@@ -1381,14 +1381,13 @@ private:
// map, set
template <bool MaybeMulti = IsMulti>
auto
insertUnchecked(value_type const& value) -> std::pair<iterator, bool>
requires(!MaybeMulti);
insertUnchecked(value_type const& value)
-> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>;
// multimap, multiset
template <bool MaybeMulti = IsMulti>
auto
insertUnchecked(value_type const& value) -> iterator
requires MaybeMulti;
insertUnchecked(value_type const& value) -> std::enable_if_t<MaybeMulti, iterator>;
template <class InputIt>
void
@@ -1429,9 +1428,8 @@ private:
template <
bool MaybePropagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
void
std::enable_if_t<MaybePropagate>
swapData(AgedUnorderedContainer& other) noexcept
requires MaybePropagate
{
std::swap(config_.hashFunction(), other.config_.hashFunction());
std::swap(config_.keyEq(), other.config_.keyEq());
@@ -1441,9 +1439,8 @@ private:
template <
bool MaybePropagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
void
std::enable_if_t<!MaybePropagate>
swapData(AgedUnorderedContainer& other) noexcept
requires(!MaybePropagate)
{
std::swap(config_.hashFunction(), other.config_.hashFunction());
std::swap(config_.keyEq(), other.config_.keyEq());
@@ -2097,10 +2094,9 @@ template <
class Hash,
class KeyEqual,
class Allocator>
template <class K, bool MaybeMulti, bool MaybeMap>
template <class K, bool MaybeMulti, bool MaybeMap, class>
std::conditional_t<IsMap, T, void*>&
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::at(K const& k)
requires(MaybeMap && !MaybeMulti)
{
auto const iter(
cont_.find(k, std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual())));
@@ -2118,11 +2114,10 @@ template <
class Hash,
class KeyEqual,
class Allocator>
template <class K, bool MaybeMulti, bool MaybeMap>
template <class K, bool MaybeMulti, bool MaybeMap, class>
std::conditional<IsMap, T, void*>::type const&
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::at(
K const& k) const
requires(MaybeMap && !MaybeMulti)
{
auto const iter(
cont_.find(k, std::cref(config_.hashFunction()), std::cref(config_.keyValueEqual())));
@@ -2140,11 +2135,10 @@ template <
class Hash,
class KeyEqual,
class Allocator>
template <bool MaybeMulti, bool MaybeMap>
template <bool MaybeMulti, bool MaybeMap, class>
std::conditional_t<IsMap, T, void*>&
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator[](
Key const& key)
requires(MaybeMap && !MaybeMulti)
{
maybeRehash(1);
typename cont_type::insert_commit_data d;
@@ -2170,11 +2164,10 @@ template <
class Hash,
class KeyEqual,
class Allocator>
template <bool MaybeMulti, bool MaybeMap>
template <bool MaybeMulti, bool MaybeMap, class>
std::conditional_t<IsMap, T, void*>&
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator[](
Key&& key)
requires(MaybeMap && !MaybeMulti)
{
maybeRehash(1);
typename cont_type::insert_commit_data d;
@@ -2227,8 +2220,7 @@ template <
template <bool MaybeMulti>
auto
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
value_type const& value) -> std::pair<iterator, bool>
requires(!MaybeMulti)
value_type const& value) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>
{
maybeRehash(1);
typename cont_type::insert_commit_data d;
@@ -2257,8 +2249,7 @@ template <
template <bool MaybeMulti>
auto
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
value_type const& value) -> iterator
requires MaybeMulti
value_type const& value) -> std::enable_if_t<MaybeMulti, iterator>
{
maybeRehash(1);
Element* const p(newElement(value));
@@ -2280,8 +2271,7 @@ template <
template <bool MaybeMulti, bool MaybeMap>
auto
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
value_type&& value) -> std::pair<iterator, bool>
requires(!MaybeMulti && !MaybeMap)
value_type&& value) -> std::enable_if_t<!MaybeMulti && !MaybeMap, std::pair<iterator, bool>>
{
maybeRehash(1);
typename cont_type::insert_commit_data d;
@@ -2310,8 +2300,7 @@ template <
template <bool MaybeMulti, bool MaybeMap>
auto
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
value_type&& value) -> iterator
requires(MaybeMulti && !MaybeMap)
value_type&& value) -> std::enable_if_t<MaybeMulti && !MaybeMap, iterator>
{
maybeRehash(1);
Element* const p(newElement(std::move(value)));
@@ -2320,6 +2309,7 @@ AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>
return iterator(iter);
}
#if 1 // Use insert() instead of insert_check() insert_commit()
// set, map
template <
bool IsMulti,
@@ -2333,8 +2323,7 @@ template <
template <bool MaybeMulti, class... Args>
auto
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace(
Args&&... args) -> std::pair<iterator, bool>
requires(!MaybeMulti)
Args&&... args) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>
{
maybeRehash(1);
// VFALCO NOTE Its unfortunate that we need to
@@ -2349,6 +2338,42 @@ AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>
deleteElement(p);
return std::make_pair(iterator(result.first), false);
}
#else // As original, use insert_check() / insert_commit () pair.
// set, map
template <
bool IsMulti,
bool IsMap,
class Key,
class T,
class Clock,
class Hash,
class KeyEqual,
class Allocator>
template <bool maybe_multi, class... Args>
auto
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace(
Args&&... args) -> typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
{
maybe_rehash(1);
// VFALCO NOTE Its unfortunate that we need to
// construct element here
element* const p(new_element(std::forward<Args>(args)...));
typename cont_type::insert_commit_data d;
auto const result(m_cont.insert_check(
extract(p->value),
std::cref(m_config.hashFunction()),
std::cref(m_config.keyValueEqual()),
d));
if (result.second)
{
auto const iter(m_cont.insert_commit(*p, d));
chronological.list.push_back(*p);
return std::make_pair(iterator(iter), true);
}
delete_element(p);
return std::make_pair(iterator(result.first), false);
}
#endif // 0
// multiset, multimap
template <
@@ -2363,8 +2388,7 @@ template <
template <bool MaybeMulti, class... Args>
auto
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace(
Args&&... args) -> iterator
requires MaybeMulti
Args&&... args) -> std::enable_if_t<MaybeMulti, iterator>
{
maybeRehash(1);
Element* const p(newElement(std::forward<Args>(args)...));
@@ -2387,8 +2411,7 @@ template <bool MaybeMulti, class... Args>
auto
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplaceHint(
const_iterator /*hint*/,
Args&&... args) -> std::pair<iterator, bool>
requires(!MaybeMulti)
Args&&... args) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>
{
maybeRehash(1);
// VFALCO NOTE Its unfortunate that we need to
@@ -2539,7 +2562,7 @@ template <
class OtherHash,
class OtherAllocator,
bool MaybeMulti>
bool
std::enable_if_t<!MaybeMulti, bool>
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator==(
AgedUnorderedContainer<
false,
@@ -2550,7 +2573,6 @@ AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>
OtherHash,
KeyEqual,
OtherAllocator> const& other) const
requires(!MaybeMulti)
{
if (size() != other.size())
return false;
@@ -2580,7 +2602,7 @@ template <
class OtherHash,
class OtherAllocator,
bool MaybeMulti>
bool
std::enable_if_t<MaybeMulti, bool>
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator==(
AgedUnorderedContainer<
true,
@@ -2591,7 +2613,6 @@ AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>
OtherHash,
KeyEqual,
OtherAllocator> const& other) const
requires MaybeMulti
{
if (size() != other.size())
return false;
@@ -2628,8 +2649,7 @@ template <
template <bool MaybeMulti>
auto
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insertUnchecked(
value_type const& value) -> std::pair<iterator, bool>
requires(!MaybeMulti)
value_type const& value) -> std::enable_if_t<!MaybeMulti, std::pair<iterator, bool>>
{
typename cont_type::insert_commit_data d;
auto const result(cont_.insert_check(
@@ -2657,8 +2677,7 @@ template <
template <bool MaybeMulti>
auto
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insertUnchecked(
value_type const& value) -> iterator
requires MaybeMulti
value_type const& value) -> std::enable_if_t<MaybeMulti, iterator>
{
Element* const p(newElement(value));
chronological.list_.push_back(*p);

View File

@@ -29,18 +29,16 @@ struct LexicalCast<std::string, In>
explicit LexicalCast() = default;
template <class Arithmetic = In>
bool
std::enable_if_t<std::is_arithmetic_v<Arithmetic>, bool>
operator()(std::string& out, Arithmetic in)
requires(std::is_arithmetic_v<Arithmetic>)
{
out = std::to_string(in);
return true;
}
template <class Enumeration = In>
bool
std::enable_if_t<std::is_enum_v<Enumeration>, bool>
operator()(std::string& out, Enumeration in)
requires(std::is_enum_v<Enumeration>)
{
out = std::to_string(static_cast<std::underlying_type_t<Enumeration>>(in));
return true;
@@ -58,9 +56,8 @@ struct LexicalCast<Out, std::string_view>
"beast::LexicalCast can only be used with integral types");
template <class Integral = Out>
bool
std::enable_if_t<std::is_integral_v<Integral> && !std::is_same_v<Integral, bool>, bool>
operator()(Integral& out, std::string_view in) const
requires(std::is_integral_v<Integral> && !std::is_same_v<Integral, bool>)
{
auto first = in.data();
auto last = in.data() + in.size();

View File

@@ -41,7 +41,7 @@ public:
operator=(NodePtr node)
{
node_ = node;
return *this;
return static_cast<LockFreeStackIterator&>(*this);
}
LockFreeStackIterator&

View File

@@ -26,7 +26,7 @@ template <class T>
inline void
reverseBytes(T& t)
{
auto* bytes =
unsigned char* bytes =
static_cast<unsigned char*>(std::memmove(std::addressof(t), std::addressof(t), sizeof(T)));
for (unsigned i = 0; i < sizeof(T) / 2; ++i)
std::swap(bytes[i], bytes[sizeof(T) - 1 - i]);
@@ -200,29 +200,26 @@ struct IsContiguouslyHashable<T[N], HashAlgorithm>
// scalars
template <class Hasher, class T>
inline void
inline std::enable_if_t<IsContiguouslyHashable<T, Hasher>::value>
hash_append(Hasher& h, T const& t) noexcept
requires(IsContiguouslyHashable<T, Hasher>::value)
{
// NOLINTNEXTLINE(bugprone-sizeof-expression)
h(static_cast<void const*>(std::addressof(t)), sizeof(t));
}
template <class Hasher, class T>
inline void
inline std::enable_if_t<
!IsContiguouslyHashable<T, Hasher>::value &&
(std::is_integral_v<T> || std::is_pointer_v<T> || std::is_enum_v<T>)>
hash_append(Hasher& h, T t) noexcept
requires(
!IsContiguouslyHashable<T, Hasher>::value &&
(std::is_integral_v<T> || std::is_pointer_v<T> || std::is_enum_v<T>))
{
detail::reverseBytes(t);
h(std::addressof(t), sizeof(t));
}
template <class Hasher, class T>
inline void
inline std::enable_if_t<std::is_floating_point_v<T>>
hash_append(Hasher& h, T t) noexcept
requires(std::is_floating_point_v<T>)
{
if (t == 0)
t = 0;
@@ -242,44 +239,36 @@ hash_append(Hasher& h, std::nullptr_t) noexcept
// Forward declarations for ADL purposes
template <class Hasher, class T, std::size_t N>
void
hash_append(Hasher& h, T (&a)[N]) noexcept
requires(!IsContiguouslyHashable<T, Hasher>::value);
std::enable_if_t<!IsContiguouslyHashable<T, Hasher>::value>
hash_append(Hasher& h, T (&a)[N]) noexcept;
template <class Hasher, class CharT, class Traits, class Alloc>
void
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept
requires(!IsContiguouslyHashable<CharT, Hasher>::value);
std::enable_if_t<!IsContiguouslyHashable<CharT, Hasher>::value>
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept;
template <class Hasher, class CharT, class Traits, class Alloc>
void
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept
requires(IsContiguouslyHashable<CharT, Hasher>::value);
std::enable_if_t<IsContiguouslyHashable<CharT, Hasher>::value>
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept;
template <class Hasher, class T, class U>
void
hash_append(Hasher& h, std::pair<T, U> const& p) noexcept
requires(!IsContiguouslyHashable<std::pair<T, U>, Hasher>::value);
std::enable_if_t<!IsContiguouslyHashable<std::pair<T, U>, Hasher>::value>
hash_append(Hasher& h, std::pair<T, U> const& p) noexcept;
template <class Hasher, class T, class Alloc>
void
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
requires(!IsContiguouslyHashable<T, Hasher>::value);
std::enable_if_t<!IsContiguouslyHashable<T, Hasher>::value>
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept;
template <class Hasher, class T, class Alloc>
void
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
requires(IsContiguouslyHashable<T, Hasher>::value);
std::enable_if_t<IsContiguouslyHashable<T, Hasher>::value>
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept;
template <class Hasher, class T, std::size_t N>
void
hash_append(Hasher& h, std::array<T, N> const& a) noexcept
requires(!IsContiguouslyHashable<std::array<T, N>, Hasher>::value);
std::enable_if_t<!IsContiguouslyHashable<std::array<T, N>, Hasher>::value>
hash_append(Hasher& h, std::array<T, N> const& a) noexcept;
template <class Hasher, class... T>
void
hash_append(Hasher& h, std::tuple<T...> const& t) noexcept
requires(!IsContiguouslyHashable<std::tuple<T...>, Hasher>::value);
std::enable_if_t<!IsContiguouslyHashable<std::tuple<T...>, Hasher>::value>
hash_append(Hasher& h, std::tuple<T...> const& t) noexcept;
template <class Hasher, class Key, class T, class Hash, class Pred, class Alloc>
void
@@ -290,13 +279,11 @@ void
hash_append(Hasher& h, std::unordered_set<Key, Hash, Pred, Alloc> const& s);
template <class Hasher, class Key, class Compare, class Alloc>
void
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept
requires(!IsContiguouslyHashable<Key, Hasher>::value);
std::enable_if_t<!IsContiguouslyHashable<Key, Hasher>::value>
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept;
template <class Hasher, class Key, class Compare, class Alloc>
void
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept
requires(IsContiguouslyHashable<Key, Hasher>::value);
std::enable_if_t<IsContiguouslyHashable<Key, Hasher>::value>
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept;
template <class Hasher, class T0, class T1, class... T>
void
hash_append(Hasher& h, T0 const& t0, T1 const& t1, T const&... t) noexcept;
@@ -304,9 +291,8 @@ hash_append(Hasher& h, T0 const& t0, T1 const& t1, T const&... t) noexcept;
// c-array
template <class Hasher, class T, std::size_t N>
void
std::enable_if_t<!IsContiguouslyHashable<T, Hasher>::value>
hash_append(Hasher& h, T (&a)[N]) noexcept
requires(!IsContiguouslyHashable<T, Hasher>::value)
{
for (auto const& t : a)
hash_append(h, t);
@@ -315,9 +301,8 @@ hash_append(Hasher& h, T (&a)[N]) noexcept
// basic_string
template <class Hasher, class CharT, class Traits, class Alloc>
inline void
inline std::enable_if_t<!IsContiguouslyHashable<CharT, Hasher>::value>
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept
requires(!IsContiguouslyHashable<CharT, Hasher>::value)
{
for (auto c : s)
hash_append(h, c);
@@ -325,9 +310,8 @@ hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcep
}
template <class Hasher, class CharT, class Traits, class Alloc>
inline void
inline std::enable_if_t<IsContiguouslyHashable<CharT, Hasher>::value>
hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcept
requires(IsContiguouslyHashable<CharT, Hasher>::value)
{
h(s.data(), s.size() * sizeof(CharT));
hash_append(h, s.size());
@@ -336,9 +320,8 @@ hash_append(Hasher& h, std::basic_string<CharT, Traits, Alloc> const& s) noexcep
// pair
template <class Hasher, class T, class U>
inline void
inline std::enable_if_t<!IsContiguouslyHashable<std::pair<T, U>, Hasher>::value>
hash_append(Hasher& h, std::pair<T, U> const& p) noexcept
requires(!IsContiguouslyHashable<std::pair<T, U>, Hasher>::value)
{
hash_append(h, p.first, p.second);
}
@@ -346,9 +329,8 @@ hash_append(Hasher& h, std::pair<T, U> const& p) noexcept
// vector
template <class Hasher, class T, class Alloc>
inline void
inline std::enable_if_t<!IsContiguouslyHashable<T, Hasher>::value>
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
requires(!IsContiguouslyHashable<T, Hasher>::value)
{
for (auto const& t : v)
hash_append(h, t);
@@ -356,9 +338,8 @@ hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
}
template <class Hasher, class T, class Alloc>
inline void
inline std::enable_if_t<IsContiguouslyHashable<T, Hasher>::value>
hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
requires(IsContiguouslyHashable<T, Hasher>::value)
{
h(v.data(), v.size() * sizeof(T));
hash_append(h, v.size());
@@ -367,37 +348,57 @@ hash_append(Hasher& h, std::vector<T, Alloc> const& v) noexcept
// array
template <class Hasher, class T, std::size_t N>
void
std::enable_if_t<!IsContiguouslyHashable<std::array<T, N>, Hasher>::value>
hash_append(Hasher& h, std::array<T, N> const& a) noexcept
requires(!IsContiguouslyHashable<std::array<T, N>, Hasher>::value)
{
for (auto const& t : a)
hash_append(h, t);
}
template <class Hasher, class Key, class Compare, class Alloc>
void
std::enable_if_t<!IsContiguouslyHashable<Key, Hasher>::value>
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept
requires(!IsContiguouslyHashable<Key, Hasher>::value)
{
for (auto const& t : v)
hash_append(h, t);
}
template <class Hasher, class Key, class Compare, class Alloc>
void
std::enable_if_t<IsContiguouslyHashable<Key, Hasher>::value>
hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v) noexcept
requires(IsContiguouslyHashable<Key, Hasher>::value)
{
h(&(v.begin()), v.size() * sizeof(Key));
}
// tuple
template <class Hasher, class... T>
namespace detail {
inline void
hash_append(Hasher& h, std::tuple<T...> const& t) noexcept
requires(!IsContiguouslyHashable<std::tuple<T...>, Hasher>::value)
forEachItem(...) noexcept
{
std::apply([&h](auto const&... item) { (hash_append(h, item), ...); }, t);
}
template <class Hasher, class T>
inline int
hashOne(Hasher& h, T const& t) noexcept
{
hash_append(h, t);
return 0;
}
template <class Hasher, class... T, std::size_t... I>
inline void
tuple_hash(Hasher& h, std::tuple<T...> const& t, std::index_sequence<I...>) noexcept
{
for_each_item(hash_one(h, std::get<I>(t))...);
}
} // namespace detail
template <class Hasher, class... T>
inline std::enable_if_t<!IsContiguouslyHashable<std::tuple<T...>, Hasher>::value>
hash_append(Hasher& h, std::tuple<T...> const& t) noexcept
{
detail::tuple_hash(h, t, std::index_sequence_for<T...>{});
}
// shared_ptr

View File

@@ -124,18 +124,14 @@ public:
}
}
template <class Seed>
explicit Xxhasher(Seed seed)
requires(std::is_unsigned_v<Seed>)
: seed_(seed)
template <class Seed, std::enable_if_t<std::is_unsigned_v<Seed>>* = nullptr>
explicit Xxhasher(Seed seed) : seed_(seed)
{
resetBuffers();
}
template <class Seed>
Xxhasher(Seed seed, Seed)
requires(std::is_unsigned_v<Seed>)
: seed_(seed)
template <class Seed, std::enable_if_t<std::is_unsigned_v<Seed>>* = nullptr>
Xxhasher(Seed seed, Seed) : seed_(seed)
{
resetBuffers();
}

View File

@@ -49,11 +49,6 @@ public:
impl_->set(value);
}
// This is a write-through handle: assignment sets the value of the
// referenced metric. It is const-qualified and returns Gauge const&
// (a non-const Gauge& would require a const_cast), so it does not follow
// the conventional assignment-operator signature.
// NOLINTNEXTLINE(misc-unconventional-assign-operator)
Gauge const&
operator=(value_type value) const
{

View File

@@ -23,7 +23,6 @@ typeName()
if (auto s = abi::__cxa_demangle(name.c_str(), nullptr, nullptr, nullptr))
{
name = s;
// NOLINTNEXTLINE(cppcoreguidelines-no-malloc)
std::free(s);
}
#endif

View File

@@ -10,9 +10,9 @@
#include <boost/assert.hpp>
#include <set>
#include <string> // IWYU pragma: keep
#include <typeindex> // IWYU pragma: keep
#include <unordered_set> // IWYU pragma: keep
#include <string>
#include <typeindex>
#include <unordered_set>
namespace beast::unit_test {

View File

@@ -45,10 +45,7 @@ public:
template <class F, class... Args>
explicit Thread(Suite& s, F&& f, Args&&... args) : s_(&s)
{
std::function<void(void)> b = [f = std::forward<F>(f),
... args = std::forward<Args>(args)]() mutable {
std::invoke(f, args...);
};
std::function<void(void)> b = std::bind(std::forward<F>(f), std::forward<Args>(args)...);
t_ = std::thread(&Thread::run, this, std::move(b));
}

View File

@@ -108,12 +108,12 @@ public:
};
#ifndef __INTELLISENSE__
static_assert(!std::is_default_constructible_v<Sink>);
static_assert(!std::is_copy_constructible_v<Sink>);
static_assert(!std::is_move_constructible_v<Sink>);
static_assert(!std::is_copy_assignable_v<Sink>);
static_assert(!std::is_move_assignable_v<Sink>);
static_assert(std::is_nothrow_destructible_v<Sink>);
static_assert(!std::is_default_constructible_v<Sink>, "");
static_assert(!std::is_copy_constructible_v<Sink>, "");
static_assert(!std::is_move_constructible_v<Sink>, "");
static_assert(!std::is_copy_assignable_v<Sink>, "");
static_assert(!std::is_move_assignable_v<Sink>, "");
static_assert(std::is_nothrow_destructible_v<Sink>, "");
#endif
/** Returns a Sink which does nothing. */
@@ -164,12 +164,12 @@ public:
};
#ifndef __INTELLISENSE__
static_assert(!std::is_default_constructible_v<ScopedStream>);
static_assert(std::is_copy_constructible_v<ScopedStream>);
static_assert(std::is_move_constructible_v<ScopedStream>);
static_assert(!std::is_copy_assignable_v<ScopedStream>);
static_assert(!std::is_move_assignable_v<ScopedStream>);
static_assert(std::is_nothrow_destructible_v<ScopedStream>);
static_assert(!std::is_default_constructible_v<ScopedStream>, "");
static_assert(std::is_copy_constructible_v<ScopedStream>, "");
static_assert(std::is_move_constructible_v<ScopedStream>, "");
static_assert(!std::is_copy_assignable_v<ScopedStream>, "");
static_assert(!std::is_move_assignable_v<ScopedStream>, "");
static_assert(std::is_nothrow_destructible_v<ScopedStream>, "");
#endif
//--------------------------------------------------------------------------
@@ -246,12 +246,12 @@ public:
};
#ifndef __INTELLISENSE__
static_assert(std::is_default_constructible_v<Stream>);
static_assert(std::is_copy_constructible_v<Stream>);
static_assert(std::is_move_constructible_v<Stream>);
static_assert(!std::is_copy_assignable_v<Stream>);
static_assert(!std::is_move_assignable_v<Stream>);
static_assert(std::is_nothrow_destructible_v<Stream>);
static_assert(std::is_default_constructible_v<Stream>, "");
static_assert(std::is_copy_constructible_v<Stream>, "");
static_assert(std::is_move_constructible_v<Stream>, "");
static_assert(!std::is_copy_assignable_v<Stream>, "");
static_assert(!std::is_move_assignable_v<Stream>, "");
static_assert(std::is_nothrow_destructible_v<Stream>, "");
#endif
//--------------------------------------------------------------------------
@@ -329,12 +329,12 @@ public:
};
#ifndef __INTELLISENSE__
static_assert(!std::is_default_constructible_v<Journal>);
static_assert(std::is_copy_constructible_v<Journal>);
static_assert(std::is_move_constructible_v<Journal>);
static_assert(std::is_copy_assignable_v<Journal>);
static_assert(std::is_move_assignable_v<Journal>);
static_assert(std::is_nothrow_destructible_v<Journal>);
static_assert(!std::is_default_constructible_v<Journal>, "");
static_assert(std::is_copy_constructible_v<Journal>, "");
static_assert(std::is_move_constructible_v<Journal>, "");
static_assert(std::is_copy_assignable_v<Journal>, "");
static_assert(std::is_move_assignable_v<Journal>, "");
static_assert(std::is_nothrow_destructible_v<Journal>, "");
#endif
//------------------------------------------------------------------------------

View File

@@ -26,7 +26,9 @@ struct Zero
explicit Zero() = default;
};
inline constexpr Zero kZero{};
namespace {
constexpr Zero kZero{};
} // namespace
/** Default implementation of signum calls the method on the class. */
template <typename T>

View File

@@ -3,6 +3,7 @@
#include <array>
#include <cstdint>
#include <cstring>
#include <type_traits>
namespace beast {
@@ -13,7 +14,7 @@ rngfill(void* const buffer, std::size_t const bytes, Generator& g)
using result_type = Generator::result_type;
constexpr std::size_t kResultSize = sizeof(result_type);
auto* const bufferStart = static_cast<std::uint8_t*>(buffer);
std::uint8_t* const bufferStart = static_cast<std::uint8_t*>(buffer);
std::size_t const completeIterations = bytes / kResultSize;
std::size_t const bytesRemaining = bytes % kResultSize;
@@ -32,14 +33,16 @@ rngfill(void* const buffer, std::size_t const bytes, Generator& g)
}
}
template <class Generator, std::size_t N>
template <
class Generator,
std::size_t N,
class = std::enable_if_t<N % sizeof(typename Generator::result_type) == 0>>
void
rngfill(std::array<std::uint8_t, N>& a, Generator& g)
requires(N % sizeof(typename Generator::result_type) == 0)
{
using result_type = Generator::result_type;
auto i = N / sizeof(result_type);
auto* p = reinterpret_cast<result_type*>(a.data());
result_type* p = reinterpret_cast<result_type*>(a.data());
while (i--)
*p++ = g();
}

View File

@@ -127,7 +127,7 @@ private:
}
[[nodiscard]] HashRouterFlags
getFlags() const
getFlags(void) const
{
return flags_;
}

View File

@@ -154,14 +154,16 @@ public:
@param type The type of job.
@param name Name of the job.
@param jobHandler Callable with signature void(). Called when the job is executed.
@param jobHandler Lambda with signature void (Job&). Called when the
job is executed.
@return true if jobHandler added to queue.
*/
template <typename JobHandler>
template <
typename JobHandler,
typename = std::enable_if_t<std::is_same_v<decltype(std::declval<JobHandler&&>()()), void>>>
bool
addJob(JobType type, std::string const& name, JobHandler&& jobHandler)
requires(std::is_void_v<std::invoke_result_t<JobHandler>>)
{
if (auto optionalCountedJob = jobCounter_.wrap(std::forward<JobHandler>(jobHandler)))
{

View File

@@ -118,7 +118,7 @@ public:
[[nodiscard]] JobTypeInfo const&
get(JobType jt) const
{
auto const iter = map.find(jt);
Map::const_iterator const iter(map.find(jt));
XRPL_ASSERT(iter != map.end(), "xrpl::JobTypes::get : valid input");
if (iter != map.end())

View File

@@ -154,7 +154,7 @@ private:
Location end,
unsigned int& unicode);
bool
addError(std::string const& message, Token& token, Location extra = nullptr);
addError(std::string const& message, Token& token, Location extra = 0);
bool
recoverFromError(TokenType skipUntilToken);
bool

View File

@@ -5,12 +5,13 @@
#include <xrpl/beast/utility/instrumentation.h>
#include <xrpl/ledger/ReadView.h>
#include <xrpl/protocol/AccountID.h>
#include <xrpl/protocol/Issue.h> // IWYU pragma: keep
#include <xrpl/protocol/Issue.h>
#include <xrpl/protocol/Keylet.h>
#include <xrpl/protocol/LedgerFormats.h>
#include <xrpl/protocol/MPTIssue.h>
#include <xrpl/protocol/STAmount.h>
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STVector256.h>
#include <cstdint>
@@ -411,6 +412,12 @@ public:
emptyDirDelete(Keylet const& directory);
};
struct ApplyViewContext
{
ApplyView& view;
STTx const& tx;
};
namespace directory {
/** Helper functions for managing low-level directory operations.
These are not part of the ApplyView interface.

View File

@@ -141,7 +141,7 @@ template <class Base>
class CachedView : public detail::CachedViewImpl
{
private:
static_assert(std::is_base_of_v<DigestAwareReadView, Base>);
static_assert(std::is_base_of_v<DigestAwareReadView, Base>, "");
std::shared_ptr<Base const> sp_;

View File

@@ -82,7 +82,7 @@ private:
using txs_map = std::map<
key_type,
TxData,
std::less<>,
std::less<key_type>,
boost::container::pmr::polymorphic_allocator<std::pair<key_type const, TxData>>>;
// monotonic_resource_ must outlive `items_`. Make a pointer so it may be

View File

@@ -7,7 +7,7 @@
#include <xrpl/ledger/detail/ReadViewFwdRange.h>
#include <xrpl/protocol/AccountID.h>
#include <xrpl/protocol/Fees.h>
#include <xrpl/protocol/Issue.h> // IWYU pragma: keep
#include <xrpl/protocol/Issue.h>
#include <xrpl/protocol/Keylet.h>
#include <xrpl/protocol/LedgerHeader.h>
#include <xrpl/protocol/MPTIssue.h>

View File

@@ -210,8 +210,7 @@ canWithdraw(ReadView const& view, STTx const& tx);
[[nodiscard]] TER
doWithdraw(
ApplyView& view,
STTx const& tx,
ApplyViewContext ctx,
AccountID const& senderAcct,
AccountID const& dstAcct,
AccountID const& sourceAcct,

View File

@@ -105,7 +105,7 @@ private:
using items_t = std::map<
key_type,
SleAction,
std::less<>,
std::less<key_type>,
boost::container::pmr::polymorphic_allocator<std::pair<key_type const, SleAction>>>;
// monotonic_resource_ must outlive `items_`. Make a pointer so it may be
// easily moved.

View File

@@ -108,8 +108,8 @@ public:
std::optional<value_type> mutable cache_;
};
static_assert(std::is_nothrow_move_constructible<Iterator>{});
static_assert(std::is_nothrow_move_assignable<Iterator>{});
static_assert(std::is_nothrow_move_constructible<Iterator>{}, "");
static_assert(std::is_nothrow_move_assignable<Iterator>{}, "");
using const_iterator = Iterator;

View File

@@ -14,6 +14,7 @@
#include <cstdint>
#include <expected>
#include <optional>
#include <set>
#include <vector>
@@ -26,21 +27,225 @@ namespace xrpl {
[[nodiscard]] bool
isGlobalFrozen(ReadView const& view, AccountID const& issuer);
// Calculate liquid XRP balance for an account.
// This function may be used to calculate the amount of XRP that
// the holder is able to freely spend. It subtracts reserve requirements.
//
// ownerCountAdj adjusts the owner count in case the caller calculates
// before ledger entries are added or removed. Positive to add, negative
// to subtract.
//
// @param ownerCountAdj positive to add to count, negative to reduce count.
/** Calculate liquid XRP balance for an account.
*
* This function may be used to calculate the amount of XRP that
* the holder is able to freely spend. It subtracts reserve requirements.
*
* ownerCountAdj adjusts the owner count in case the caller calculates
* before ledger entries are added or removed. Positive to add, negative
* to subtract.
*
* @param view The ledger view to read from
* @param id The account ID to check
* @param ownerCountAdj Positive to add to count, negative to reduce count
* @param j Journal for logging
* @return The liquid XRP amount available to the account
*/
[[nodiscard]] XRPAmount
xrpLiquid(ReadView const& view, AccountID const& id, std::int32_t ownerCountAdj, beast::Journal j);
/** Adjust the owner count up or down. */
struct Adjustment
{
std::int32_t ownerCountDelta = 0;
std::int32_t accountCountDelta = 0;
};
/** Returns the account reserve, in drops.
*
* Actual owner count can be adjusted by delta in ownerCountAdj
* Actual reserve count can be adjusted by delta in accountCountAdj
* The reserve is calculated as:
* (ownerCount + "sponsoring object count" - "sponsored object count" + additionalOwnerCount) *
* increment + (1 if not sponsored account + sponsoringAccountCount) * "reserve base"
*
* @param view The ledger view to read from
* @param sle The ledger entry for the account
* @param j Journal for logging
* @param ownerCountAdj Adjustment to the owner count (default: 0)
* @param accountCountAdj Adjustment to the account count (default: 0)
* @return The account reserve amount in drops
*/
[[nodiscard]] XRPAmount
accountReserve(ReadView const& view, SLE::const_ref sle, beast::Journal j, Adjustment adj = {});
/** Convenience overload that accepts AccountID instead of SLE.
*
* @param view The ledger view to read from
* @param id The account ID
* @param j Journal for logging
* @param ownerCountAdj Adjustment to the owner count (default: 0)
* @param accountCountAdj Adjustment to the account count (default: 0)
* @return The account reserve amount in drops
*/
[[nodiscard]] inline XRPAmount
accountReserve(ReadView const& view, AccountID const& id, beast::Journal j, Adjustment adj = {})
{
return accountReserve(view, view.read(keylet::account(id)), j, adj);
}
/** Check if an account has sufficient reserve.
*
* @param view The ledger view to read from
* @param tx The transaction being processed
* @param accSle The account's ledger entry
* @param accBalance The account's balance
* @param sponsorSle The sponsor's ledger entry (if applicable)
* @param ownerCountAdj Adjustment to the owner count
* @param accountCountAdj Adjustment to the account count (default: 0)
* @param j Journal for logging (default: null sink)
* @return Transaction result code
*/
[[nodiscard]] TER
checkReserve(
ApplyViewContext ctx,
SLE::const_ref accSle,
STAmount const& accBalance,
SLE::const_ref sponsorSle,
Adjustment adj,
beast::Journal j = beast::Journal{beast::Journal::getNullSink()});
/** Return number of the objects which reserve is covered by the account(sle) (so called "owner
* count"). Actual owner count can be adjusted by delta in ownerCountAdj.
*
* @param sle The account's ledger entry
* @param j Journal for logging
* @param ownerCountAdj Adjustment to the owner count (default: 0)
* @return The adjusted owner count
*/
std::uint32_t
ownerCount(SLE::const_ref sle, beast::Journal j, std::int32_t ownerCountAdj = 0);
/** Increase owner-count fields when the caller supplies the sponsor.
*
* This helper does not create a ledger object. It updates reserve accounting
* after the caller has created/updated an object.
* If sponsorSle is provided, this also adjusts the account's sponsored count
* and the sponsor's sponsoring count.
*
* @param view The apply view for making changes
* @param accountSle The account's ledger entry
* @param sponsorSle The sponsor's ledger entry (if applicable)
* @param count Amount to add to the owner count
* @param j Journal for logging
*/
void
adjustOwnerCount(ApplyView& view, SLE::ref sle, std::int32_t amount, beast::Journal j);
increaseOwnerCount(
ApplyView& view,
SLE::ref accountSle,
SLE::ref sponsorSle,
std::uint32_t count,
beast::Journal j);
/** Convenience overload that accepts AccountID instead of SLE references.
*
* @param view The apply view for making changes
* @param account The account ID
* @param sponsor The optional sponsor account ID
* @param count Amount to add to the owner count
* @param j Journal for logging
*/
inline void
increaseOwnerCount(
ApplyView& view,
AccountID const& account,
std::optional<AccountID> const& sponsor,
std::uint32_t count,
beast::Journal j)
{
increaseOwnerCount(
view,
view.peek(keylet::account(account)),
sponsor ? view.peek(keylet::account(*sponsor)) : SLE::pointer(),
count,
j);
}
/** Decrease owner-count fields when the caller supplies the sponsor.
*
* This helper does not delete a ledger object. It updates reserve accounting
* after the caller has removed an owner-counted reserve, or for special
* owner-count changes whose sponsor cannot be derived from an object's
* sfSponsor field.
*
* @param view The apply view for making changes
* @param accountSle The account's ledger entry
* @param sponsorSle The sponsor's ledger entry (if applicable)
* @param count Amount to remove from the owner count
* @param j Journal for logging
*/
void
decreaseOwnerCount(
ApplyView& view,
SLE::ref accountSle,
SLE::ref sponsorSle,
std::uint32_t count,
beast::Journal j);
/** Convenience overload that accepts AccountID instead of SLE references.
*
* @param view The apply view for making changes
* @param account The account ID
* @param sponsor The optional sponsor account ID
* @param count Amount to remove from the owner count
* @param j Journal for logging
*/
inline void
decreaseOwnerCount(
ApplyView& view,
AccountID const& account,
std::optional<AccountID> const& sponsor,
std::uint32_t count,
beast::Journal j)
{
decreaseOwnerCount(
view,
view.peek(keylet::account(account)),
sponsor ? view.peek(keylet::account(*sponsor)) : SLE::pointer(),
count,
j);
}
/** Decrease owner-count fields for an existing ledger object.
*
* This helper derives the reserve sponsor from objectSle's sfSponsor field,
* then updates the same owner-count fields as decreaseOwnerCount. Use this
* when removing an existing object whose reserve sponsor is stored on that
* object.
*
* @param view The apply view for making changes
* @param accountSle The account's ledger entry
* @param objectSle The object's ledger entry
* @param count Amount to remove from the owner count
* @param j Journal for logging
*/
void
decreaseOwnerCountForObject(
ApplyView& view,
SLE::ref accountSle,
SLE::ref objectSle,
std::uint32_t count,
beast::Journal j);
/** Convenience overload that accepts AccountID instead of account SLE reference.
*
* @param view The apply view for making changes
* @param account The account ID
* @param objectSle The object's ledger entry
* @param count Amount to remove from the owner count
* @param j Journal for logging
*/
inline void
decreaseOwnerCountForObject(
ApplyView& view,
AccountID const& account,
SLE::ref objectSle,
std::uint32_t count,
beast::Journal j)
{
SLE::ref accountSle = view.peek(keylet::account(account));
decreaseOwnerCountForObject(view, accountSle, objectSle, count, j);
}
/** Returns IOU issuer transfer fee as Rate. Rate specifies
* the fee as fractions of 1 billion. For example, 1% transfer rate
@@ -60,25 +265,25 @@ pseudoAccountAddress(ReadView const& view, uint256 const& pseudoOwnerKey);
/** Returns the list of fields that define an ACCOUNT_ROOT as a pseudo-account
if set.
The list is constructed during initialization and is const after that.
Pseudo-account designator fields MUST be maintained by including the
SField::sMD_PseudoAccount flag in the SField definition.
The list is constructed during initialization and is const after that.
Pseudo-account designator fields MUST be maintained by including the
SField::sMD_PseudoAccount flag in the SField definition.
*/
[[nodiscard]] std::vector<SField const*> const&
getPseudoAccountFields();
/** Returns true if and only if sleAcct is a pseudo-account or specific
pseudo-accounts in pseudoFieldFilter.
Returns false if sleAcct is:
- NOT a pseudo-account OR
- NOT a ltACCOUNT_ROOT OR
- null pointer
*/
[[nodiscard]] bool
isPseudoAccount(SLE::const_pointer sleAcct, std::set<SField const*> const& pseudoFieldFilter = {});
/** Convenience overload that reads the account from the view. */
[[nodiscard]] bool
isPseudoAccount(SLE::const_ref sleAcct, std::set<SField const*> const& pseudoFieldFilter = {});
/** Convenience overload that reads the account from the view.
*
* @param view The ledger view to read from
* @param accountId The account ID to check
* @param pseudoFieldFilter Optional set of specific pseudo-account fields to filter (default:
* empty)
* @return true if the account is a pseudo-account (or matches the filter), false otherwise
*/
[[nodiscard]] inline bool
isPseudoAccount(
ReadView const& view,
@@ -101,8 +306,8 @@ createPseudoAccount(ApplyView& view, uint256 const& pseudoOwnerKey, SField const
/** Checks the destination and tag.
- Checks that the SLE is not null.
- If the SLE requires a destination tag, checks that there is a tag.
- Checks that the SLE is not null.
- If the SLE requires a destination tag, checks that there is a tag.
*/
[[nodiscard]] TER
checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag);

View File

@@ -19,7 +19,11 @@ namespace xrpl {
namespace detail {
template <class V, class N>
template <
class V,
class N,
class = std::enable_if_t<
std::is_same_v<std::remove_cv_t<N>, SLE> && std::is_base_of_v<ReadView, V>>>
bool
internalDirNext(
V& view,
@@ -27,7 +31,6 @@ internalDirNext(
std::shared_ptr<N>& page,
unsigned int& index,
uint256& entry)
requires(std::is_same_v<std::remove_cv_t<N>, SLE> && std::is_base_of_v<ReadView, V>)
{
auto const& svIndexes = page->getFieldV256(sfIndexes);
XRPL_ASSERT(index <= svIndexes.size(), "xrpl::detail::internalDirNext : index inside range");
@@ -65,7 +68,11 @@ internalDirNext(
return true;
}
template <class V, class N>
template <
class V,
class N,
class = std::enable_if_t<
std::is_same_v<std::remove_cv_t<N>, SLE> && std::is_base_of_v<ReadView, V>>>
bool
internalDirFirst(
V& view,
@@ -73,7 +80,6 @@ internalDirFirst(
std::shared_ptr<N>& page,
unsigned int& index,
uint256& entry)
requires(std::is_same_v<std::remove_cv_t<N>, SLE> && std::is_base_of_v<ReadView, V>)
{
if constexpr (std::is_const_v<N>)
{

View File

@@ -6,6 +6,7 @@
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
#include <xrpl/ledger/helpers/MPTokenHelpers.h>
#include <xrpl/ledger/helpers/RippleStateHelpers.h>
#include <xrpl/ledger/helpers/SponsorHelpers.h>
#include <xrpl/ledger/helpers/TokenHelpers.h>
#include <xrpl/protocol/AccountID.h>
#include <xrpl/protocol/Concepts.h>
@@ -22,14 +23,12 @@
#include <xrpl/protocol/TER.h>
#include <xrpl/protocol/UintTypes.h>
#include <cstdint>
namespace xrpl {
template <ValidIssueType T>
TER
escrowUnlockApplyHelper(
ApplyView& view,
ApplyViewContext ctx,
Rate lockedRate,
SLE::ref sleDest,
STAmount const& xrpBalance,
@@ -43,7 +42,7 @@ escrowUnlockApplyHelper(
template <>
inline TER
escrowUnlockApplyHelper<Issue>(
ApplyView& view,
ApplyViewContext ctx,
Rate lockedRate,
SLE::ref sleDest,
STAmount const& xrpBalance,
@@ -54,7 +53,7 @@ escrowUnlockApplyHelper<Issue>(
bool createAsset,
beast::Journal journal)
{
auto const& issue = amount.get<Issue>();
Issue const& issue = amount.get<Issue>();
Keylet const trustLineKey = keylet::trustLine(receiver, issue);
bool const recvLow = issuer > receiver;
bool const senderIssuer = issuer == sender;
@@ -66,11 +65,16 @@ escrowUnlockApplyHelper<Issue>(
if (receiverIssuer)
return tesSUCCESS;
if (!view.exists(trustLineKey) && createAsset)
if (!ctx.view.exists(trustLineKey) && createAsset)
{
// Can the account cover the trust line's reserve?
if (std::uint32_t const ownerCount = {sleDest->at(sfOwnerCount)};
xrpBalance < view.fees().accountReserve(ownerCount + 1))
auto const sponsorSle = getTxReserveSponsor(ctx);
if (!sponsorSle)
return sponsorSle.error(); // LCOV_EXCL_LINE
if (auto const ret = checkReserve(
ctx, sleDest, xrpBalance, *sponsorSle, {.ownerCountDelta = 1}, journal);
!isTesSuccess(ret))
{
JLOG(journal.trace()) << "Trust line does not exist. "
"Insufficient reserve to create line.";
@@ -83,7 +87,7 @@ escrowUnlockApplyHelper<Issue>(
initialBalance.get<Issue>().account = noAccount();
if (TER const ter = trustCreate(
view, // payment sandbox
ctx.view, // payment sandbox
recvLow, // is dest low?
issuer, // source
receiver, // destination
@@ -97,19 +101,20 @@ escrowUnlockApplyHelper<Issue>(
Issue(currency, receiver), // limit of zero
0, // quality in
0, // quality out
*sponsorSle, // sponsor
journal); // journal
!isTesSuccess(ter))
{
return ter; // LCOV_EXCL_LINE
}
view.update(sleDest);
ctx.view.update(sleDest);
}
if (!view.exists(trustLineKey) && !receiverIssuer)
if (!ctx.view.exists(trustLineKey) && !receiverIssuer)
return tecNO_LINE;
auto const xferRate = transferRate(view, amount);
auto const xferRate = transferRate(ctx.view, amount);
// update if issuer rate is less than locked rate
if (xferRate < lockedRate)
lockedRate = xferRate;
@@ -137,7 +142,7 @@ escrowUnlockApplyHelper<Issue>(
// of the funds
if (!createAsset)
{
auto const sleRippleState = view.peek(trustLineKey);
auto const sleRippleState = ctx.view.peek(trustLineKey);
if (!sleRippleState)
return tecINTERNAL; // LCOV_EXCL_LINE
@@ -163,7 +168,7 @@ escrowUnlockApplyHelper<Issue>(
// if destination is not the issuer then transfer funds
if (!receiverIssuer)
{
auto const ter = directSendNoFee(view, issuer, receiver, finalAmt, true, journal);
auto const ter = directSendNoFee(ctx.view, issuer, receiver, finalAmt, true, journal);
if (!isTesSuccess(ter))
return ter; // LCOV_EXCL_LINE
}
@@ -173,7 +178,7 @@ escrowUnlockApplyHelper<Issue>(
template <>
inline TER
escrowUnlockApplyHelper<MPTIssue>(
ApplyView& view,
ApplyViewContext ctx,
Rate lockedRate,
SLE::ref sleDest,
STAmount const& xrpBalance,
@@ -189,27 +194,34 @@ escrowUnlockApplyHelper<MPTIssue>(
auto const mptID = amount.get<MPTIssue>().getMptID();
auto const issuanceKey = keylet::mptokenIssuance(mptID);
if (!view.exists(keylet::mptoken(issuanceKey.key, receiver)) && createAsset && !receiverIssuer)
auto const mptKeylet = keylet::mptoken(issuanceKey.key, receiver);
if (!ctx.view.exists(mptKeylet) && createAsset && !receiverIssuer)
{
if (std::uint32_t const ownerCount = {sleDest->at(sfOwnerCount)};
xrpBalance < view.fees().accountReserve(ownerCount + 1))
{
return tecINSUFFICIENT_RESERVE;
}
auto const sponsorSle = getTxReserveSponsor(ctx);
if (!sponsorSle)
return sponsorSle.error(); // LCOV_EXCL_LINE
if (auto const ter = createMPToken(view, mptID, receiver, 0); !isTesSuccess(ter))
if (auto const ret = checkReserve(
ctx, sleDest, xrpBalance, *sponsorSle, {.ownerCountDelta = 1}, journal);
!isTesSuccess(ret))
return ret;
if (auto const ter = createMPToken(ctx.view, mptID, receiver, *sponsorSle, 0);
!isTesSuccess(ter))
{
return ter; // LCOV_EXCL_LINE
}
// update owner count.
adjustOwnerCount(view, sleDest, 1, journal);
increaseOwnerCount(ctx.view, sleDest, *sponsorSle, 1, journal);
auto mptSle = ctx.view.peek(mptKeylet);
addSponsorToLedgerEntry(mptSle, *sponsorSle);
}
if (!view.exists(keylet::mptoken(issuanceKey.key, receiver)) && !receiverIssuer)
if (!ctx.view.exists(mptKeylet) && !receiverIssuer)
return tecNO_PERMISSION;
auto const xferRate = transferRate(view, amount);
auto const xferRate = transferRate(ctx.view, amount);
// update if issuer rate is less than locked rate
if (xferRate < lockedRate)
lockedRate = xferRate;
@@ -232,11 +244,11 @@ escrowUnlockApplyHelper<MPTIssue>(
finalAmt = amount.value() - xferFee;
}
return unlockEscrowMPT(
view,
ctx.view,
sender,
receiver,
finalAmt,
view.rules().enabled(fixTokenEscrowV1) ? amount : finalAmt,
ctx.view.rules().enabled(fixTokenEscrowV1) ? amount : finalAmt,
journal);
}

View File

@@ -8,7 +8,7 @@
#include <xrpl/ledger/ApplyView.h>
#include <xrpl/ledger/ReadView.h>
#include <xrpl/protocol/Asset.h>
#include <xrpl/protocol/LedgerFormats.h> // IWYU pragma: keep
#include <xrpl/protocol/LedgerFormats.h>
#include <xrpl/protocol/Protocol.h>
#include <xrpl/protocol/Rules.h>
#include <xrpl/protocol/SField.h>

View File

@@ -86,7 +86,7 @@ canAddHolding(ReadView const& view, MPTIssue const& mptIssue);
[[nodiscard]] TER
authorizeMPToken(
ApplyView& view,
ApplyViewContext ctx,
XRPAmount const& priorBalance,
MPTID const& mptIssuanceID,
AccountID const& account,
@@ -117,7 +117,7 @@ requireAuth(
*/
[[nodiscard]] TER
enforceMPTokenAuthorization(
ApplyView& view,
ApplyViewContext ctx,
MPTID const& mptIssuanceID,
AccountID const& account,
XRPAmount const& priorBalance,
@@ -203,7 +203,7 @@ canMPTTradeAndTransfer(
[[nodiscard]] TER
addEmptyHolding(
ApplyView& view,
ApplyViewContext ctx,
AccountID const& accountID,
XRPAmount priorBalance,
MPTIssue const& mptIssue,
@@ -211,7 +211,7 @@ addEmptyHolding(
[[nodiscard]] TER
removeEmptyHolding(
ApplyView& view,
ApplyViewContext ctx,
AccountID const& accountID,
MPTIssue const& mptIssue,
beast::Journal journal);
@@ -243,6 +243,7 @@ createMPToken(
ApplyView& view,
MPTID const& mptIssuanceID,
AccountID const& account,
SLE::ref sponsorSle,
std::uint32_t const flags);
TER
@@ -250,6 +251,7 @@ checkCreateMPT(
xrpl::ApplyView& view,
xrpl::MPTIssue const& mptIssue,
xrpl::AccountID const& holder,
SLE::ref sponsorSle,
beast::Journal j);
//------------------------------------------------------------------------------

View File

@@ -0,0 +1,19 @@
#pragma once
#include <cstddef>
#include <cstdint>
namespace xrpl {
constexpr uint32_t kMinOracleReserveCount = 1;
constexpr uint32_t kMaxOracleReserveCount = 2;
constexpr std::size_t kOracleReserveCountThreshold = 5;
inline uint32_t
calculateOracleReserve(std::size_t priceDataSeriesCount)
{
return priceDataSeriesCount > kOracleReserveCountThreshold ? kMaxOracleReserveCount
: kMinOracleReserveCount;
}
} // namespace xrpl

View File

@@ -156,6 +156,7 @@ trustCreate(
// Issuer should be the account being set.
std::uint32_t uQualityIn,
std::uint32_t uQualityOut,
SLE::ref sponsorSle,
beast::Journal j);
[[nodiscard]] TER
@@ -235,7 +236,7 @@ canTransfer(ReadView const& view, Issue const& issue, AccountID const& from, Acc
/// canAddHolding() in preflight with the same View and Asset
[[nodiscard]] TER
addEmptyHolding(
ApplyView& view,
ApplyViewContext ctx,
AccountID const& accountID,
XRPAmount priorBalance,
Issue const& issue,
@@ -243,7 +244,7 @@ addEmptyHolding(
[[nodiscard]] TER
removeEmptyHolding(
ApplyView& view,
ApplyViewContext ctx,
AccountID const& accountID,
Issue const& issue,
beast::Journal journal);

View File

@@ -0,0 +1,193 @@
#pragma once
#include <xrpl/beast/utility/instrumentation.h>
#include <xrpl/ledger/ApplyView.h>
#include <xrpl/ledger/ReadView.h>
#include <xrpl/ledger/helpers/OracleHelpers.h>
#include <xrpl/protocol/AccountID.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/LedgerFormats.h>
#include <xrpl/protocol/SField.h>
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/TER.h>
#include <xrpl/protocol/TxFlags.h>
#include <cstdint>
#include <expected>
#include <optional>
namespace xrpl {
inline bool
isFeeSponsored(STTx const& tx)
{
return (tx.getFieldU32(sfSponsorFlags) & spfSponsorFee) != 0u;
}
inline bool
isReserveSponsored(STTx const& tx)
{
return (tx.getFieldU32(sfSponsorFlags) & spfSponsorReserve) != 0u;
}
std::optional<AccountID>
getTxReserveSponsorAccountID(STTx const& tx);
std::expected<SLE::pointer, TER>
getTxReserveSponsor(ApplyViewContext ctx);
std::expected<SLE::const_pointer, TER>
getTxReserveSponsor(ReadView const& view, STTx const& tx);
std::optional<AccountID>
getLedgerEntryReserveSponsorAccountID(SLE::const_ref sle, SF_ACCOUNT const& field = sfSponsor);
SLE::pointer
getLedgerEntryReserveSponsor(
ApplyView& view,
SLE::const_ref sle,
SF_ACCOUNT const& field = sfSponsor);
SLE::const_pointer
getLedgerEntryReserveSponsor(
ReadView const& view,
SLE::const_ref sle,
SF_ACCOUNT const& field = sfSponsor);
void
addSponsorToLedgerEntry(
SLE::ref sle,
SLE::const_ref sponsorSle,
SF_ACCOUNT const& field = sfSponsor);
void
removeSponsorFromLedgerEntry(SLE::ref sle, SF_ACCOUNT const& field = sfSponsor);
template <typename T>
inline std::optional<AccountID>
getLedgerEntryOwner(ReadView const& view, T const& sle, AccountID const& account)
{
switch (sle->getType())
{
case ltCHECK:
case ltESCROW:
case ltPAYCHAN:
case ltMPTOKEN:
case ltDELEGATE:
case ltDEPOSIT_PREAUTH:
return sle->getAccountID(sfAccount);
case ltMPTOKEN_ISSUANCE:
return sle->getAccountID(sfIssuer);
case ltSIGNER_LIST: {
auto const signerList = view.read(keylet::signerList(account));
if (!signerList)
return std::nullopt;
if (signerList->key() == sle->key())
return account;
return std::nullopt;
}
case ltCREDENTIAL: {
if (sle->isFlag(lsfAccepted))
return sle->getAccountID(sfSubject);
return sle->getAccountID(sfIssuer);
}
case ltRIPPLE_STATE: {
if (sle->isFlag(lsfHighReserve))
{
auto const highAccount = sle->getFieldAmount(sfHighLimit).getIssuer();
if (highAccount == account)
return highAccount;
}
if (sle->isFlag(lsfLowReserve))
{
auto const lowAccount = sle->getFieldAmount(sfLowLimit).getIssuer();
if (lowAccount == account)
return lowAccount;
}
return std::nullopt;
}
default:
UNREACHABLE("Object is not supported by sponsorship.");
return std::nullopt;
};
}
template <typename T>
inline bool
isLedgerEntrySupportedBySponsorship(T const& sle)
{
switch (sle->getType())
{
case ltCHECK:
case ltESCROW:
case ltPAYCHAN:
case ltMPTOKEN:
case ltDELEGATE:
case ltDEPOSIT_PREAUTH:
case ltMPTOKEN_ISSUANCE:
case ltSIGNER_LIST:
case ltCREDENTIAL:
case ltRIPPLE_STATE:
return true;
default:
return false;
};
}
template <typename T>
inline std::uint32_t
getLedgerEntryOwnerCount(T const& sle)
{
switch (sle->getType())
{
case ltORACLE: {
return calculateOracleReserve(sle->getFieldArray(sfPriceDataSeries).size());
}
// Vaults require 2 owner counts (the vault and a pseudo-account)
case ltVAULT:
return 2;
case ltSIGNER_LIST: {
// Mirror SignerListSet's owner-count accounting so that create and
// delete agree. Modern lists (post-MultiSignReserve) carry the
// lsfOneOwnerCount flag and cost a single owner count. Legacy
// pre-MultiSignReserve lists cost 2 + signer_count owner counts
if (sle->isFlag(lsfOneOwnerCount))
return 1;
return 2 + static_cast<std::uint32_t>(sle->getFieldArray(sfSignerEntries).size());
}
default:
return 1;
}
};
template <typename T>
inline SF_ACCOUNT const&
getLedgerEntrySponsorField(T const& sle, AccountID const& owner)
{
switch (sle->getType())
{
case ltRIPPLE_STATE: {
if (sle->isFlag(lsfHighReserve))
{
auto const highAccount = sle->getFieldAmount(sfHighLimit).getIssuer();
if (highAccount == owner)
return sfHighSponsor;
}
if (sle->isFlag(lsfLowReserve))
{
auto const lowAccount = sle->getFieldAmount(sfLowLimit).getIssuer();
if (lowAccount == owner)
return sfLowSponsor;
}
// LCOV_EXCL_START
UNREACHABLE("Should not happen. Owner should be checked before calling this function.");
return sfSponsor;
// LCOV_EXCL_STOP
}
default:
return sfSponsor;
}
};
} // namespace xrpl

View File

@@ -10,6 +10,7 @@
#include <xrpl/protocol/MPTIssue.h>
#include <xrpl/protocol/Rate.h>
#include <xrpl/protocol/STAmount.h>
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/TER.h>
#include <xrpl/protocol/UintTypes.h>
#include <xrpl/protocol/XRPAmount.h>
@@ -302,7 +303,7 @@ canAddHolding(ReadView const& view, Asset const& asset);
[[nodiscard]] TER
addEmptyHolding(
ApplyView& view,
ApplyViewContext ctx,
AccountID const& accountID,
XRPAmount priorBalance,
Asset const& asset,
@@ -310,7 +311,7 @@ addEmptyHolding(
[[nodiscard]] TER
removeEmptyHolding(
ApplyView& view,
ApplyViewContext ctx,
AccountID const& accountID,
Asset const& asset,
beast::Journal journal);
@@ -371,6 +372,7 @@ accountSend(
AccountID const& to,
STAmount const& saAmount,
beast::Journal j,
SLE::ref sponsorSle = {},
WaiveTransferFee waiveFee = WaiveTransferFee::No,
AllowMPTOverflow allowOverflow = AllowMPTOverflow::No);
@@ -388,6 +390,7 @@ accountSendMulti(
Asset const& asset,
MultiplePaymentDestinations const& receivers,
beast::Journal j,
SLE::ref sponsorSle,
WaiveTransferFee waiveFee = WaiveTransferFee::No);
[[nodiscard]] TER

View File

@@ -120,9 +120,12 @@ public:
socket_->next_layer().async_receive(
boost::asio::buffer(buffer_),
boost::asio::socket_base::message_peek,
[this, cbFunc](error_code const& ec, size_t bytesTransferred) {
handleAutodetect(cbFunc, ec, bytesTransferred);
});
std::bind(
&AutoSocket::handleAutodetect,
this,
cbFunc,
std::placeholders::_1,
std::placeholders::_2));
}
}

View File

@@ -13,6 +13,7 @@
#include <openssl/err.h>
#include <openssl/tls1.h>
#include <functional>
#include <stdexcept>
#include <string>
#include <type_traits>
@@ -83,12 +84,13 @@ public:
*
* @return error_code indicating failures, if any
*/
template <class T>
template <
class T,
class = std::enable_if_t<
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> ||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>>>>
boost::system::error_code
preConnectVerify(T& strm, std::string const& host)
requires(
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> ||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>>)
{
boost::system::error_code ec;
if (!SSL_set_tlsext_host_name(strm.native_handle(), host.c_str()))
@@ -102,7 +104,11 @@ public:
return ec;
}
template <class T>
template <
class T,
class = std::enable_if_t<
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> ||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>>>>
/**
* @brief invoked after connect/async_connect but before sending data
* on an ssl stream - to setup name verification.
@@ -112,9 +118,6 @@ public:
*/
boost::system::error_code
postConnectVerify(T& strm, std::string const& host)
requires(
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> ||
std::is_same_v<T, boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>>)
{
boost::system::error_code ec;
@@ -124,9 +127,8 @@ public:
if (!ec)
{
strm.set_verify_callback(
[host, j = j_](bool preverified, boost::asio::ssl::verify_context& ctx) {
return rfc6125Verify(host, preverified, ctx, j);
},
std::bind(
&rfc6125Verify, host, std::placeholders::_1, std::placeholders::_2, j_),
ec);
}
}

View File

@@ -34,11 +34,11 @@ public:
createObject();
private:
bool success_{false};
bool success_;
void const* key_;
NodeObjectType objectType_{NodeObjectType::Unknown};
unsigned char const* objectData_{nullptr};
NodeObjectType objectType_;
unsigned char const* objectData_;
int dataBytes_;
};

View File

@@ -62,7 +62,7 @@ lz4Compress(void const* in, std::size_t inSize, BufferFactory&& bf)
std::array<std::uint8_t, varint_traits<std::size_t>::kMax> vi{};
auto const n = writeVarint(vi.data(), inSize);
auto const outMax = LZ4_compressBound(inSize);
auto* out = reinterpret_cast<std::uint8_t*>(bf(n + outMax));
std::uint8_t* out = reinterpret_cast<std::uint8_t*>(bf(n + outMax));
result.first = out;
std::memcpy(out, vi.data(), n);
auto const outSize = LZ4_compress_default(
@@ -90,7 +90,7 @@ nodeobjectDecompress(void const* in, std::size_t inSize, BufferFactory&& bf)
{
using namespace nudb::detail;
auto const* p = reinterpret_cast<std::uint8_t const*>(in);
std::uint8_t const* p = reinterpret_cast<std::uint8_t const*>(in);
std::size_t type = 0;
auto const vn = readVarint(p, inSize, type);
if (vn == 0)
@@ -237,7 +237,7 @@ nodeobjectCompress(void const* in, std::size_t inSize, BufferFactory&& bf)
auto const vs = sizeVarint(type);
result.second = vs + field<std::uint16_t>::size + // mask
(n * 32); // hashes
auto* out = reinterpret_cast<std::uint8_t*>(bf(result.second));
std::uint8_t* out = reinterpret_cast<std::uint8_t*>(bf(result.second));
result.first = out;
ostream os(out, result.second);
write<varint>(os, type);
@@ -249,7 +249,7 @@ nodeobjectCompress(void const* in, std::size_t inSize, BufferFactory&& bf)
auto const type = 3U;
auto const vs = sizeVarint(type);
result.second = vs + (n * 32); // hashes
auto* out = reinterpret_cast<std::uint8_t*>(bf(result.second));
std::uint8_t* out = reinterpret_cast<std::uint8_t*>(bf(result.second));
result.first = out;
ostream os(out, result.second);
write<varint>(os, type);

View File

@@ -39,7 +39,7 @@ readVarint(void const* buf, std::size_t buflen, std::size_t& t)
if (buflen == 0)
return 0;
t = 0;
auto const* p = reinterpret_cast<std::uint8_t const*>(buf);
std::uint8_t const* p = reinterpret_cast<std::uint8_t const*>(buf);
std::size_t n = 0;
while (p[n] & 0x80)
{
@@ -68,10 +68,9 @@ readVarint(void const* buf, std::size_t buflen, std::size_t& t)
return used;
}
template <class T>
template <class T, std::enable_if_t<std::is_unsigned_v<T>>* = nullptr>
std::size_t
sizeVarint(T v)
requires(std::is_unsigned_v<T>)
{
std::size_t n = 0;
do
@@ -87,7 +86,7 @@ std::size_t
writeVarint(void* p0, std::size_t v)
{
// NOLINTNEXTLINE(misc-const-correctness)
auto* p = reinterpret_cast<std::uint8_t*>(p0);
std::uint8_t* p = reinterpret_cast<std::uint8_t*>(p0);
do
{
std::uint8_t d = v % 127;
@@ -101,10 +100,9 @@ writeVarint(void* p0, std::size_t v)
// input stream
template <class T>
template <class T, std::enable_if_t<std::is_same_v<T, varint>>* = nullptr>
void
read(nudb::detail::istream& is, std::size_t& u)
requires(std::is_same_v<T, varint>)
{
auto p0 = is(1);
auto p1 = p0;
@@ -115,10 +113,9 @@ read(nudb::detail::istream& is, std::size_t& u)
// output stream
template <class T>
template <class T, std::enable_if_t<std::is_same_v<T, varint>>* = nullptr>
void
write(nudb::detail::ostream& os, std::size_t t)
requires(std::is_same_v<T, varint>)
{
writeVarint(os.data(sizeVarint(t)), t);
}

View File

@@ -13,7 +13,7 @@
#include <xrpl/protocol/XRPAmount.h>
#include <cstdint>
#include <limits> // IWYU pragma: keep
#include <limits>
#include <stdexcept>
#include <type_traits>

View File

@@ -2,7 +2,6 @@
#include <xrpl/protocol/XRPAmount.h>
#include <cstddef>
#include <cstdint>
namespace xrpl {
@@ -39,13 +38,13 @@ struct Fees
/** Returns the account reserve given the owner count, in drops.
The reserve is calculated as the reserve base plus
the reserve increment times the number of increments.
The reserve is calculated as the reserve base times the number of accounts plus the reserve
increment times the number of increments.
*/
[[nodiscard]] XRPAmount
accountReserve(std::size_t ownerCount) const
accountReserve(std::uint32_t ownerCount, std::uint32_t accountCount) const
{
return reserve + ownerCount * increment;
return (reserve * accountCount) + (increment * ownerCount);
}
};

View File

@@ -142,6 +142,10 @@ ticket(uint256 const& key)
Keylet
signerList(AccountID const& account) noexcept;
/** A Sponsorship */
Keylet
sponsorship(AccountID const& sponsor, AccountID const& sponsee) noexcept;
/** A Check */
/** @{ */
Keylet

View File

@@ -208,7 +208,11 @@ enum LedgerEntryType : std::uint16_t {
LEDGER_OBJECT(Loan, \
LSF_FLAG(lsfLoanDefault, 0x00010000) \
LSF_FLAG(lsfLoanImpaired, 0x00020000) \
LSF_FLAG(lsfLoanOverpayment, 0x00040000)) /* True, loan allows overpayments */
LSF_FLAG(lsfLoanOverpayment, 0x00040000)) /* True, loan allows overpayments */ \
\
LEDGER_OBJECT(Sponsorship, \
LSF_FLAG(lsfSponsorshipRequireSignForFee, 0x00010000) \
LSF_FLAG(lsfSponsorshipRequireSignForReserve, 0x00020000))
// clang-format on

View File

@@ -282,7 +282,7 @@ public:
auto const maxVMantissa = mantissa(maxV);
auto const expDiff = exponent(maxV) - exponent(minV);
auto const minVD = static_cast<double>(minVMantissa);
double const minVD = static_cast<double>(minVMantissa);
double const maxVD =
(expDiff != 0) ? maxVMantissa * pow(10, expDiff) : static_cast<double>(maxVMantissa);

View File

@@ -32,13 +32,17 @@ public:
STArray() = default;
STArray(STArray const&) = default;
template <class Iter>
explicit STArray(Iter first, Iter last)
requires(std::is_convertible_v<typename std::iterator_traits<Iter>::reference, STObject>);
template <
class Iter,
class = std::enable_if_t<
std::is_convertible_v<typename std::iterator_traits<Iter>::reference, STObject>>>
explicit STArray(Iter first, Iter last);
template <class Iter>
STArray(SField const& f, Iter first, Iter last)
requires(std::is_convertible_v<typename std::iterator_traits<Iter>::reference, STObject>);
template <
class Iter,
class = std::enable_if_t<
std::is_convertible_v<typename std::iterator_traits<Iter>::reference, STObject>>>
STArray(SField const& f, Iter first, Iter last);
STArray&
operator=(STArray const&) = default;
@@ -166,17 +170,13 @@ private:
friend class detail::STVar;
};
template <class Iter>
STArray::STArray(Iter first, Iter last)
requires(std::is_convertible_v<typename std::iterator_traits<Iter>::reference, STObject>)
: v_(first, last)
template <class Iter, class>
STArray::STArray(Iter first, Iter last) : v_(first, last)
{
}
template <class Iter>
STArray::STArray(SField const& f, Iter first, Iter last)
requires(std::is_convertible_v<typename std::iterator_traits<Iter>::reference, STObject>)
: STBase(f), v_(first, last)
template <class Iter, class>
STArray::STArray(SField const& f, Iter first, Iter last) : STBase(f), v_(first, last)
{
}

View File

@@ -148,7 +148,7 @@ template <int Bits>
bool
STBitString<Bits>::isEquivalent(STBase const& t) const
{
auto const* v = dynamic_cast<STBitString const*>(&t);
STBitString const* v = dynamic_cast<STBitString const*>(&t);
return v && (value_ == v->value_);
}

View File

@@ -115,7 +115,7 @@ template <typename Integer>
inline bool
STInteger<Integer>::isEquivalent(STBase const& t) const
{
auto const* v = dynamic_cast<STInteger const*>(&t);
STInteger const* v = dynamic_cast<STInteger const*>(&t);
return v && (value_ == v->value_);
}

View File

@@ -229,10 +229,10 @@ public:
[[nodiscard]] AccountID
getAccountID(SField const& field) const;
/** The account responsible for the fee and authorization: the delegate when
/** The account responsible for the authorization: the delegate when
sfDelegate is present, otherwise the account. */
[[nodiscard]] AccountID
getFeePayer() const;
getInitiator() const;
[[nodiscard]] Blob
getFieldVL(SField const& field) const;
@@ -555,14 +555,9 @@ public:
ValueProxy&
operator=(ValueProxy const&) = delete;
// Write-through proxy: assignment sets the referenced field to the given
// value, so it intentionally takes the assigned value rather than a
// ValueProxy.
template <class U>
// NOLINTNEXTLINE(misc-unconventional-assign-operator)
ValueProxy&
operator=(U&& u)
requires(std::is_assignable_v<T, U>);
std::enable_if_t<std::is_assignable_v<T, U>, ValueProxy&>
operator=(U&& u);
// Convenience operators for value types supporting
// arithmetic operations
@@ -696,9 +691,8 @@ public:
operator=(optional_type const& v);
template <class U>
OptionalProxy&
operator=(U&& u)
requires(std::is_assignable_v<T, U>);
std::enable_if_t<std::is_assignable_v<T, U>, OptionalProxy&>
operator=(U&& u);
private:
friend class STObject;
@@ -804,10 +798,8 @@ STObject::Proxy<T>::assign(U&& u)
template <class T>
template <class U>
// NOLINTNEXTLINE(misc-unconventional-assign-operator)
STObject::ValueProxy<T>&
std::enable_if_t<std::is_assignable_v<T, U>, STObject::ValueProxy<T>&>
STObject::ValueProxy<T>::operator=(U&& u)
requires(std::is_assignable_v<T, U>)
{
this->assign(std::forward<U>(u));
return *this;
@@ -910,9 +902,8 @@ STObject::OptionalProxy<T>::operator=(optional_type const& v) -> OptionalProxy&
template <class T>
template <class U>
STObject::OptionalProxy<T>&
std::enable_if_t<std::is_assignable_v<T, U>, STObject::OptionalProxy<T>&>
STObject::OptionalProxy<T>::operator=(U&& u)
requires(std::is_assignable_v<T, U>)
{
this->assign(std::forward<U>(u));
return *this;
@@ -1250,7 +1241,7 @@ template <typename T, typename V>
void
STObject::setFieldUsingSetValue(SField const& field, V value)
{
static_assert(!std::is_lvalue_reference_v<V>);
static_assert(!std::is_lvalue_reference_v<V>, "");
STBase* rf = getPField(field, true);

View File

@@ -240,9 +240,6 @@ private:
inline STPathElement::STPathElement() : type_(TypeNone), isOffer_(true)
{
// hashValue_ is derived from the whole object, so it is computed in the body
// once every other member is initialized (as in the other constructors).
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
hashValue_ = getHash(*this);
}
@@ -318,9 +315,6 @@ inline STPathElement::STPathElement(
assetID_.visit(
[&](Currency const&) { type_ = type_ & (~Type::TypeMpt); },
[&](MPTID const&) { type_ = type_ & (~Type::TypeCurrency); });
// hashValue_ must be computed after type_ is adjusted above, so this cannot
// be a member initializer.
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
hashValue_ = getHash(*this);
}

View File

@@ -141,6 +141,9 @@ public:
[[nodiscard]] std::vector<uint256> const&
getBatchTransactionIDs() const;
[[nodiscard]] AccountID
getFeePayerID() const;
private:
/** Check the signature.
@param rules The current ledger rules.

View File

@@ -334,7 +334,7 @@ public:
template <int N>
explicit SerialIter(std::uint8_t const (&data)[N]) : SerialIter(&data[0], N)
{
static_assert(N > 0);
static_assert(N > 0, "");
}
[[nodiscard]] bool

View File

@@ -225,6 +225,7 @@ enum TERcodes : TERUnderlyingType {
// create a pseudo-account
terNO_DELEGATE_PERMISSION, // Delegate does not have permission
terLOCKED, // MPT is locked
terNO_SPONSORSHIP, // No sponsorship found
};
//------------------------------------------------------------------------------
@@ -368,6 +369,7 @@ enum TECcodes : TERUnderlyingType {
// reclaimed after those networks reset.
tecNO_DELEGATE_PERMISSION = 198,
tecBAD_PROOF = 199,
tecNO_SPONSOR_PERMISSION = 200,
};
//------------------------------------------------------------------------------
@@ -411,7 +413,7 @@ TERtoInt(TECcodes v)
//------------------------------------------------------------------------------
// Template class that is specific to selected ranges of error codes. The
// Trait tells the requires-clause which ranges are allowed.
// Trait tells std::enable_if which ranges are allowed.
template <template <typename> class Trait>
class TERSubset
{
@@ -437,11 +439,11 @@ public:
return TERSubset(from);
}
// Trait tells the requires-clause which types are allowed for construction.
template <typename T>
constexpr TERSubset(T rhs)
requires(Trait<std::remove_cv_t<std::remove_reference_t<T>>>::value)
: code_(TERtoInt(rhs))
// Trait tells enable_if which types are allowed for construction.
template <
typename T,
typename = std::enable_if_t<Trait<std::remove_cv_t<std::remove_reference_t<T>>>::value>>
constexpr TERSubset(T rhs) : code_(TERtoInt(rhs))
{
}
@@ -451,11 +453,10 @@ public:
constexpr TERSubset&
operator=(TERSubset&& rhs) = default;
// Trait tells the requires-clause which types are allowed for assignment.
// Trait tells enable_if which types are allowed for assignment.
template <typename T>
constexpr auto
operator=(T rhs) -> TERSubset&
requires(Trait<T>::value)
operator=(T rhs) -> std::enable_if_t<Trait<T>::value, TERSubset&>
{
code_ = TERtoInt(rhs);
return *this;
@@ -509,60 +510,54 @@ public:
// Only enabled if both arguments return int if TERtiInt is called with them.
template <typename L, typename R>
constexpr auto
operator==(L const& lhs, R const& rhs) -> bool
requires(
std::is_same_v<decltype(TERtoInt(lhs)), int> &&
std::is_same_v<decltype(TERtoInt(rhs)), int>)
operator==(L const& lhs, R const& rhs) -> std::enable_if_t<
std::is_same_v<decltype(TERtoInt(lhs)), int> && std::is_same_v<decltype(TERtoInt(rhs)), int>,
bool>
{
return TERtoInt(lhs) == TERtoInt(rhs);
}
template <typename L, typename R>
constexpr auto
operator!=(L const& lhs, R const& rhs) -> bool
requires(
std::is_same_v<decltype(TERtoInt(lhs)), int> &&
std::is_same_v<decltype(TERtoInt(rhs)), int>)
operator!=(L const& lhs, R const& rhs) -> std::enable_if_t<
std::is_same_v<decltype(TERtoInt(lhs)), int> && std::is_same_v<decltype(TERtoInt(rhs)), int>,
bool>
{
return TERtoInt(lhs) != TERtoInt(rhs);
}
template <typename L, typename R>
constexpr auto
operator<(L const& lhs, R const& rhs) -> bool
requires(
std::is_same_v<decltype(TERtoInt(lhs)), int> &&
std::is_same_v<decltype(TERtoInt(rhs)), int>)
operator<(L const& lhs, R const& rhs) -> std::enable_if_t<
std::is_same_v<decltype(TERtoInt(lhs)), int> && std::is_same_v<decltype(TERtoInt(rhs)), int>,
bool>
{
return TERtoInt(lhs) < TERtoInt(rhs);
}
template <typename L, typename R>
constexpr auto
operator<=(L const& lhs, R const& rhs) -> bool
requires(
std::is_same_v<decltype(TERtoInt(lhs)), int> &&
std::is_same_v<decltype(TERtoInt(rhs)), int>)
operator<=(L const& lhs, R const& rhs) -> std::enable_if_t<
std::is_same_v<decltype(TERtoInt(lhs)), int> && std::is_same_v<decltype(TERtoInt(rhs)), int>,
bool>
{
return TERtoInt(lhs) <= TERtoInt(rhs);
}
template <typename L, typename R>
constexpr auto
operator>(L const& lhs, R const& rhs) -> bool
requires(
std::is_same_v<decltype(TERtoInt(lhs)), int> &&
std::is_same_v<decltype(TERtoInt(rhs)), int>)
operator>(L const& lhs, R const& rhs) -> std::enable_if_t<
std::is_same_v<decltype(TERtoInt(lhs)), int> && std::is_same_v<decltype(TERtoInt(rhs)), int>,
bool>
{
return TERtoInt(lhs) > TERtoInt(rhs);
}
template <typename L, typename R>
constexpr auto
operator>=(L const& lhs, R const& rhs) -> bool
requires(
std::is_same_v<decltype(TERtoInt(lhs)), int> &&
std::is_same_v<decltype(TERtoInt(rhs)), int>)
operator>=(L const& lhs, R const& rhs) -> std::enable_if_t<
std::is_same_v<decltype(TERtoInt(lhs)), int> && std::is_same_v<decltype(TERtoInt(rhs)), int>,
bool>
{
return TERtoInt(lhs) >= TERtoInt(rhs);
}

View File

@@ -102,7 +102,8 @@ inline constexpr FlagValue tfUniversalMask = ~tfUniversal;
TRANSACTION(Payment, \
TF_FLAG(tfNoRippleDirect, 0x00010000) \
TF_FLAG(tfPartialPayment, 0x00020000) \
TF_FLAG(tfLimitQuality, 0x00040000), \
TF_FLAG(tfLimitQuality, 0x00040000) \
TF_FLAG(tfSponsorCreatedAccount, 0x00080000), \
MASK_ADJ(0)) \
\
TRANSACTION(TrustSet, \
@@ -215,6 +216,20 @@ inline constexpr FlagValue tfUniversalMask = ~tfUniversal;
TF_FLAG(tfLoanDefault, 0x00010000) \
TF_FLAG(tfLoanImpair, 0x00020000) \
TF_FLAG(tfLoanUnimpair, 0x00040000), \
MASK_ADJ(0)) \
\
TRANSACTION(SponsorshipSet, \
TF_FLAG(tfSponsorshipSetRequireSignForFee, 0x00010000) \
TF_FLAG(tfSponsorshipClearRequireSignForFee, 0x00020000) \
TF_FLAG(tfSponsorshipSetRequireSignForReserve, 0x00040000) \
TF_FLAG(tfSponsorshipClearRequireSignForReserve, 0x00080000) \
TF_FLAG(tfDeleteObject, 0x00100000), \
MASK_ADJ(0)) \
\
TRANSACTION(SponsorshipTransfer, \
TF_FLAG(tfSponsorshipEnd, 0x00000001) \
TF_FLAG(tfSponsorshipCreate, 0x00000002) \
TF_FLAG(tfSponsorshipReassign, 0x00000004), \
MASK_ADJ(0))
// clang-format on
@@ -444,6 +459,12 @@ getAsfFlagMap()
#pragma pop_macro("ACCOUNTSET_FLAG_TO_MAP")
#pragma pop_macro("ACCOUNTSET_FLAGS")
// Sponsor flags (spf)
inline constexpr FlagValue spfSponsorFee = 1;
inline constexpr FlagValue spfSponsorReserve = 2;
inline constexpr FlagValue spfSponsorFlagMask = ~(spfSponsorFee | spfSponsorReserve);
} // namespace xrpl
// NOLINTEND(readability-identifier-naming)

View File

@@ -50,13 +50,14 @@ public:
STVar&
operator=(STVar&& rhs);
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
STVar(STBase&& t) : p_(t.move(kMaxSize, &d_))
STVar(STBase&& t) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
{
p_ = t.move(kMaxSize, &d_);
}
STVar(STBase const& t) : p_(t.copy(kMaxSize, &d_))
STVar(STBase const& t)
{
p_ = t.copy(kMaxSize, &d_);
}
STVar(DefaultObjectT, SField const& name);

View File

@@ -15,9 +15,10 @@
// Add new amendments to the top of this list.
// Keep it sorted in reverse chronological order.
XRPL_FEATURE(BatchV1_1, Supported::Yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(Sponsor, Supported::No, VoteBehavior::DefaultNo)
XRPL_FEATURE(BatchV1_1, Supported::No, VoteBehavior::DefaultNo)
XRPL_FEATURE(LendingProtocolV1_1, Supported::No, VoteBehavior::DefaultNo)
XRPL_FEATURE(ConfidentialTransfer, Supported::Yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(ConfidentialTransfer, Supported::No, VoteBehavior::DefaultNo)
XRPL_FIX (Cleanup3_3_0, Supported::Yes, VoteBehavior::DefaultNo)
XRPL_FIX (Cleanup3_2_0, Supported::Yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(MPTokensV2, Supported::No, VoteBehavior::DefaultNo)
@@ -60,6 +61,7 @@ XRPL_FEATURE(PriceOracle, Supported::Yes, VoteBehavior::DefaultNo
XRPL_FIX (AMMOverflowOffer, Supported::Yes, VoteBehavior::DefaultYes)
XRPL_FIX (FillOrKill, Supported::Yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(DID, Supported::Yes, VoteBehavior::DefaultNo)
XRPL_FIX (DisallowIncomingV1, Supported::Yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(XChainBridge, Supported::Yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(AMM, Supported::Yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(XRPFees, Supported::Yes, VoteBehavior::DefaultNo)
@@ -99,7 +101,6 @@ XRPL_RETIRE_FIX(1623)
XRPL_RETIRE_FIX(1781)
XRPL_RETIRE_FIX(AmendmentMajorityCalc)
XRPL_RETIRE_FIX(CheckThreading)
XRPL_RETIRE_FIX(DisallowIncomingV1)
XRPL_RETIRE_FIX(InnerObjTemplate)
XRPL_RETIRE_FIX(MasterKeyAsRegularKey)
XRPL_RETIRE_FIX(NonFungibleTokensV1_2)

View File

@@ -127,29 +127,32 @@ LEDGER_ENTRY(ltTICKET, 0x0054, Ticket, ticket, ({
\sa keylet::account
*/
LEDGER_ENTRY(ltACCOUNT_ROOT, 0x0061, AccountRoot, account, ({
{sfAccount, SoeRequired},
{sfSequence, SoeRequired},
{sfBalance, SoeRequired},
{sfOwnerCount, SoeRequired},
{sfPreviousTxnID, SoeRequired},
{sfPreviousTxnLgrSeq, SoeRequired},
{sfAccountTxnID, SoeOptional},
{sfRegularKey, SoeOptional},
{sfEmailHash, SoeOptional},
{sfWalletLocator, SoeOptional},
{sfWalletSize, SoeOptional},
{sfMessageKey, SoeOptional},
{sfTransferRate, SoeOptional},
{sfDomain, SoeOptional},
{sfTickSize, SoeOptional},
{sfTicketCount, SoeOptional},
{sfNFTokenMinter, SoeOptional},
{sfMintedNFTokens, SoeDefault},
{sfBurnedNFTokens, SoeDefault},
{sfFirstNFTokenSequence, SoeOptional},
{sfAMMID, SoeOptional}, // pseudo-account designator
{sfVaultID, SoeOptional}, // pseudo-account designator
{sfLoanBrokerID, SoeOptional}, // pseudo-account designator
{sfAccount, SoeRequired},
{sfSequence, SoeRequired},
{sfBalance, SoeRequired},
{sfOwnerCount, SoeRequired},
{sfPreviousTxnID, SoeRequired},
{sfPreviousTxnLgrSeq, SoeRequired},
{sfAccountTxnID, SoeOptional},
{sfRegularKey, SoeOptional},
{sfEmailHash, SoeOptional},
{sfWalletLocator, SoeOptional},
{sfWalletSize, SoeOptional},
{sfMessageKey, SoeOptional},
{sfTransferRate, SoeOptional},
{sfDomain, SoeOptional},
{sfTickSize, SoeOptional},
{sfTicketCount, SoeOptional},
{sfNFTokenMinter, SoeOptional},
{sfMintedNFTokens, SoeDefault},
{sfBurnedNFTokens, SoeDefault},
{sfFirstNFTokenSequence, SoeOptional},
{sfSponsoredOwnerCount, SoeDefault},
{sfSponsoringOwnerCount, SoeDefault},
{sfSponsoringAccountCount, SoeDefault},
{sfAMMID, SoeOptional}, // pseudo-account designator
{sfVaultID, SoeOptional}, // pseudo-account designator
{sfLoanBrokerID, SoeOptional}, // pseudo-account designator
}))
/** A ledger object which contains a list of object identifiers.
@@ -286,6 +289,8 @@ LEDGER_ENTRY(ltRIPPLE_STATE, 0x0072, RippleState, state, ({
{sfHighNode, SoeOptional},
{sfHighQualityIn, SoeOptional},
{sfHighQualityOut, SoeOptional},
{sfHighSponsor, SoeOptional},
{sfLowSponsor, SoeOptional},
}))
/** The ledger object which lists the network's fee settings.
@@ -616,5 +621,20 @@ LEDGER_ENTRY(ltLOAN, 0x0089, Loan, loan, ({
{sfLoanScale, SoeDefault},
}))
/** A ledger object representing a sponsorship.
\sa keylet::sponsorship
*/
LEDGER_ENTRY(ltSPONSORSHIP, 0x0090, Sponsorship, sponsorship, ({
{sfPreviousTxnID, SoeRequired},
{sfPreviousTxnLgrSeq, SoeRequired},
{sfOwner, SoeRequired},
{sfSponsee, SoeRequired},
{sfFeeAmount, SoeOptional},
{sfMaxFee, SoeOptional},
{sfRemainingOwnerCount, SoeDefault},
{sfOwnerNode, SoeRequired},
{sfSponseeNode, SoeRequired},
}))
#undef EXPAND
#undef LEDGER_ENTRY_DUPLICATE

View File

@@ -114,6 +114,11 @@ TYPED_SFIELD(sfLateInterestRate, UINT32, 66) // 1/10 basis points (bi
TYPED_SFIELD(sfCloseInterestRate, UINT32, 67) // 1/10 basis points (bips)
TYPED_SFIELD(sfOverpaymentInterestRate, UINT32, 68) // 1/10 basis points (bips)
TYPED_SFIELD(sfConfidentialBalanceVersion, UINT32, 69)
TYPED_SFIELD(sfSponsoredOwnerCount, UINT32, 70)
TYPED_SFIELD(sfSponsoringOwnerCount, UINT32, 71)
TYPED_SFIELD(sfSponsoringAccountCount, UINT32, 72)
TYPED_SFIELD(sfRemainingOwnerCount, UINT32, 73)
TYPED_SFIELD(sfSponsorFlags, UINT32, 74)
// 64-bit integers (common)
TYPED_SFIELD(sfIndexNext, UINT64, 1)
@@ -148,6 +153,7 @@ TYPED_SFIELD(sfLockedAmount, UINT64, 29, SField::kSmdBaseTen|SFie
TYPED_SFIELD(sfVaultNode, UINT64, 30)
TYPED_SFIELD(sfLoanBrokerNode, UINT64, 31)
TYPED_SFIELD(sfConfidentialOutstandingAmount, UINT64, 32, SField::kSmdBaseTen|SField::kSmdDefault)
TYPED_SFIELD(sfSponseeNode, UINT64, 33)
// 128-bit
TYPED_SFIELD(sfEmailHash, UINT128, 1)
@@ -209,6 +215,7 @@ TYPED_SFIELD(sfLoanBrokerID, UINT256, 37,
TYPED_SFIELD(sfLoanID, UINT256, 38)
TYPED_SFIELD(sfReferenceHolding, UINT256, 39)
TYPED_SFIELD(sfBlindingFactor, UINT256, 40)
TYPED_SFIELD(sfObjectID, UINT256, 41)
// number (common)
TYPED_SFIELD(sfNumber, NUMBER, 1)
@@ -268,6 +275,8 @@ TYPED_SFIELD(sfPrice, AMOUNT, 28)
TYPED_SFIELD(sfSignatureReward, AMOUNT, 29)
TYPED_SFIELD(sfMinAccountCreateAmount, AMOUNT, 30)
TYPED_SFIELD(sfLPTokenBalance, AMOUNT, 31)
TYPED_SFIELD(sfFeeAmount, AMOUNT, 32)
TYPED_SFIELD(sfMaxFee, AMOUNT, 33)
// variable length (common)
TYPED_SFIELD(sfPublicKey, VL, 1)
@@ -343,6 +352,11 @@ TYPED_SFIELD(sfIssuingChainDoor, ACCOUNT, 23)
TYPED_SFIELD(sfSubject, ACCOUNT, 24)
TYPED_SFIELD(sfBorrower, ACCOUNT, 25)
TYPED_SFIELD(sfCounterparty, ACCOUNT, 26)
TYPED_SFIELD(sfSponsor, ACCOUNT, 27)
TYPED_SFIELD(sfHighSponsor, ACCOUNT, 28)
TYPED_SFIELD(sfLowSponsor, ACCOUNT, 29)
TYPED_SFIELD(sfCounterpartySponsor, ACCOUNT, 30)
TYPED_SFIELD(sfSponsee, ACCOUNT, 31)
// vector of 256-bit
TYPED_SFIELD(sfIndexes, VECTOR256, 1, SField::kSmdNever)
@@ -407,6 +421,7 @@ UNTYPED_SFIELD(sfRawTransaction, OBJECT, 34)
UNTYPED_SFIELD(sfBatchSigner, OBJECT, 35)
UNTYPED_SFIELD(sfBook, OBJECT, 36)
UNTYPED_SFIELD(sfCounterpartySignature, OBJECT, 37, SField::kSmdDefault, SField::kNotSigning)
UNTYPED_SFIELD(sfSponsorSignature, OBJECT, 38, SField::kSmdDefault, SField::kNotSigning)
// array of objects (common)
// ARRAY/1 is reserved for end of array

View File

@@ -1163,6 +1163,33 @@ TRANSACTION(ttCONFIDENTIAL_MPT_CLAWBACK, 89, ConfidentialMPTClawback,
{sfHolder, SoeRequired},
{sfMPTAmount, SoeRequired},
{sfZKProof, SoeRequired},
}))/** This transaction transfer sponsorship */
#if TRANSACTION_INCLUDE
# include <xrpl/tx/transactors/sponsor/SponsorshipTransfer.h>
#endif
TRANSACTION(ttSPONSORSHIP_TRANSFER, 90, SponsorshipTransfer,
Delegation::NotDelegable,
featureSponsor,
MayModifyVault,
({
{sfObjectID, SoeOptional},
{sfSponsee, SoeOptional},
}))
/** This transaction create sponsorship object */
#if TRANSACTION_INCLUDE
# include <xrpl/tx/transactors/sponsor/SponsorshipSet.h>
#endif
TRANSACTION(ttSPONSORSHIP_SET, 91, SponsorshipSet,
Delegation::Delegable,
featureSponsor,
NoPriv,
({
{sfCounterpartySponsor, SoeOptional},
{sfSponsee, SoeOptional},
{sfFeeAmount, SoeOptional},
{sfMaxFee, SoeOptional},
{sfRemainingOwnerCount, SoeOptional},
}))
/** This system-generated transaction type is used to update the status of the various amendments.

View File

@@ -558,6 +558,9 @@ JSS(source_account); // in: PathRequest, RipplePathFind
JSS(source_amount); // in: PathRequest, RipplePathFind
JSS(source_currencies); // in: PathRequest, RipplePathFind
JSS(source_tag); // out: AccountChannels
JSS(sponsee); // in: LedgerEntry
JSS(sponsor); // in: LedgerEntry
JSS(sponsored); // in: AccountObjects
JSS(stand_alone); // out: NetworkOPs
JSS(standard_deviation); // out: get_aggregate_price
JSS(start); // in: TxHistory

View File

@@ -447,6 +447,78 @@ public:
return this->sle_->isFieldPresent(sfFirstNFTokenSequence);
}
/**
* @brief Get sfSponsoredOwnerCount (SoeDefault)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getSponsoredOwnerCount() const
{
if (hasSponsoredOwnerCount())
return this->sle_->at(sfSponsoredOwnerCount);
return std::nullopt;
}
/**
* @brief Check if sfSponsoredOwnerCount is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasSponsoredOwnerCount() const
{
return this->sle_->isFieldPresent(sfSponsoredOwnerCount);
}
/**
* @brief Get sfSponsoringOwnerCount (SoeDefault)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getSponsoringOwnerCount() const
{
if (hasSponsoringOwnerCount())
return this->sle_->at(sfSponsoringOwnerCount);
return std::nullopt;
}
/**
* @brief Check if sfSponsoringOwnerCount is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasSponsoringOwnerCount() const
{
return this->sle_->isFieldPresent(sfSponsoringOwnerCount);
}
/**
* @brief Get sfSponsoringAccountCount (SoeDefault)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getSponsoringAccountCount() const
{
if (hasSponsoringAccountCount())
return this->sle_->at(sfSponsoringAccountCount);
return std::nullopt;
}
/**
* @brief Check if sfSponsoringAccountCount is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasSponsoringAccountCount() const
{
return this->sle_->isFieldPresent(sfSponsoringAccountCount);
}
/**
* @brief Get sfAMMID (SoeOptional)
* @return The field value, or std::nullopt if not present.
@@ -786,6 +858,39 @@ public:
return *this;
}
/**
* @brief Set sfSponsoredOwnerCount (SoeDefault)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setSponsoredOwnerCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSponsoredOwnerCount] = value;
return *this;
}
/**
* @brief Set sfSponsoringOwnerCount (SoeDefault)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setSponsoringOwnerCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSponsoringOwnerCount] = value;
return *this;
}
/**
* @brief Set sfSponsoringAccountCount (SoeDefault)
* @return Reference to this builder for method chaining.
*/
AccountRootBuilder&
setSponsoringAccountCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfSponsoringAccountCount] = value;
return *this;
}
/**
* @brief Set sfAMMID (SoeOptional)
* @return Reference to this builder for method chaining.

View File

@@ -243,6 +243,54 @@ public:
{
return this->sle_->isFieldPresent(sfHighQualityOut);
}
/**
* @brief Get sfHighSponsor (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getHighSponsor() const
{
if (hasHighSponsor())
return this->sle_->at(sfHighSponsor);
return std::nullopt;
}
/**
* @brief Check if sfHighSponsor is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasHighSponsor() const
{
return this->sle_->isFieldPresent(sfHighSponsor);
}
/**
* @brief Get sfLowSponsor (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getLowSponsor() const
{
if (hasLowSponsor())
return this->sle_->at(sfLowSponsor);
return std::nullopt;
}
/**
* @brief Check if sfLowSponsor is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasLowSponsor() const
{
return this->sle_->isFieldPresent(sfLowSponsor);
}
};
/**
@@ -410,6 +458,28 @@ public:
return *this;
}
/**
* @brief Set sfHighSponsor (SoeOptional)
* @return Reference to this builder for method chaining.
*/
RippleStateBuilder&
setHighSponsor(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfHighSponsor] = value;
return *this;
}
/**
* @brief Set sfLowSponsor (SoeOptional)
* @return Reference to this builder for method chaining.
*/
RippleStateBuilder&
setLowSponsor(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfLowSponsor] = value;
return *this;
}
/**
* @brief Build and return the completed RippleState wrapper.
* @param index The ledger entry index.

View File

@@ -0,0 +1,344 @@
// This file is auto-generated. Do not edit.
#pragma once
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::ledger_entries {
class SponsorshipBuilder;
/**
* @brief Ledger Entry: Sponsorship
*
* Type: ltSPONSORSHIP (0x0090)
* RPC Name: sponsorship
*
* Immutable wrapper around SLE providing type-safe field access.
* Use SponsorshipBuilder to construct new ledger entries.
*/
class Sponsorship : public LedgerEntryBase
{
public:
static constexpr LedgerEntryType entryType = ltSPONSORSHIP;
/**
* @brief Construct a Sponsorship ledger entry wrapper from an existing SLE object.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
explicit Sponsorship(SLE::const_pointer sle)
: LedgerEntryBase(std::move(sle))
{
// Verify ledger entry type
if (sle_->getType() != entryType)
{
throw std::runtime_error("Invalid ledger entry type for Sponsorship");
}
}
// Ledger entry-specific field getters
/**
* @brief Get sfPreviousTxnID (SoeRequired)
* @return The field value.
*/
[[nodiscard]]
SF_UINT256::type::value_type
getPreviousTxnID() const
{
return this->sle_->at(sfPreviousTxnID);
}
/**
* @brief Get sfPreviousTxnLgrSeq (SoeRequired)
* @return The field value.
*/
[[nodiscard]]
SF_UINT32::type::value_type
getPreviousTxnLgrSeq() const
{
return this->sle_->at(sfPreviousTxnLgrSeq);
}
/**
* @brief Get sfOwner (SoeRequired)
* @return The field value.
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getOwner() const
{
return this->sle_->at(sfOwner);
}
/**
* @brief Get sfSponsee (SoeRequired)
* @return The field value.
*/
[[nodiscard]]
SF_ACCOUNT::type::value_type
getSponsee() const
{
return this->sle_->at(sfSponsee);
}
/**
* @brief Get sfFeeAmount (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getFeeAmount() const
{
if (hasFeeAmount())
return this->sle_->at(sfFeeAmount);
return std::nullopt;
}
/**
* @brief Check if sfFeeAmount is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasFeeAmount() const
{
return this->sle_->isFieldPresent(sfFeeAmount);
}
/**
* @brief Get sfMaxFee (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getMaxFee() const
{
if (hasMaxFee())
return this->sle_->at(sfMaxFee);
return std::nullopt;
}
/**
* @brief Check if sfMaxFee is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasMaxFee() const
{
return this->sle_->isFieldPresent(sfMaxFee);
}
/**
* @brief Get sfRemainingOwnerCount (SoeDefault)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getRemainingOwnerCount() const
{
if (hasRemainingOwnerCount())
return this->sle_->at(sfRemainingOwnerCount);
return std::nullopt;
}
/**
* @brief Check if sfRemainingOwnerCount is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasRemainingOwnerCount() const
{
return this->sle_->isFieldPresent(sfRemainingOwnerCount);
}
/**
* @brief Get sfOwnerNode (SoeRequired)
* @return The field value.
*/
[[nodiscard]]
SF_UINT64::type::value_type
getOwnerNode() const
{
return this->sle_->at(sfOwnerNode);
}
/**
* @brief Get sfSponseeNode (SoeRequired)
* @return The field value.
*/
[[nodiscard]]
SF_UINT64::type::value_type
getSponseeNode() const
{
return this->sle_->at(sfSponseeNode);
}
};
/**
* @brief Builder for Sponsorship ledger entries.
*
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses STObject internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class SponsorshipBuilder : public LedgerEntryBuilderBase<SponsorshipBuilder>
{
public:
/**
* @brief Construct a new SponsorshipBuilder with required fields.
* @param previousTxnID The sfPreviousTxnID field value.
* @param previousTxnLgrSeq The sfPreviousTxnLgrSeq field value.
* @param owner The sfOwner field value.
* @param sponsee The sfSponsee field value.
* @param ownerNode The sfOwnerNode field value.
* @param sponseeNode The sfSponseeNode field value.
*/
SponsorshipBuilder(std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq,std::decay_t<typename SF_ACCOUNT::type::value_type> const& owner,std::decay_t<typename SF_ACCOUNT::type::value_type> const& sponsee,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT64::type::value_type> const& sponseeNode)
: LedgerEntryBuilderBase<SponsorshipBuilder>(ltSPONSORSHIP)
{
setPreviousTxnID(previousTxnID);
setPreviousTxnLgrSeq(previousTxnLgrSeq);
setOwner(owner);
setSponsee(sponsee);
setOwnerNode(ownerNode);
setSponseeNode(sponseeNode);
}
/**
* @brief Construct a SponsorshipBuilder from an existing SLE object.
* @param sle The existing ledger entry to copy from.
* @throws std::runtime_error if the ledger entry type doesn't match.
*/
SponsorshipBuilder(SLE::const_pointer sle)
{
if (sle->at(sfLedgerEntryType) != ltSPONSORSHIP)
{
throw std::runtime_error("Invalid ledger entry type for Sponsorship");
}
object_ = *sle;
}
/** @brief Ledger entry-specific field setters */
/**
* @brief Set sfPreviousTxnID (SoeRequired)
* @return Reference to this builder for method chaining.
*/
SponsorshipBuilder&
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfPreviousTxnID] = value;
return *this;
}
/**
* @brief Set sfPreviousTxnLgrSeq (SoeRequired)
* @return Reference to this builder for method chaining.
*/
SponsorshipBuilder&
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfPreviousTxnLgrSeq] = value;
return *this;
}
/**
* @brief Set sfOwner (SoeRequired)
* @return Reference to this builder for method chaining.
*/
SponsorshipBuilder&
setOwner(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfOwner] = value;
return *this;
}
/**
* @brief Set sfSponsee (SoeRequired)
* @return Reference to this builder for method chaining.
*/
SponsorshipBuilder&
setSponsee(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfSponsee] = value;
return *this;
}
/**
* @brief Set sfFeeAmount (SoeOptional)
* @return Reference to this builder for method chaining.
*/
SponsorshipBuilder&
setFeeAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfFeeAmount] = value;
return *this;
}
/**
* @brief Set sfMaxFee (SoeOptional)
* @return Reference to this builder for method chaining.
*/
SponsorshipBuilder&
setMaxFee(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfMaxFee] = value;
return *this;
}
/**
* @brief Set sfRemainingOwnerCount (SoeDefault)
* @return Reference to this builder for method chaining.
*/
SponsorshipBuilder&
setRemainingOwnerCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfRemainingOwnerCount] = value;
return *this;
}
/**
* @brief Set sfOwnerNode (SoeRequired)
* @return Reference to this builder for method chaining.
*/
SponsorshipBuilder&
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfOwnerNode] = value;
return *this;
}
/**
* @brief Set sfSponseeNode (SoeRequired)
* @return Reference to this builder for method chaining.
*/
SponsorshipBuilder&
setSponseeNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfSponseeNode] = value;
return *this;
}
/**
* @brief Build and return the completed Sponsorship wrapper.
* @param index The ledger entry index.
* @return The constructed ledger entry wrapper.
*/
Sponsorship
build(uint256 const& index)
{
return Sponsorship{std::make_shared<SLE>(std::move(object_), index)};
}
};
} // namespace xrpl::ledger_entries

View File

@@ -0,0 +1,290 @@
// This file is auto-generated. Do not edit.
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
class SponsorshipSetBuilder;
/**
* @brief Transaction: SponsorshipSet
*
* Type: ttSPONSORSHIP_SET (91)
* Delegable: Delegation::Delegable
* Amendment: featureSponsor
* Privileges: NoPriv
*
* Immutable wrapper around STTx providing type-safe field access.
* Use SponsorshipSetBuilder to construct new transactions.
*/
class SponsorshipSet : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttSPONSORSHIP_SET;
/**
* @brief Construct a SponsorshipSet transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit SponsorshipSet(std::shared_ptr<STTx const> tx)
: TransactionBase(std::move(tx))
{
// Verify transaction type
if (tx_->getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for SponsorshipSet");
}
}
// Transaction-specific field getters
/**
* @brief Get sfCounterpartySponsor (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getCounterpartySponsor() const
{
if (hasCounterpartySponsor())
{
return this->tx_->at(sfCounterpartySponsor);
}
return std::nullopt;
}
/**
* @brief Check if sfCounterpartySponsor is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasCounterpartySponsor() const
{
return this->tx_->isFieldPresent(sfCounterpartySponsor);
}
/**
* @brief Get sfSponsee (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getSponsee() const
{
if (hasSponsee())
{
return this->tx_->at(sfSponsee);
}
return std::nullopt;
}
/**
* @brief Check if sfSponsee is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasSponsee() const
{
return this->tx_->isFieldPresent(sfSponsee);
}
/**
* @brief Get sfFeeAmount (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getFeeAmount() const
{
if (hasFeeAmount())
{
return this->tx_->at(sfFeeAmount);
}
return std::nullopt;
}
/**
* @brief Check if sfFeeAmount is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasFeeAmount() const
{
return this->tx_->isFieldPresent(sfFeeAmount);
}
/**
* @brief Get sfMaxFee (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_AMOUNT::type::value_type>
getMaxFee() const
{
if (hasMaxFee())
{
return this->tx_->at(sfMaxFee);
}
return std::nullopt;
}
/**
* @brief Check if sfMaxFee is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasMaxFee() const
{
return this->tx_->isFieldPresent(sfMaxFee);
}
/**
* @brief Get sfRemainingOwnerCount (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getRemainingOwnerCount() const
{
if (hasRemainingOwnerCount())
{
return this->tx_->at(sfRemainingOwnerCount);
}
return std::nullopt;
}
/**
* @brief Check if sfRemainingOwnerCount is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasRemainingOwnerCount() const
{
return this->tx_->isFieldPresent(sfRemainingOwnerCount);
}
};
/**
* @brief Builder for SponsorshipSet transactions.
*
* Provides a fluent interface for constructing transactions with method chaining.
* Uses STObject internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class SponsorshipSetBuilder : public TransactionBuilderBase<SponsorshipSetBuilder>
{
public:
/**
* @brief Construct a new SponsorshipSetBuilder with required fields.
* @param account The account initiating the transaction.
* @param sequence Optional sequence number for the transaction.
* @param fee Optional fee for the transaction.
*/
SponsorshipSetBuilder(SF_ACCOUNT::type::value_type account,
std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<SponsorshipSetBuilder>(ttSPONSORSHIP_SET, account, sequence, fee)
{
}
/**
* @brief Construct a SponsorshipSetBuilder from an existing STTx object.
* @param tx The existing transaction to copy from.
* @throws std::runtime_error if the transaction type doesn't match.
*/
SponsorshipSetBuilder(std::shared_ptr<STTx const> tx)
{
if (tx->getTxnType() != ttSPONSORSHIP_SET)
{
throw std::runtime_error("Invalid transaction type for SponsorshipSetBuilder");
}
object_ = *tx;
}
/** @brief Transaction-specific field setters */
/**
* @brief Set sfCounterpartySponsor (SoeOptional)
* @return Reference to this builder for method chaining.
*/
SponsorshipSetBuilder&
setCounterpartySponsor(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfCounterpartySponsor] = value;
return *this;
}
/**
* @brief Set sfSponsee (SoeOptional)
* @return Reference to this builder for method chaining.
*/
SponsorshipSetBuilder&
setSponsee(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfSponsee] = value;
return *this;
}
/**
* @brief Set sfFeeAmount (SoeOptional)
* @return Reference to this builder for method chaining.
*/
SponsorshipSetBuilder&
setFeeAmount(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfFeeAmount] = value;
return *this;
}
/**
* @brief Set sfMaxFee (SoeOptional)
* @return Reference to this builder for method chaining.
*/
SponsorshipSetBuilder&
setMaxFee(std::decay_t<typename SF_AMOUNT::type::value_type> const& value)
{
object_[sfMaxFee] = value;
return *this;
}
/**
* @brief Set sfRemainingOwnerCount (SoeOptional)
* @return Reference to this builder for method chaining.
*/
SponsorshipSetBuilder&
setRemainingOwnerCount(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfRemainingOwnerCount] = value;
return *this;
}
/**
* @brief Build and return the SponsorshipSet wrapper.
* @param publicKey The public key for signing.
* @param secretKey The secret key for signing.
* @return The constructed transaction wrapper.
*/
SponsorshipSet
build(PublicKey const& publicKey, SecretKey const& secretKey)
{
sign(publicKey, secretKey);
return SponsorshipSet{std::make_shared<STTx>(std::move(object_))};
}
};
} // namespace xrpl::transactions

View File

@@ -0,0 +1,179 @@
// This file is auto-generated. Do not edit.
#pragma once
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/STParsedJSON.h>
#include <xrpl/protocol/jss.h>
#include <xrpl/protocol_autogen/TransactionBase.h>
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
#include <xrpl/json/json_value.h>
#include <stdexcept>
#include <optional>
namespace xrpl::transactions {
class SponsorshipTransferBuilder;
/**
* @brief Transaction: SponsorshipTransfer
*
* Type: ttSPONSORSHIP_TRANSFER (90)
* Delegable: Delegation::NotDelegable
* Amendment: featureSponsor
* Privileges: MayModifyVault
*
* Immutable wrapper around STTx providing type-safe field access.
* Use SponsorshipTransferBuilder to construct new transactions.
*/
class SponsorshipTransfer : public TransactionBase
{
public:
static constexpr xrpl::TxType txType = ttSPONSORSHIP_TRANSFER;
/**
* @brief Construct a SponsorshipTransfer transaction wrapper from an existing STTx object.
* @throws std::runtime_error if the transaction type doesn't match.
*/
explicit SponsorshipTransfer(std::shared_ptr<STTx const> tx)
: TransactionBase(std::move(tx))
{
// Verify transaction type
if (tx_->getTxnType() != txType)
{
throw std::runtime_error("Invalid transaction type for SponsorshipTransfer");
}
}
// Transaction-specific field getters
/**
* @brief Get sfObjectID (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT256::type::value_type>
getObjectID() const
{
if (hasObjectID())
{
return this->tx_->at(sfObjectID);
}
return std::nullopt;
}
/**
* @brief Check if sfObjectID is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasObjectID() const
{
return this->tx_->isFieldPresent(sfObjectID);
}
/**
* @brief Get sfSponsee (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
getSponsee() const
{
if (hasSponsee())
{
return this->tx_->at(sfSponsee);
}
return std::nullopt;
}
/**
* @brief Check if sfSponsee is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasSponsee() const
{
return this->tx_->isFieldPresent(sfSponsee);
}
};
/**
* @brief Builder for SponsorshipTransfer transactions.
*
* Provides a fluent interface for constructing transactions with method chaining.
* Uses STObject internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class SponsorshipTransferBuilder : public TransactionBuilderBase<SponsorshipTransferBuilder>
{
public:
/**
* @brief Construct a new SponsorshipTransferBuilder with required fields.
* @param account The account initiating the transaction.
* @param sequence Optional sequence number for the transaction.
* @param fee Optional fee for the transaction.
*/
SponsorshipTransferBuilder(SF_ACCOUNT::type::value_type account,
std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
)
: TransactionBuilderBase<SponsorshipTransferBuilder>(ttSPONSORSHIP_TRANSFER, account, sequence, fee)
{
}
/**
* @brief Construct a SponsorshipTransferBuilder from an existing STTx object.
* @param tx The existing transaction to copy from.
* @throws std::runtime_error if the transaction type doesn't match.
*/
SponsorshipTransferBuilder(std::shared_ptr<STTx const> tx)
{
if (tx->getTxnType() != ttSPONSORSHIP_TRANSFER)
{
throw std::runtime_error("Invalid transaction type for SponsorshipTransferBuilder");
}
object_ = *tx;
}
/** @brief Transaction-specific field setters */
/**
* @brief Set sfObjectID (SoeOptional)
* @return Reference to this builder for method chaining.
*/
SponsorshipTransferBuilder&
setObjectID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
{
object_[sfObjectID] = value;
return *this;
}
/**
* @brief Set sfSponsee (SoeOptional)
* @return Reference to this builder for method chaining.
*/
SponsorshipTransferBuilder&
setSponsee(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
{
object_[sfSponsee] = value;
return *this;
}
/**
* @brief Build and return the SponsorshipTransfer wrapper.
* @param publicKey The public key for signing.
* @param secretKey The secret key for signing.
* @return The constructed transaction wrapper.
*/
SponsorshipTransfer
build(PublicKey const& publicKey, SecretKey const& secretKey)
{
sign(publicKey, secretKey);
return SponsorshipTransfer{std::make_shared<STTx>(std::move(object_))};
}
};
} // namespace xrpl::transactions

View File

@@ -351,9 +351,10 @@ public:
Import& import(iter->second);
if (iter->second.whenExpires <= elapsed)
{
for (auto& item : import.items)
for (auto itemIter(import.items.begin()); itemIter != import.items.end();
++itemIter)
{
item.consumer.entry().remoteBalance -= item.balance;
itemIter->consumer.entry().remoteBalance -= itemIter->balance;
}
iter = importTable_.erase(iter);

View File

@@ -161,12 +161,13 @@ deserializeManifest(
return deserializeManifest(makeSlice(s), journal);
}
template <class T>
template <
class T,
class = std::enable_if_t<std::is_same_v<T, char> || std::is_same_v<T, unsigned char>>>
std::optional<Manifest>
deserializeManifest(
std::vector<T> const& v,
beast::Journal journal = beast::Journal(beast::Journal::getNullSink()))
requires(std::is_same_v<T, char> || std::is_same_v<T, unsigned char>)
{
return deserializeManifest(makeSlice(v), journal);
}

View File

@@ -223,7 +223,10 @@ BaseHTTPPeer<Handler, Impl>::close()
{
if (!strand_.running_in_this_thread())
{
return post(strand_, [self = impl().shared_from_this()] { self->close(); });
return post(
strand_,
std::bind(
(void (BaseHTTPPeer::*)(void))&BaseHTTPPeer::close, impl().shared_from_this()));
}
boost::beast::get_lowest_layer(impl().stream_).close();
}
@@ -319,18 +322,22 @@ BaseHTTPPeer<Handler, Impl>::onWrite(error_code const& ec, std::size_t bytesTran
v,
bind_executor(
strand_,
[self = impl().shared_from_this()](
error_code const& ec, std::size_t bytesTransferred) {
self->onWrite(ec, bytesTransferred);
}));
std::bind(
&BaseHTTPPeer::onWrite,
impl().shared_from_this(),
std::placeholders::_1,
std::placeholders::_2)));
}
if (!complete_)
return;
if (graceful_)
return doClose();
util::spawn(strand_, [self = impl().shared_from_this()](yield_context doYield) {
self->doRead(doYield);
});
util::spawn(
strand_,
std::bind(
&BaseHTTPPeer<Handler, Impl>::doRead,
impl().shared_from_this(),
std::placeholders::_1));
}
template <class Handler, class Impl>
@@ -344,9 +351,14 @@ BaseHTTPPeer<Handler, Impl>::doWriter(
{
auto const p = impl().shared_from_this();
resume = std::function<void(void)>([this, p, writer, keepAlive]() {
util::spawn(strand_, [p, writer, keepAlive](yield_context doYield) {
p->doWriter(writer, keepAlive, doYield);
});
util::spawn(
strand_,
std::bind(
&BaseHTTPPeer<Handler, Impl>::doWriter,
p,
writer,
keepAlive,
std::placeholders::_1));
});
}
@@ -367,9 +379,12 @@ BaseHTTPPeer<Handler, Impl>::doWriter(
if (!keepAlive)
return doClose();
util::spawn(strand_, [self = impl().shared_from_this()](yield_context doYield) {
self->doRead(doYield);
});
util::spawn(
strand_,
std::bind(
&BaseHTTPPeer<Handler, Impl>::doRead,
impl().shared_from_this(),
std::placeholders::_1));
}
//------------------------------------------------------------------------------
@@ -390,7 +405,8 @@ BaseHTTPPeer<Handler, Impl>::write(void const* buf, std::size_t bytes)
if (!strand_.running_in_this_thread())
{
return post(
strand_, [self = impl().shared_from_this()] { self->onWrite(error_code{}, 0); });
strand_,
std::bind(&BaseHTTPPeer::onWrite, impl().shared_from_this(), error_code{}, 0));
}
return onWrite(error_code{}, 0);
}
@@ -401,9 +417,13 @@ void
BaseHTTPPeer<Handler, Impl>::write(std::shared_ptr<Writer> const& writer, bool keepAlive)
{
util::spawn(
strand_, [self = impl().shared_from_this(), writer, keepAlive](yield_context doYield) {
self->doWriter(writer, keepAlive, doYield);
});
strand_,
std::bind(
&BaseHTTPPeer<Handler, Impl>::doWriter,
impl().shared_from_this(),
writer,
keepAlive,
std::placeholders::_1));
}
// DEPRECATED
@@ -423,7 +443,8 @@ BaseHTTPPeer<Handler, Impl>::complete()
{
if (!strand_.running_in_this_thread())
{
return post(strand_, [self = impl().shared_from_this()] { self->complete(); });
return post(
strand_, std::bind(&BaseHTTPPeer<Handler, Impl>::complete, impl().shared_from_this()));
}
message_ = {};
@@ -436,9 +457,12 @@ BaseHTTPPeer<Handler, Impl>::complete()
}
// keep-alive
util::spawn(strand_, [self = impl().shared_from_this()](yield_context doYield) {
self->doRead(doYield);
});
util::spawn(
strand_,
std::bind(
&BaseHTTPPeer<Handler, Impl>::doRead,
impl().shared_from_this(),
std::placeholders::_1));
}
// DEPRECATED
@@ -450,7 +474,11 @@ BaseHTTPPeer<Handler, Impl>::close(bool graceful)
if (!strand_.running_in_this_thread())
{
return post(
strand_, [self = impl().shared_from_this(), graceful] { self->close(graceful); });
strand_,
std::bind(
(void (BaseHTTPPeer::*)(bool))&BaseHTTPPeer<Handler, Impl>::close,
impl().shared_from_this(),
graceful));
}
complete_ = true;

View File

@@ -10,6 +10,7 @@
#include <atomic>
#include <chrono>
#include <functional>
#include <string>
#include <utility>
@@ -83,7 +84,7 @@ void
BasePeer<Handler, Impl>::close()
{
if (!strand_.running_in_this_thread())
return post(strand_, [self = impl().shared_from_this()] { self->close(); });
return post(strand_, std::bind(&BasePeer::close, impl().shared_from_this()));
error_code ec;
xrpl::getLowestLayer(impl().ws_).socket().close(ec);
}

View File

@@ -20,7 +20,6 @@
#include <algorithm>
#include <chrono>
#include <cstddef>
#include <functional>
#include <iterator>
#include <list>
@@ -181,13 +180,12 @@ void
BaseWSPeer<Handler, Impl>::run()
{
if (!strand_.running_in_this_thread())
return post(strand_, [self = impl().shared_from_this()] { self->run(); });
return post(strand_, std::bind(&BaseWSPeer::run, impl().shared_from_this()));
impl().ws_.set_option(port().pmdOptions);
// Must manage the control callback memory outside of the `control_callback`
// function
controlCallback_ = [this](
boost::beast::websocket::frame_type kind,
boost::beast::string_view payload) { onPingPong(kind, payload); };
controlCallback_ =
std::bind(&BaseWSPeer::onPingPong, this, std::placeholders::_1, std::placeholders::_2);
impl().ws_.control_callback(controlCallback_);
startTimer();
closeOnTimer_ = true;
@@ -195,9 +193,11 @@ BaseWSPeer<Handler, Impl>::run()
res.set(boost::beast::http::field::server, BuildInfo::getFullVersionString());
}));
impl().ws_.async_accept(
request_, bind_executor(strand_, [self = impl().shared_from_this()](error_code const& ec) {
self->onWsHandshake(ec);
}));
request_,
bind_executor(
strand_,
std::bind(
&BaseWSPeer::onWsHandshake, impl().shared_from_this(), std::placeholders::_1)));
}
template <class Handler, class Impl>
@@ -205,10 +205,7 @@ void
BaseWSPeer<Handler, Impl>::send(std::shared_ptr<WSMsg> w)
{
if (!strand_.running_in_this_thread())
{
return post(
strand_, [self = impl().shared_from_this(), w = std::move(w)] { self->send(w); });
}
return post(strand_, std::bind(&BaseWSPeer::send, impl().shared_from_this(), std::move(w)));
if (doClose_)
return;
if (wq_.size() > port().wsQueueLimit)
@@ -261,7 +258,7 @@ void
BaseWSPeer<Handler, Impl>::complete()
{
if (!strand_.running_in_this_thread())
return post(strand_, [self = impl().shared_from_this()] { self->complete(); });
return post(strand_, std::bind(&BaseWSPeer::complete, impl().shared_from_this()));
doRead();
}
@@ -280,7 +277,7 @@ void
BaseWSPeer<Handler, Impl>::doWrite()
{
if (!strand_.running_in_this_thread())
return post(strand_, [self = impl().shared_from_this()] { self->doWrite(); });
return post(strand_, std::bind(&BaseWSPeer::doWrite, impl().shared_from_this()));
onWrite({});
}
@@ -291,7 +288,8 @@ BaseWSPeer<Handler, Impl>::onWrite(error_code const& ec)
if (ec)
return fail(ec, "write");
auto& w = *wq_.front();
auto const result = w.prepare(65536, [self = impl().shared_from_this()] { self->doWrite(); });
auto const result =
w.prepare(65536, std::bind(&BaseWSPeer::doWrite, impl().shared_from_this()));
if (boost::indeterminate(result.first))
return;
startTimer();
@@ -301,9 +299,8 @@ BaseWSPeer<Handler, Impl>::onWrite(error_code const& ec)
static_cast<bool>(result.first),
result.second,
bind_executor(
strand_, [self = impl().shared_from_this()](error_code const& ec, std::size_t) {
self->onWrite(ec);
}));
strand_,
std::bind(&BaseWSPeer::onWrite, impl().shared_from_this(), std::placeholders::_1)));
}
else
{
@@ -311,9 +308,9 @@ BaseWSPeer<Handler, Impl>::onWrite(error_code const& ec)
static_cast<bool>(result.first),
result.second,
bind_executor(
strand_, [self = impl().shared_from_this()](error_code const& ec, std::size_t) {
self->onWriteFin(ec);
}));
strand_,
std::bind(
&BaseWSPeer::onWriteFin, impl().shared_from_this(), std::placeholders::_1)));
}
}
@@ -327,9 +324,10 @@ BaseWSPeer<Handler, Impl>::onWriteFin(error_code const& ec)
if (doClose_)
{
impl().ws_.async_close(
cr_, bind_executor(strand_, [self = impl().shared_from_this()](error_code const& ec) {
self->onClose(ec);
}));
cr_,
bind_executor(
strand_,
std::bind(&BaseWSPeer::onClose, impl().shared_from_this(), std::placeholders::_1)));
}
else if (!wq_.empty())
{
@@ -342,13 +340,12 @@ void
BaseWSPeer<Handler, Impl>::doRead()
{
if (!strand_.running_in_this_thread())
return post(strand_, [self = impl().shared_from_this()] { self->doRead(); });
return post(strand_, std::bind(&BaseWSPeer::doRead, impl().shared_from_this()));
impl().ws_.async_read(
rb_,
bind_executor(
strand_, [self = impl().shared_from_this()](error_code const& ec, std::size_t) {
self->onRead(ec);
}));
strand_,
std::bind(&BaseWSPeer::onRead, impl().shared_from_this(), std::placeholders::_1)));
}
template <class Handler, class Impl>
@@ -392,7 +389,11 @@ BaseWSPeer<Handler, Impl>::startTimer()
}
timer_.async_wait(bind_executor(
strand_, [self = impl().shared_from_this()](error_code const& ec) { self->onTimer(ec); }));
strand_,
std::bind(
&BaseWSPeer<Handler, Impl>::onTimer,
impl().shared_from_this(),
std::placeholders::_1)));
}
// Convenience for discarding the error code
@@ -460,9 +461,10 @@ BaseWSPeer<Handler, Impl>::onTimer(error_code ec)
beast::rngfill(payload_.begin(), payload_.size(), cryptoPrng());
impl().ws_.async_ping(
payload_,
bind_executor(strand_, [self = impl().shared_from_this()](error_code const& ec) {
self->onPing(ec);
}));
bind_executor(
strand_,
std::bind(
&BaseWSPeer::onPing, impl().shared_from_this(), std::placeholders::_1)));
JLOG(this->j_.trace()) << "sent ping";
return;
}

View File

@@ -33,6 +33,7 @@
#include <algorithm>
#include <chrono>
#include <cstdint>
#include <functional>
#include <memory>
#include <optional>
#include <sstream>
@@ -181,7 +182,7 @@ void
Door<Handler>::Detector::run()
{
util::spawn(
strand_, [self = this->shared_from_this()](yield_context yield) { self->doDetect(yield); });
strand_, std::bind(&Detector::doDetect, this->shared_from_this(), std::placeholders::_1));
}
template <class Handler>
@@ -296,7 +297,8 @@ void
Door<Handler>::run()
{
util::spawn(
strand_, [self = this->shared_from_this()](yield_context yield) { self->doAccept(yield); });
strand_,
std::bind(&Door<Handler>::doAccept, this->shared_from_this(), std::placeholders::_1));
}
template <class Handler>
@@ -305,7 +307,8 @@ Door<Handler>::close()
{
if (!strand_.running_in_this_thread())
{
return boost::asio::post(strand_, [self = this->shared_from_this()] { self->close(); });
return boost::asio::post(
strand_, std::bind(&Door<Handler>::close, this->shared_from_this()));
}
backoffTimer_.cancel();
error_code ec;

View File

@@ -9,6 +9,7 @@
#include <boost/beast/core/tcp_stream.hpp>
#include <functional>
#include <memory>
#include <utility>
@@ -88,9 +89,7 @@ PlainHTTPPeer<Handler>::run()
{
if (!this->handler_.onAccept(this->session(), this->remoteAddress_))
{
util::spawn(this->strand_, [self = this->shared_from_this()](boost::asio::yield_context) {
self->doClose();
});
util::spawn(this->strand_, std::bind(&PlainHTTPPeer::doClose, this->shared_from_this()));
return;
}
@@ -98,9 +97,8 @@ PlainHTTPPeer<Handler>::run()
return;
util::spawn(
this->strand_, [self = this->shared_from_this()](boost::asio::yield_context doYield) {
self->doRead(doYield);
});
this->strand_,
std::bind(&PlainHTTPPeer::doRead, this->shared_from_this(), std::placeholders::_1));
}
template <class Handler>

View File

@@ -13,6 +13,7 @@
#include <boost/beast/core/tcp_stream.hpp>
#include <boost/beast/ssl/ssl_stream.hpp>
#include <functional>
#include <memory>
#include <utility>
@@ -98,15 +99,14 @@ SSLHTTPPeer<Handler>::run()
{
if (!this->handler_.onAccept(this->session(), this->remoteAddress_))
{
util::spawn(
this->strand_, [self = this->shared_from_this()](yield_context) { self->doClose(); });
util::spawn(this->strand_, std::bind(&SSLHTTPPeer::doClose, this->shared_from_this()));
return;
}
if (!socket_.is_open())
return;
util::spawn(this->strand_, [self = this->shared_from_this()](yield_context doYield) {
self->doHandshake(doYield);
});
util::spawn(
this->strand_,
std::bind(&SSLHTTPPeer::doHandshake, this->shared_from_this(), std::placeholders::_1));
}
template <class Handler>
@@ -142,9 +142,9 @@ SSLHTTPPeer<Handler>::doHandshake(yield_context doYield)
this->port().protocol.count("https") > 0;
if (http)
{
util::spawn(this->strand_, [self = this->shared_from_this()](yield_context doYield) {
self->doRead(doYield);
});
util::spawn(
this->strand_,
std::bind(&SSLHTTPPeer::doRead, this->shared_from_this(), std::placeholders::_1));
return;
}
// `this` will be destroyed
@@ -172,7 +172,7 @@ SSLHTTPPeer<Handler>::doClose()
this->startTimer();
stream_.async_shutdown(bind_executor(
this->strand_,
[self = this->shared_from_this()](error_code const& ec) { self->onShutdown(ec); }));
std::bind(&SSLHTTPPeer::onShutdown, this->shared_from_this(), std::placeholders::_1)));
}
template <class Handler>

View File

@@ -103,7 +103,7 @@ public:
/** generation determines whether cached entry is valid */
std::uint32_t
getGeneration() const
getGeneration(void) const
{
return gen_;
}

View File

@@ -138,7 +138,6 @@ intrusive_ptr_release(SHAMapItem const* x)
// If the slabber doesn't claim this pointer, it was allocated
// manually, so we free it manually.
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
if (!detail::gSlabber.deallocate(const_cast<std::uint8_t*>(p)))
delete[] p;
}

View File

@@ -127,6 +127,15 @@ public:
TER
checkInvariants(TER const result, XRPAmount const fee);
ApplyViewContext
getApplyViewContext()
{
XRPL_ASSERT(
view_.has_value(),
"xrpl::ApplyContext::getApplyViewContext : view_ emplaced in constructor");
return {.view = *view_, .tx = tx};
}
private:
static TER
failInvariantCheck(TER const result);

View File

@@ -10,8 +10,10 @@
#include <xrpl/ledger/ReadView.h>
#include <xrpl/protocol/AccountID.h>
#include <xrpl/protocol/Fees.h>
#include <xrpl/protocol/Keylet.h>
#include <xrpl/protocol/Permissions.h>
#include <xrpl/protocol/Rules.h>
#include <xrpl/protocol/SField.h>
#include <xrpl/protocol/STObject.h>
#include <xrpl/protocol/TER.h>
#include <xrpl/protocol/Units.h>
@@ -126,6 +128,21 @@ struct PreflightResult;
// Needed for preflight specialization
class Change;
enum class FeePayerType {
Account,
Delegate,
SponsorCoSigned,
SponsorPreFunded,
};
struct FeePayer
{
AccountID id;
Keylet keylet;
SF_AMOUNT const& balanceField;
FeePayerType type{FeePayerType::Account};
};
class Transactor
{
protected:
@@ -298,6 +315,10 @@ public:
return T::checkGranularSemantics(view, tx, heldGranularPermissions);
}
static NotTEC
checkSponsor(ReadView const& view, STTx const& tx);
/////////////////////////////////////////////////////
// Interface used by AccountDelete
@@ -459,6 +480,9 @@ private:
std::pair<TER, XRPAmount>
reset(XRPAmount fee);
static FeePayer
getFeePayer(ReadView const& view, STTx const& tx);
TER
consumeSeqProxy(SLE::pointer const& sleAccount);
TER

View File

@@ -15,6 +15,7 @@
#include <xrpl/tx/invariants/NFTInvariant.h>
#include <xrpl/tx/invariants/PermissionedDEXInvariant.h>
#include <xrpl/tx/invariants/PermissionedDomainInvariant.h>
#include <xrpl/tx/invariants/SponsorshipInvariant.h>
#include <xrpl/tx/invariants/VaultInvariant.h>
#include <cstdint>
@@ -441,7 +442,9 @@ using InvariantChecks = std::tuple<
ValidMPTPayment,
ValidAmounts,
ValidMPTTransfer,
ObjectHasPseudoAccount>;
ObjectHasPseudoAccount,
SponsorshipOwnerCountsMatch,
SponsorshipAccountCountMatchesField>;
/**
* @brief get a tuple of all invariant checks

View File

@@ -0,0 +1,59 @@
#pragma once
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/ledger/ReadView.h>
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/STTx.h>
#include <xrpl/protocol/TER.h>
#include <xrpl/protocol/XRPAmount.h>
#include <cstdint>
#include <memory>
namespace xrpl {
/**
* @brief Invariant: Sponsored owner counts are balanced.
*
* The following check is made for every transaction:
* - The sum of all per-account deltas of `sfSponsoredOwnerCount` equals
* the sum of all per-account deltas of `sfSponsoringOwnerCount`.
* - Account OwnerCount must be greater than or equal to SponsoredOwnerCount.
*/
class SponsorshipOwnerCountsMatch
{
std::int64_t deltaSponsoredOwnerCount_ = 0;
std::int64_t deltaSponsoringOwnerCount_ = 0;
std::int64_t deltaSponsoredObjectOwnerCount_ = 0;
std::uint64_t ownerCountBelowSponsored_ = 0;
public:
void
visitEntry(bool, std::shared_ptr<SLE const> const&, std::shared_ptr<SLE const> const&);
[[nodiscard]] bool
finalize(STTx const&, TER const, XRPAmount const, ReadView const&, beast::Journal const&) const;
};
/**
* @brief Invariant: Sponsoring account relationships tracked consistently.
*
* The following check is made for every transaction:
* - The net delta of `sfSponsoringAccountCount` across all accounts equals
* the net delta of the count of ltACCOUNT_ROOT entries having
* `sfSponsor` present (presence transitions only: add/remove).
*/
class SponsorshipAccountCountMatchesField
{
std::int64_t deltaSponsoringAccountCount_ = 0;
std::int64_t deltaSponsorFieldPresence_ = 0;
public:
void
visitEntry(bool, std::shared_ptr<SLE const> const&, std::shared_ptr<SLE const> const&);
[[nodiscard]] bool
finalize(STTx const&, TER const, XRPAmount const, ReadView const&, beast::Journal const&) const;
};
} // namespace xrpl

View File

@@ -7,6 +7,7 @@
#include <xrpl/protocol/AccountID.h>
#include <xrpl/protocol/Concepts.h>
#include <xrpl/protocol/Quality.h>
#include <xrpl/protocol/STLedgerEntry.h>
#include <xrpl/protocol/TER.h>
#include <cstdint>
@@ -110,7 +111,10 @@ public:
send(Args&&... args)
{
return accountSend(
std::forward<Args>(args)..., WaiveTransferFee::Yes, AllowMPTOverflow::Yes);
std::forward<Args>(args)...,
SLE::pointer(),
WaiveTransferFee::Yes,
AllowMPTOverflow::Yes);
}
[[nodiscard]] bool

View File

@@ -234,7 +234,8 @@ template <typename... Args>
TER
TOffer<TIn, TOut>::send(Args&&... args)
{
return accountSend(std::forward<Args>(args)..., WaiveTransferFee::No, AllowMPTOverflow::Yes);
return accountSend(
std::forward<Args>(args)..., SLE::pointer(), WaiveTransferFee::No, AllowMPTOverflow::Yes);
}
template <StepAmount TIn, StepAmount TOut>

View File

@@ -92,7 +92,6 @@ public:
[[nodiscard]] TOffer<TIn, TOut>&
tip() const
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
return const_cast<TOfferStreamBase*>(this)->offer_;
}

View File

@@ -6,7 +6,7 @@
#include <xrpl/protocol/MPTAmount.h> // IWYU pragma: keep
#include <xrpl/protocol/XRPAmount.h>
#include <ostream> // IWYU pragma: keep
#include <ostream>
#include <stdexcept>
#include <variant>

Some files were not shown because too many files have changed in this diff Show More