Skip to content

Commit 146dd52

Browse files
committed
Address comments
1 parent d222d6e commit 146dd52

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

exp/xdrill/ledgers/ledgers.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (l Ledgers) LedgerVersion() uint32 {
6161
return uint32(l.LedgerHeaderHistoryEntry().Header.LedgerVersion)
6262
}
6363

64-
func (l Ledgers) GetSorobanFeeWrite1Kb() (int64, bool) {
64+
func (l Ledgers) SorobanFeeWrite1Kb() (int64, bool) {
6565
lcmV1, ok := l.GetV1()
6666
if ok {
6767
extV1, ok := lcmV1.Ext.GetV1()
@@ -73,7 +73,7 @@ func (l Ledgers) GetSorobanFeeWrite1Kb() (int64, bool) {
7373
return 0, false
7474
}
7575

76-
func (l Ledgers) GetTotalByteSizeOfBucketList() (uint64, bool) {
76+
func (l Ledgers) TotalByteSizeOfBucketList() (uint64, bool) {
7777
lcmV1, ok := l.GetV1()
7878
if ok {
7979
return uint64(lcmV1.TotalByteSizeOfBucketList), true
@@ -82,7 +82,7 @@ func (l Ledgers) GetTotalByteSizeOfBucketList() (uint64, bool) {
8282
return 0, false
8383
}
8484

85-
func (l Ledgers) GetNodeID() (string, bool) {
85+
func (l Ledgers) NodeID() (string, bool) {
8686
LedgerCloseValueSignature, ok := l.LedgerHeaderHistoryEntry().Header.ScpValue.Ext.GetLcValueSignature()
8787
if ok {
8888
nodeID, ok := utils.GetAddress(LedgerCloseValueSignature.NodeId)
@@ -94,7 +94,7 @@ func (l Ledgers) GetNodeID() (string, bool) {
9494
return "", false
9595
}
9696

97-
func (l Ledgers) GetSignature() (string, bool) {
97+
func (l Ledgers) Signature() (string, bool) {
9898
LedgerCloseValueSignature, ok := l.LedgerHeaderHistoryEntry().Header.ScpValue.Ext.GetLcValueSignature()
9999
if ok {
100100
return base64.StdEncoding.EncodeToString(LedgerCloseValueSignature.Signature), true
@@ -103,7 +103,8 @@ func (l Ledgers) GetSignature() (string, bool) {
103103
return "", false
104104
}
105105

106-
func (l Ledgers) GetTransactionCounts() (successTxCount, failedTxCount int32, ok bool) {
106+
// Add docstring to larger, more complicated functions
107+
func (l Ledgers) TransactionCounts() (successTxCount, failedTxCount int32, ok bool) {
107108
transactions := getTransactionSet(l)
108109
results := l.V0.TxProcessing
109110
txCount := len(transactions)
@@ -122,7 +123,8 @@ func (l Ledgers) GetTransactionCounts() (successTxCount, failedTxCount int32, ok
122123
return successTxCount, failedTxCount, true
123124
}
124125

125-
func (l Ledgers) GetOperationCounts() (operationCount, txSetOperationCount int32, ok bool) {
126+
// Add docstring to larger, more complicated functions
127+
func (l Ledgers) OperationCounts() (operationCount, txSetOperationCount int32, ok bool) {
126128
transactions := getTransactionSet(l)
127129
results := l.V0.TxProcessing
128130
txCount := len(transactions)

exp/xdrill/transform_ledger.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/stellar/go/xdr"
99
)
1010

11-
type LedgerOutput struct {
11+
type LedgerClosedOutput struct {
1212
Sequence uint32 `json:"sequence"` // sequence number of the ledger
1313
LedgerHash string `json:"ledger_hash"`
1414
PreviousLedgerHash string `json:"previous_ledger_hash"`
@@ -32,51 +32,51 @@ type LedgerOutput struct {
3232
TotalByteSizeOfBucketList uint64 `json:"total_byte_size_of_bucket_list"`
3333
}
3434

35-
func TransformLedger(lcm xdr.LedgerCloseMeta) (LedgerOutput, error) {
35+
func TransformLedger(lcm xdr.LedgerCloseMeta) (LedgerClosedOutput, error) {
3636
ledger := ledgers.Ledgers{
3737
LedgerCloseMeta: lcm,
3838
}
3939

4040
outputLedgerHeader, err := xdr.MarshalBase64(ledger.LedgerHeaderHistoryEntry().Header)
4141
if err != nil {
42-
return LedgerOutput{}, err
42+
return LedgerClosedOutput{}, err
4343
}
4444

45-
outputSuccessfulTransactionCount, outputFailedTransactionCount, ok := ledger.GetTransactionCounts()
45+
outputSuccessfulTransactionCount, outputFailedTransactionCount, ok := ledger.TransactionCounts()
4646
if !ok {
47-
return LedgerOutput{}, fmt.Errorf("could not get transaction counts")
47+
return LedgerClosedOutput{}, fmt.Errorf("could not get transaction counts")
4848
}
4949

50-
outputOperationCount, outputTxSetOperationCount, ok := ledger.GetOperationCounts()
50+
outputOperationCount, outputTxSetOperationCount, ok := ledger.OperationCounts()
5151
if !ok {
52-
return LedgerOutput{}, fmt.Errorf("could not get operation counts")
52+
return LedgerClosedOutput{}, fmt.Errorf("could not get operation counts")
5353
}
5454

5555
var outputSorobanFeeWrite1Kb int64
56-
sorobanFeeWrite1Kb, ok := ledger.GetSorobanFeeWrite1Kb()
56+
sorobanFeeWrite1Kb, ok := ledger.SorobanFeeWrite1Kb()
5757
if ok {
5858
outputSorobanFeeWrite1Kb = sorobanFeeWrite1Kb
5959
}
6060

6161
var outputTotalByteSizeOfBucketList uint64
62-
totalByteSizeOfBucketList, ok := ledger.GetTotalByteSizeOfBucketList()
62+
totalByteSizeOfBucketList, ok := ledger.TotalByteSizeOfBucketList()
6363
if ok {
6464
outputTotalByteSizeOfBucketList = totalByteSizeOfBucketList
6565
}
6666

6767
var outputNodeID string
68-
nodeID, ok := ledger.GetNodeID()
68+
nodeID, ok := ledger.NodeID()
6969
if ok {
7070
outputNodeID = nodeID
7171
}
7272

7373
var outputSigature string
74-
signature, ok := ledger.GetSignature()
74+
signature, ok := ledger.Signature()
7575
if ok {
7676
outputSigature = signature
7777
}
7878

79-
ledgerOutput := LedgerOutput{
79+
ledgerOutput := LedgerClosedOutput{
8080
Sequence: ledger.LedgerSequence(),
8181
LedgerHash: ledger.Hash(),
8282
PreviousLedgerHash: ledger.Hash(),

0 commit comments

Comments
 (0)