forked from rubblelabs/ripple
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ledgerentry.go
177 lines (160 loc) · 6.66 KB
/
ledgerentry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
package data
type LedgerEntrySlice []LedgerEntry
type leBase struct {
LedgerEntryType LedgerEntryType
LedgerIndex *Hash256 `json:"index,omitempty"`
PreviousTxnID *Hash256 `json:",omitempty"`
PreviousTxnLgrSeq *uint32 `json:",omitempty"`
Hash Hash256 `json:"-"`
Id Hash256 `json:"-"`
}
type AccountRoot struct {
leBase
Flags *LedgerEntryFlag `json:",omitempty"`
Account *Account `json:",omitempty"`
Sequence *uint32 `json:",omitempty"`
Balance *Value `json:",omitempty"`
OwnerCount *uint32 `json:",omitempty"`
AccountTxnID *Hash256 `json:",omitempty"`
RegularKey *RegularKey `json:",omitempty"`
EmailHash *Hash128 `json:",omitempty"`
WalletLocator *Hash256 `json:",omitempty"`
WalletSize *uint32 `json:",omitempty"`
MessageKey *VariableLength `json:",omitempty"`
TransferRate *uint32 `json:",omitempty"`
Domain *VariableLength `json:",omitempty"`
Signers *VariableLength `json:",omitempty"`
}
type RippleState struct {
leBase
Flags *LedgerEntryFlag `json:",omitempty"`
LowLimit *Amount `json:",omitempty"`
HighLimit *Amount `json:",omitempty"`
Balance *Amount `json:",omitempty"`
LowNode *NodeIndex `json:",omitempty"`
HighNode *NodeIndex `json:",omitempty"`
LowQualityIn *uint32 `json:",omitempty"`
LowQualityOut *uint32 `json:",omitempty"`
HighQualityIn *uint32 `json:",omitempty"`
HighQualityOut *uint32 `json:",omitempty"`
}
type Offer struct {
leBase
Flags *LedgerEntryFlag `json:",omitempty"`
Account *Account `json:",omitempty"`
Sequence *uint32 `json:"sequence,omitempty"`
TakerPays *Amount `json:",omitempty"`
TakerGets *Amount `json:",omitempty"`
BookDirectory *Hash256 `json:",omitempty"`
BookNode *NodeIndex `json:",omitempty"`
OwnerNode *NodeIndex `json:",omitempty"`
Expiration *uint32 `json:",omitempty"`
}
type Directory struct {
leBase
Flags *LedgerEntryFlag `json:",omitempty"`
RootIndex *Hash256 `json:",omitempty"`
Indexes *Vector256 `json:",omitempty"`
Owner *Account `json:",omitempty"`
TakerPaysCurrency *Hash160 `json:",omitempty"`
TakerPaysIssuer *Hash160 `json:",omitempty"`
TakerGetsCurrency *Hash160 `json:",omitempty"`
TakerGetsIssuer *Hash160 `json:",omitempty"`
ExchangeRate *ExchangeRate `json:",omitempty"`
IndexNext *NodeIndex `json:",omitempty"`
IndexPrevious *NodeIndex `json:",omitempty"`
}
type LedgerHashes struct {
leBase
Flags *LedgerEntryFlag `json:",omitempty"`
FirstLedgerSequence *uint32 `json:",omitempty"`
LastLedgerSequence *uint32 `json:",omitempty"`
Hashes *Vector256 `json:",omitempty"`
}
type Majority struct {
Amendment *Hash256 `json:",omitempty"`
CloseTime *uint32 `json:",omitempty"`
}
type Amendments struct {
leBase
Flags *LedgerEntryFlag `json:",omitempty"`
Amendments []Hash256 `json:",omitempty"`
Majorities []Majority `json:",omitempty"`
}
type FeeSettings struct {
leBase
Flags *LedgerEntryFlag `json:",omitempty"`
BaseFee *Uint64Hex `json:",omitempty"`
ReferenceFeeUnits *uint32 `json:",omitempty"`
ReserveBase *uint32 `json:",omitempty"`
ReserveIncrement *uint32 `json:",omitempty"`
}
type SuspendedPayment struct {
leBase
Flags *LedgerEntryFlag `json:",omitempty"`
Account *Account `json:",omitempty"`
Destination *Account `json:",omitempty"`
Amount Amount `json:",omitempty"`
Digest *Hash256 `json:",omitempty"`
CancelAfter *uint32 `json:",omitempty"`
FinishAfter *uint32 `json:",omitempty"`
SourceTag *uint32 `json:",omitempty"`
DestinationTag *uint32 `json:",omitempty"`
OwnerNode *NodeIndex `json:",omitempty"`
}
type SignerEntry struct {
Account *Account `json:",omitempty"`
SignerWeight *uint16 `json:",omitempty"`
}
type SignerList struct {
leBase
Flags *LedgerEntryFlag `json:",omitempty"`
OwnerNode *NodeIndex `json:",omitempty"`
SignerQuorum *uint32 `json:",omitempty"`
SignerEntries []SignerEntry `json:",omitempty"`
SignerListID *uint32 `json:",omitempty"`
}
type Ticket struct {
leBase
Flags *LedgerEntryFlag `json:",omitempty"`
Account *Account `json:",omitempty"`
Sequence *uint32 `json:",omitempty"`
OwnerNode *NodeIndex `json:",omitempty"`
Target *Account `json:",omitempty"`
Expiration *uint32 `json:",omitempty"`
}
func (a *AccountRoot) Affects(account Account) bool {
return a.Account != nil && a.Account.Equals(account)
}
func (r *RippleState) Affects(account Account) bool {
return r.LowLimit.Issuer.Equals(account) || r.HighLimit.Issuer.Equals(account)
}
func (o *Offer) Affects(account Account) bool { return o.Account.Equals(account) }
func (d *Directory) Affects(account Account) bool { return false }
func (l *LedgerHashes) Affects(account Account) bool { return false }
func (a *Amendments) Affects(account Account) bool { return false }
func (f *FeeSettings) Affects(account Account) bool { return false }
func (s *SuspendedPayment) Affects(account Account) bool {
return s.Account.Equals(account) || s.Destination.Equals(account)
}
func (s *SignerList) Affects(account Account) bool {
for _, entry := range s.SignerEntries {
if entry.Account.Equals(account) {
return true
}
}
return false
}
func (t *Ticket) Affects(account Account) bool { return t.Account.Equals(account) }
func (le *leBase) GetType() string { return ledgerEntryNames[le.LedgerEntryType] }
func (le *leBase) GetLedgerEntryType() LedgerEntryType { return le.LedgerEntryType }
func (le *leBase) Prefix() HashPrefix { return HP_LEAF_NODE }
func (le *leBase) NodeType() NodeType { return NT_ACCOUNT_NODE }
func (le *leBase) Ledger() uint32 { return 0 }
func (le *leBase) GetHash() *Hash256 { return &le.Hash }
func (le *leBase) NodeId() *Hash256 { return &le.Id }
func (le *leBase) GetLedgerIndex() *Hash256 { return le.LedgerIndex }
func (le *leBase) GetPreviousTxnId() *Hash256 { return le.PreviousTxnID }
func (o *Offer) Ratio() *Value {
return o.TakerPays.Ratio(*o.TakerGets)
}