Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
chowbao committed Nov 4, 2024
1 parent d222d6e commit 146dd52
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
14 changes: 8 additions & 6 deletions exp/xdrill/ledgers/ledgers.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (l Ledgers) LedgerVersion() uint32 {
return uint32(l.LedgerHeaderHistoryEntry().Header.LedgerVersion)
}

func (l Ledgers) GetSorobanFeeWrite1Kb() (int64, bool) {
func (l Ledgers) SorobanFeeWrite1Kb() (int64, bool) {
lcmV1, ok := l.GetV1()

Check failure on line 65 in exp/xdrill/ledgers/ledgers.go

View workflow job for this annotation

GitHub Actions / golangci

l.GetV1 undefined (type Ledgers has no field or method GetV1) (typecheck)
if ok {
extV1, ok := lcmV1.Ext.GetV1()
Expand All @@ -73,7 +73,7 @@ func (l Ledgers) GetSorobanFeeWrite1Kb() (int64, bool) {
return 0, false
}

func (l Ledgers) GetTotalByteSizeOfBucketList() (uint64, bool) {
func (l Ledgers) TotalByteSizeOfBucketList() (uint64, bool) {
lcmV1, ok := l.GetV1()

Check failure on line 77 in exp/xdrill/ledgers/ledgers.go

View workflow job for this annotation

GitHub Actions / golangci

l.GetV1 undefined (type Ledgers has no field or method GetV1) (typecheck)
if ok {
return uint64(lcmV1.TotalByteSizeOfBucketList), true
Expand All @@ -82,7 +82,7 @@ func (l Ledgers) GetTotalByteSizeOfBucketList() (uint64, bool) {
return 0, false
}

func (l Ledgers) GetNodeID() (string, bool) {
func (l Ledgers) NodeID() (string, bool) {
LedgerCloseValueSignature, ok := l.LedgerHeaderHistoryEntry().Header.ScpValue.Ext.GetLcValueSignature()
if ok {
nodeID, ok := utils.GetAddress(LedgerCloseValueSignature.NodeId)
Expand All @@ -94,7 +94,7 @@ func (l Ledgers) GetNodeID() (string, bool) {
return "", false
}

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

func (l Ledgers) GetTransactionCounts() (successTxCount, failedTxCount int32, ok bool) {
// Add docstring to larger, more complicated functions
func (l Ledgers) TransactionCounts() (successTxCount, failedTxCount int32, ok bool) {
transactions := getTransactionSet(l)
results := l.V0.TxProcessing

Check failure on line 109 in exp/xdrill/ledgers/ledgers.go

View workflow job for this annotation

GitHub Actions / golangci

l.V0 undefined (type Ledgers has no field or method V0) (typecheck)
txCount := len(transactions)
Expand All @@ -122,7 +123,8 @@ func (l Ledgers) GetTransactionCounts() (successTxCount, failedTxCount int32, ok
return successTxCount, failedTxCount, true
}

func (l Ledgers) GetOperationCounts() (operationCount, txSetOperationCount int32, ok bool) {
// Add docstring to larger, more complicated functions
func (l Ledgers) OperationCounts() (operationCount, txSetOperationCount int32, ok bool) {
transactions := getTransactionSet(l)
results := l.V0.TxProcessing

Check failure on line 129 in exp/xdrill/ledgers/ledgers.go

View workflow job for this annotation

GitHub Actions / golangci

l.V0 undefined (type Ledgers has no field or method V0) (typecheck)
txCount := len(transactions)
Expand Down
24 changes: 12 additions & 12 deletions exp/xdrill/transform_ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/stellar/go/xdr"
)

type LedgerOutput struct {
type LedgerClosedOutput struct {
Sequence uint32 `json:"sequence"` // sequence number of the ledger
LedgerHash string `json:"ledger_hash"`
PreviousLedgerHash string `json:"previous_ledger_hash"`
Expand All @@ -32,51 +32,51 @@ type LedgerOutput struct {
TotalByteSizeOfBucketList uint64 `json:"total_byte_size_of_bucket_list"`
}

func TransformLedger(lcm xdr.LedgerCloseMeta) (LedgerOutput, error) {
func TransformLedger(lcm xdr.LedgerCloseMeta) (LedgerClosedOutput, error) {
ledger := ledgers.Ledgers{
LedgerCloseMeta: lcm,
}

outputLedgerHeader, err := xdr.MarshalBase64(ledger.LedgerHeaderHistoryEntry().Header)
if err != nil {
return LedgerOutput{}, err
return LedgerClosedOutput{}, err
}

outputSuccessfulTransactionCount, outputFailedTransactionCount, ok := ledger.GetTransactionCounts()
outputSuccessfulTransactionCount, outputFailedTransactionCount, ok := ledger.TransactionCounts()
if !ok {
return LedgerOutput{}, fmt.Errorf("could not get transaction counts")
return LedgerClosedOutput{}, fmt.Errorf("could not get transaction counts")
}

outputOperationCount, outputTxSetOperationCount, ok := ledger.GetOperationCounts()
outputOperationCount, outputTxSetOperationCount, ok := ledger.OperationCounts()
if !ok {
return LedgerOutput{}, fmt.Errorf("could not get operation counts")
return LedgerClosedOutput{}, fmt.Errorf("could not get operation counts")
}

var outputSorobanFeeWrite1Kb int64
sorobanFeeWrite1Kb, ok := ledger.GetSorobanFeeWrite1Kb()
sorobanFeeWrite1Kb, ok := ledger.SorobanFeeWrite1Kb()
if ok {
outputSorobanFeeWrite1Kb = sorobanFeeWrite1Kb
}

var outputTotalByteSizeOfBucketList uint64
totalByteSizeOfBucketList, ok := ledger.GetTotalByteSizeOfBucketList()
totalByteSizeOfBucketList, ok := ledger.TotalByteSizeOfBucketList()
if ok {
outputTotalByteSizeOfBucketList = totalByteSizeOfBucketList
}

var outputNodeID string
nodeID, ok := ledger.GetNodeID()
nodeID, ok := ledger.NodeID()
if ok {
outputNodeID = nodeID
}

var outputSigature string
signature, ok := ledger.GetSignature()
signature, ok := ledger.Signature()
if ok {
outputSigature = signature
}

ledgerOutput := LedgerOutput{
ledgerOutput := LedgerClosedOutput{
Sequence: ledger.LedgerSequence(),
LedgerHash: ledger.Hash(),
PreviousLedgerHash: ledger.Hash(),
Expand Down

0 comments on commit 146dd52

Please sign in to comment.