Skip to content

Commit 1440f16

Browse files
authored
refactor(protocol): merge UTxO result types (#1131)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent af5558d commit 1440f16

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

protocol/localstatequery/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ func (c *Client) GetStakeDistribution() (*StakeDistributionResult, error) {
450450
// GetUTxOByAddress returns the UTxOs for a given list of ledger.Address structs
451451
func (c *Client) GetUTxOByAddress(
452452
addrs []ledger.Address,
453-
) (*UTxOByAddressResult, error) {
453+
) (*UTxOsResult, error) {
454454
c.Protocol.Logger().
455455
Debug(fmt.Sprintf("calling GetUTxOByAddress(addrs: %+v)", addrs),
456456
"component", "network",
@@ -469,15 +469,15 @@ func (c *Client) GetUTxOByAddress(
469469
QueryTypeShelleyUtxoByAddress,
470470
addrs,
471471
)
472-
var result UTxOByAddressResult
472+
var result UTxOsResult
473473
if err := c.runQuery(query, &result); err != nil {
474474
return nil, err
475475
}
476476
return &result, nil
477477
}
478478

479479
// GetUTxOWhole returns the current UTxO set
480-
func (c *Client) GetUTxOWhole() (*UTxOWholeResult, error) {
480+
func (c *Client) GetUTxOWhole() (*UTxOsResult, error) {
481481
c.Protocol.Logger().
482482
Debug("calling GetUTxOWhole()",
483483
"component", "network",
@@ -495,7 +495,7 @@ func (c *Client) GetUTxOWhole() (*UTxOWholeResult, error) {
495495
currentEra,
496496
QueryTypeShelleyUtxoWhole,
497497
)
498-
var result UTxOWholeResult
498+
var result UTxOsResult
499499
if err := c.runQuery(query, &result); err != nil {
500500
return nil, err
501501
}

protocol/localstatequery/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Blink Labs Software
1+
// Copyright 2025 Blink Labs Software
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -234,7 +234,7 @@ func TestGetUTxOByAddress(t *testing.T) {
234234
Hash: ledger.NewBlake2b256([]byte{0x1, 0x2}),
235235
Idx: 7,
236236
}
237-
expectedResult := localstatequery.UTxOByAddressResult{
237+
expectedResult := localstatequery.UTxOsResult{
238238
Results: map[localstatequery.UtxoId]ledger.BabbageTransactionOutput{
239239
expectedUtxoId: {
240240
OutputAddress: testAddress,

protocol/localstatequery/queries.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 Blink Labs Software
1+
// Copyright 2025 Blink Labs Software
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -533,11 +533,16 @@ type StakeDistributionResult struct {
533533
}
534534
}
535535

536-
type UTxOByAddressResult struct {
536+
type UTxOsResult struct {
537537
cbor.StructAsArray
538538
Results map[UtxoId]ledger.BabbageTransactionOutput
539539
}
540540

541+
type (
542+
UTxOByAddressResult = UTxOsResult
543+
UTxOWholeResult = UTxOsResult
544+
)
545+
541546
type UtxoId struct {
542547
cbor.StructAsArray
543548
Hash ledger.Blake2b256
@@ -592,15 +597,6 @@ func (u *UtxoId) MarshalCBOR() ([]byte, error) {
592597
return cbor.Encode(tmpData)
593598
}
594599

595-
// TODO (#862)
596-
/*
597-
result [{* utxo => value }]
598-
*/
599-
type UTxOWholeResult struct {
600-
cbor.StructAsArray
601-
Results map[UtxoId]ledger.BabbageTransactionOutput
602-
}
603-
604600
// TODO (#863)
605601
type DebugEpochStateResult any
606602

0 commit comments

Comments
 (0)