forked from XRPLF/rippled
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce Strongly typed DepositPreAuth wrapper. A new DepositPreAuth…
…Keylet is used to distinguish between various other types of SLEs update readSLE and peekSLE function calls associated with keylet::depositPreAuth into the new read, peek functions
- Loading branch information
1 parent
c6d98e6
commit f5e48bf
Showing
7 changed files
with
107 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
This file is part of rippled: https://github.com/ripple/rippled | ||
Copyright (c) 2021 Ripple Labs Inc. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
//============================================================================== | ||
|
||
#include <ripple/protocol/LedgerEntryWrapper.h> | ||
#include <ripple/protocol/STAccount.h> | ||
|
||
namespace ripple { | ||
|
||
// Wrapper class for DepositPreAuth Ledger Object. | ||
// This class encapsulates the std::shared_ptr<SLE> to the actual ledger object. | ||
template <bool Writable> | ||
class DepPreAuthImpl final : public LedgerEntryWrapper<Writable> | ||
{ | ||
private: | ||
using Base = LedgerEntryWrapper<Writable>; | ||
using SleT = typename Base::SleT; | ||
using Base::wrapped_; | ||
|
||
DepPreAuthImpl(std::shared_ptr<SleT>&& w) : Base(std::move(w)) | ||
{ | ||
} | ||
|
||
// Friend declarations of factory functions. | ||
// | ||
// For classes that contain factories we must declare the entire class | ||
// as a friend unless the class declaration is visible at this point. | ||
friend class ReadView; | ||
friend class ApplyView; | ||
|
||
public: | ||
// Conversion operator from DepPreAuthImpl<true> to DepPreAuthImpl<false>. | ||
operator DepPreAuthImpl<true>() const | ||
{ | ||
return DepPreAuthImpl<false>( | ||
std::const_pointer_cast<std::shared_ptr<STLedgerEntry const>>( | ||
wrapped_)); | ||
} | ||
|
||
[[nodiscard]] AccountID | ||
accountID() const | ||
{ | ||
return wrapped_->at(sfAccount); | ||
} | ||
|
||
[[nodiscard]] std::uint64_t | ||
getOwner() const | ||
{ | ||
return wrapped_->at(sfOwnerNode); | ||
} | ||
}; | ||
|
||
// The below type alias indicates a read-only non-writable DepPreAuth wrapper | ||
// around the appropriate SLE | ||
using DepPreAuthRd = DepPreAuthImpl<false>; | ||
using DepPreAuth = DepPreAuthImpl<true>; | ||
|
||
} // namespace ripple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters