rippled
Loading...
Searching...
No Matches
SignerEntries.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_TX_IMPL_SIGNER_ENTRIES_H_INCLUDED
21#define RIPPLE_TX_IMPL_SIGNER_ENTRIES_H_INCLUDED
22
23#include <xrpld/app/tx/detail/Transactor.h> // NotTEC
24
25#include <xrpl/basics/Expected.h> //
26#include <xrpl/beast/utility/Journal.h> // beast::Journal
27#include <xrpl/protocol/TER.h> // temMALFORMED
28#include <xrpl/protocol/UintTypes.h> // AccountID
29
30#include <optional>
31#include <string_view>
32
33namespace ripple {
34
35// Forward declarations
36class STObject;
37
38// Support for SignerEntries that is needed by a few Transactors.
39//
40// SignerEntries is represented as a std::vector<SignerEntries::SignerEntry>.
41// There is no direct constructor for SignerEntries.
42//
43// o A std::vector<SignerEntries::SignerEntry> is a SignerEntries.
44// o More commonly, SignerEntries are extracted from an STObject by
45// calling SignerEntries::deserialize().
47{
48public:
49 explicit SignerEntries() = delete;
50
52 {
56
58 AccountID const& inAccount,
59 std::uint16_t inWeight,
61 : account(inAccount), weight(inWeight), tag(inTag)
62 {
63 }
64
65 // For sorting to look for duplicate accounts
66 friend bool
67 operator<(SignerEntry const& lhs, SignerEntry const& rhs)
68 {
69 return lhs.account < rhs.account;
70 }
71
72 friend bool
73 operator==(SignerEntry const& lhs, SignerEntry const& rhs)
74 {
75 return lhs.account == rhs.account;
76 }
77 };
78
79 // Deserialize a SignerEntries array from the network or from the ledger.
80 //
81 // obj Contains a SignerEntries field that is an STArray.
82 // journal For reporting error conditions.
83 // annotation Source of SignerEntries, like "ledger" or "transaction".
86 STObject const& obj,
87 beast::Journal journal,
88 std::string_view annotation);
89};
90
91} // namespace ripple
92
93#endif // RIPPLE_TX_IMPL_SIGNER_ENTRIES_H_INCLUDED
A generic endpoint for log messages.
Definition: Journal.h:60
static Expected< std::vector< SignerEntry >, NotTEC > deserialize(STObject const &obj, beast::Journal journal, std::string_view annotation)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
friend bool operator<(SignerEntry const &lhs, SignerEntry const &rhs)
Definition: SignerEntries.h:67
friend bool operator==(SignerEntry const &lhs, SignerEntry const &rhs)
Definition: SignerEntries.h:73
SignerEntry(AccountID const &inAccount, std::uint16_t inWeight, std::optional< uint256 > inTag)
Definition: SignerEntries.h:57
std::optional< uint256 > tag
Definition: SignerEntries.h:55