Skip to content

Commit

Permalink
Change ledger to Ledger
Browse files Browse the repository at this point in the history
  • Loading branch information
chowbao committed Jan 9, 2025
1 parent d064296 commit 15fe1e5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
46 changes: 23 additions & 23 deletions exp/xdrill/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,59 +10,59 @@ import (
)

type Ledger struct {
ledger *xdr.LedgerCloseMeta
Ledger *xdr.LedgerCloseMeta
}

func (l Ledger) Sequence() uint32 {
return uint32(l.ledger.LedgerHeaderHistoryEntry().Header.LedgerSeq)
return uint32(l.Ledger.LedgerHeaderHistoryEntry().Header.LedgerSeq)
}

func (l Ledger) ID() int64 {
return utils.NewID(int32(l.Sequence()), 0, 0).ToInt64()
}

func (l Ledger) Hash() string {
return utils.HashToHexString(l.ledger.LedgerHeaderHistoryEntry().Hash)
return utils.HashToHexString(l.Ledger.LedgerHeaderHistoryEntry().Hash)
}

func (l Ledger) PreviousHash() string {
return utils.HashToHexString(l.ledger.PreviousLedgerHash())
return utils.HashToHexString(l.Ledger.PreviousLedgerHash())
}

func (l Ledger) CloseTime() int64 {
return l.ledger.LedgerCloseTime()
return l.Ledger.LedgerCloseTime()
}

func (l Ledger) ClosedAt() time.Time {
return time.Unix(l.CloseTime(), 0).UTC()
}

func (l Ledger) TotalCoins() int64 {
return int64(l.ledger.LedgerHeaderHistoryEntry().Header.TotalCoins)
return int64(l.Ledger.LedgerHeaderHistoryEntry().Header.TotalCoins)
}

func (l Ledger) FeePool() int64 {
return int64(l.ledger.LedgerHeaderHistoryEntry().Header.FeePool)
return int64(l.Ledger.LedgerHeaderHistoryEntry().Header.FeePool)
}

func (l Ledger) BaseFee() uint32 {
return uint32(l.ledger.LedgerHeaderHistoryEntry().Header.BaseFee)
return uint32(l.Ledger.LedgerHeaderHistoryEntry().Header.BaseFee)
}

func (l Ledger) BaseReserve() uint32 {
return uint32(l.ledger.LedgerHeaderHistoryEntry().Header.BaseReserve)
return uint32(l.Ledger.LedgerHeaderHistoryEntry().Header.BaseReserve)
}

func (l Ledger) MaxTxSetSize() uint32 {
return uint32(l.ledger.LedgerHeaderHistoryEntry().Header.MaxTxSetSize)
return uint32(l.Ledger.LedgerHeaderHistoryEntry().Header.MaxTxSetSize)
}

func (l Ledger) LedgerVersion() uint32 {
return uint32(l.ledger.LedgerHeaderHistoryEntry().Header.LedgerVersion)
return uint32(l.Ledger.LedgerHeaderHistoryEntry().Header.LedgerVersion)
}

func (l Ledger) SorobanFeeWrite1Kb() *int64 {
lcmV1, ok := l.ledger.GetV1()
lcmV1, ok := l.Ledger.GetV1()
if !ok {
return nil
}
Expand All @@ -78,7 +78,7 @@ func (l Ledger) SorobanFeeWrite1Kb() *int64 {
}

func (l Ledger) TotalByteSizeOfBucketList() *uint64 {
lcmV1, ok := l.ledger.GetV1()
lcmV1, ok := l.Ledger.GetV1()
if !ok {
return nil
}
Expand All @@ -89,7 +89,7 @@ func (l Ledger) TotalByteSizeOfBucketList() *uint64 {
}

func (l Ledger) NodeID() *string {
LedgerCloseValueSignature, ok := l.ledger.LedgerHeaderHistoryEntry().Header.ScpValue.Ext.GetLcValueSignature()
LedgerCloseValueSignature, ok := l.Ledger.LedgerHeaderHistoryEntry().Header.ScpValue.Ext.GetLcValueSignature()
if !ok {
return nil

Expand All @@ -103,7 +103,7 @@ func (l Ledger) NodeID() *string {
}

func (l Ledger) Signature() *string {
LedgerCloseValueSignature, ok := l.ledger.LedgerHeaderHistoryEntry().Header.ScpValue.Ext.GetLcValueSignature()
LedgerCloseValueSignature, ok := l.Ledger.LedgerHeaderHistoryEntry().Header.ScpValue.Ext.GetLcValueSignature()
if !ok {
return nil
}
Expand All @@ -118,7 +118,7 @@ func (l Ledger) TransactionCounts() (successTxCount, failedTxCount int32, ok boo
var results []xdr.TransactionResultMeta

transactions := getTransactionSet(l)
results = l.ledger.TxProcessing()
results = l.Ledger.TxProcessing()
txCount := len(transactions)
if txCount != len(results) {
return 0, 0, false
Expand All @@ -140,7 +140,7 @@ func (l Ledger) OperationCounts() (operationCount, txSetOperationCount int32, ok
var results []xdr.TransactionResultMeta

transactions := getTransactionSet(l)
results = l.ledger.TxProcessing()
results = l.Ledger.TxProcessing()

txCount := len(transactions)
if txCount != len(results) {
Expand Down Expand Up @@ -168,18 +168,18 @@ func (l Ledger) OperationCounts() (operationCount, txSetOperationCount int32, ok
}

func getTransactionSet(l Ledger) (transactionProcessing []xdr.TransactionEnvelope) {
switch l.ledger.V {
switch l.Ledger.V {
case 0:
return l.ledger.V0.TxSet.Txs
return l.Ledger.V0.TxSet.Txs
case 1:
switch l.ledger.V1.TxSet.V {
switch l.Ledger.V1.TxSet.V {
case 0:
return getTransactionPhase(l.ledger.V1.TxSet.V1TxSet.Phases)
return getTransactionPhase(l.Ledger.V1.TxSet.V1TxSet.Phases)
default:
panic(fmt.Sprintf("unsupported LedgerCloseMeta.V1.TxSet.V: %d", l.ledger.V1.TxSet.V))
panic(fmt.Sprintf("unsupported LedgerCloseMeta.V1.TxSet.V: %d", l.Ledger.V1.TxSet.V))
}
default:
panic(fmt.Sprintf("unsupported LedgerCloseMeta.V: %d", l.ledger.V))
panic(fmt.Sprintf("unsupported LedgerCloseMeta.V: %d", l.Ledger.V))
}
}

Check failure on line 184 in exp/xdrill/ledger.go

View workflow job for this annotation

GitHub Actions / golangci

missing return (typecheck)

Expand Down
2 changes: 1 addition & 1 deletion exp/xdrill/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func TestLedger(t *testing.T) {
ledger := Ledger{
ledger: ledgerTestInput(),
Ledger: ledgerTestInput(),
}

assert.Equal(t, uint32(30578981), ledger.Sequence())
Expand Down

0 comments on commit 15fe1e5

Please sign in to comment.