Skip to content

Commit 61366c9

Browse files
authored
fix: use getter funcs instead of direct access (#369)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 64d59b9 commit 61366c9

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

internal/utxorpc/query.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ func (s *queryServiceServer) ReadUtxos(
114114
for _, txo := range keys {
115115
// txo.Hash, txo.Index
116116
tmpTxIn := ledger.ShelleyTransactionInput{
117-
TxId: ledger.Blake2b256(txo.Hash),
118-
OutputIndex: uint32(txo.Index),
117+
TxId: ledger.Blake2b256(txo.GetHash()),
118+
OutputIndex: uint32(txo.GetIndex()),
119119
}
120120
tmpTxIns = append(tmpTxIns, tmpTxIn)
121121
}
@@ -137,16 +137,16 @@ func (s *queryServiceServer) ReadUtxos(
137137
var aud query.AnyUtxoData
138138
var audc query.AnyUtxoData_Cardano
139139
aud.TxoRef = txo
140-
txHash := hex.EncodeToString(txo.Hash)
140+
txHash := hex.EncodeToString(txo.GetHash())
141141
if utxoId.Hash.String() == txHash &&
142142
// #nosec G115
143-
uint32(utxoId.Idx) == txo.Index {
143+
uint32(utxoId.Idx) == txo.GetIndex() {
144144
aud.NativeBytes = utxo.Cbor()
145145
audc.Cardano = utxo.Utxorpc()
146-
if audc.Cardano.Datum != nil {
146+
if audc.Cardano.GetDatum() != nil {
147147
// Check if Datum.Hash is all zeroes
148148
isAllZeroes := true
149-
for _, b := range audc.Cardano.Datum.Hash {
149+
for _, b := range audc.Cardano.GetDatum().GetHash() {
150150
if b != 0 {
151151
isAllZeroes = false
152152
break
@@ -159,7 +159,7 @@ func (s *queryServiceServer) ReadUtxos(
159159
"Datum Hash is all zeroes; setting Datum to nil",
160160
)
161161
} else {
162-
log.Printf("Datum Hash present: %x", audc.Cardano.Datum.Hash)
162+
log.Printf("Datum Hash present: %x", audc.Cardano.GetDatum().GetHash())
163163
}
164164
}
165165
aud.ParsedState = &audc
@@ -173,8 +173,8 @@ func (s *queryServiceServer) ReadUtxos(
173173
}
174174
log.Printf(
175175
"Prepared response with LedgerTip: Slot=%v, Hash=%v",
176-
resp.LedgerTip.Slot,
177-
resp.LedgerTip.Hash,
176+
resp.GetLedgerTip().GetSlot(),
177+
resp.GetLedgerTip().GetHash(),
178178
)
179179
log.Printf("Final response: %v", resp)
180180
return connect.NewResponse(resp), nil
@@ -282,10 +282,10 @@ func (s *queryServiceServer) SearchUtxos(
282282
// If AssetPattern is specified, filter based on it
283283
if assetPattern != nil {
284284
assetFound := false
285-
for _, multiasset := range audc.Cardano.Assets {
286-
if bytes.Equal(multiasset.PolicyId, assetPattern.PolicyId) {
287-
for _, asset := range multiasset.Assets {
288-
if bytes.Equal(asset.Name, assetPattern.AssetName) {
285+
for _, multiasset := range audc.Cardano.GetAssets() {
286+
if bytes.Equal(multiasset.GetPolicyId(), assetPattern.GetPolicyId()) {
287+
for _, asset := range multiasset.GetAssets() {
288+
if bytes.Equal(asset.GetName(), assetPattern.GetAssetName()) {
289289
assetFound = true
290290
break
291291
}

internal/utxorpc/submit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ func (s *submitServiceServer) WatchMempool(
333333
Stage: submit.Stage_STAGE_MEMPOOL,
334334
}
335335
resp.Tx = record
336-
if string(record.NativeBytes) == cTx.String() {
336+
if string(record.GetNativeBytes()) == cTx.String() {
337337
if predicate == nil {
338338
err := stream.Send(resp)
339339
if err != nil {

0 commit comments

Comments
 (0)