forked from rubblelabs/ripple
/
ledger.go
37 lines (33 loc) · 1.29 KB
/
ledger.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
package data
type LedgerHeader struct {
LedgerSequence uint32 `json:"ledger_index,string"`
TotalXRP uint64 `json:"total_coins,string"`
PreviousLedger Hash256 `json:"parent_hash"`
TransactionHash Hash256 `json:"transaction_hash"`
StateHash Hash256 `json:"account_hash"`
ParentCloseTime RippleTime `json:"parent_close_time"`
CloseTime RippleTime `json:"close_time"`
CloseResolution uint8 `json:"close_time_resolution"`
CloseFlags uint8 `json:"close_flags"`
}
type Ledger struct {
LedgerHeader
Hash Hash256 `json:"hash"`
Closed bool `json:"closed"`
Accepted bool `json:"accepted"`
Transactions TransactionSlice `json:"transactions,omitempty"`
AccountState LedgerEntrySlice `json:"accountState,omitempty"`
}
func NewEmptyLedger(sequence uint32) *Ledger {
return &Ledger{
LedgerHeader: LedgerHeader{
LedgerSequence: sequence,
},
}
}
func (l Ledger) GetType() string { return "LedgerMaster" }
func (l Ledger) Prefix() HashPrefix { return HP_LEDGER_MASTER }
func (l Ledger) NodeType() NodeType { return NT_LEDGER }
func (l Ledger) Ledger() uint32 { return l.LedgerSequence }
func (l Ledger) NodeId() *Hash256 { return &l.Hash }
func (l Ledger) GetHash() *Hash256 { return &l.Hash }