Skip to content

Commit 8c92a01

Browse files
authored
chore: make format golines (#904)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 64ecd92 commit 8c92a01

File tree

14 files changed

+340
-84
lines changed

14 files changed

+340
-84
lines changed

ledger/allegra/rules.go

Lines changed: 84 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ var UtxoValidationRules = []common.UtxoValidationRuleFunc{
3535
}
3636

3737
// UtxoValidateOutsideValidityIntervalUtxo ensures that the current tip slot has reached the specified validity interval
38-
func UtxoValidateOutsideValidityIntervalUtxo(tx common.Transaction, slot uint64, _ common.LedgerState, _ common.ProtocolParameters) error {
38+
func UtxoValidateOutsideValidityIntervalUtxo(
39+
tx common.Transaction,
40+
slot uint64,
41+
_ common.LedgerState,
42+
_ common.ProtocolParameters,
43+
) error {
3944
validityIntervalStart := tx.ValidityIntervalStart()
4045
if validityIntervalStart == 0 || slot >= validityIntervalStart {
4146
return nil
@@ -46,54 +51,119 @@ func UtxoValidateOutsideValidityIntervalUtxo(tx common.Transaction, slot uint64,
4651
}
4752
}
4853

49-
func UtxoValidateInputSetEmptyUtxo(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
54+
func UtxoValidateInputSetEmptyUtxo(
55+
tx common.Transaction,
56+
slot uint64,
57+
ls common.LedgerState,
58+
pp common.ProtocolParameters,
59+
) error {
5060
return shelley.UtxoValidateInputSetEmptyUtxo(tx, slot, ls, pp)
5161
}
5262

53-
func UtxoValidateFeeTooSmallUtxo(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
63+
func UtxoValidateFeeTooSmallUtxo(
64+
tx common.Transaction,
65+
slot uint64,
66+
ls common.LedgerState,
67+
pp common.ProtocolParameters,
68+
) error {
5469
tmpPparams, ok := pp.(*AllegraProtocolParameters)
5570
if !ok {
5671
return fmt.Errorf("pparams are not expected type")
5772
}
58-
return shelley.UtxoValidateFeeTooSmallUtxo(tx, slot, ls, &tmpPparams.ShelleyProtocolParameters)
73+
return shelley.UtxoValidateFeeTooSmallUtxo(
74+
tx,
75+
slot,
76+
ls,
77+
&tmpPparams.ShelleyProtocolParameters,
78+
)
5979
}
6080

61-
func UtxoValidateBadInputsUtxo(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
81+
func UtxoValidateBadInputsUtxo(
82+
tx common.Transaction,
83+
slot uint64,
84+
ls common.LedgerState,
85+
pp common.ProtocolParameters,
86+
) error {
6287
return shelley.UtxoValidateBadInputsUtxo(tx, slot, ls, pp)
6388
}
6489

65-
func UtxoValidateWrongNetwork(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
90+
func UtxoValidateWrongNetwork(
91+
tx common.Transaction,
92+
slot uint64,
93+
ls common.LedgerState,
94+
pp common.ProtocolParameters,
95+
) error {
6696
return shelley.UtxoValidateWrongNetwork(tx, slot, ls, pp)
6797
}
6898

69-
func UtxoValidateWrongNetworkWithdrawal(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
99+
func UtxoValidateWrongNetworkWithdrawal(
100+
tx common.Transaction,
101+
slot uint64,
102+
ls common.LedgerState,
103+
pp common.ProtocolParameters,
104+
) error {
70105
return shelley.UtxoValidateWrongNetworkWithdrawal(tx, slot, ls, pp)
71106
}
72107

73-
func UtxoValidateValueNotConservedUtxo(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
108+
func UtxoValidateValueNotConservedUtxo(
109+
tx common.Transaction,
110+
slot uint64,
111+
ls common.LedgerState,
112+
pp common.ProtocolParameters,
113+
) error {
74114
tmpPparams, ok := pp.(*AllegraProtocolParameters)
75115
if !ok {
76116
return fmt.Errorf("pparams are not expected type")
77117
}
78-
return shelley.UtxoValidateValueNotConservedUtxo(tx, slot, ls, &tmpPparams.ShelleyProtocolParameters)
118+
return shelley.UtxoValidateValueNotConservedUtxo(
119+
tx,
120+
slot,
121+
ls,
122+
&tmpPparams.ShelleyProtocolParameters,
123+
)
79124
}
80125

81-
func UtxoValidateOutputTooSmallUtxo(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
126+
func UtxoValidateOutputTooSmallUtxo(
127+
tx common.Transaction,
128+
slot uint64,
129+
ls common.LedgerState,
130+
pp common.ProtocolParameters,
131+
) error {
82132
tmpPparams, ok := pp.(*AllegraProtocolParameters)
83133
if !ok {
84134
return fmt.Errorf("pparams are not expected type")
85135
}
86-
return shelley.UtxoValidateOutputTooSmallUtxo(tx, slot, ls, &tmpPparams.ShelleyProtocolParameters)
136+
return shelley.UtxoValidateOutputTooSmallUtxo(
137+
tx,
138+
slot,
139+
ls,
140+
&tmpPparams.ShelleyProtocolParameters,
141+
)
87142
}
88143

89-
func UtxoValidateOutputBootAddrAttrsTooBig(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
144+
func UtxoValidateOutputBootAddrAttrsTooBig(
145+
tx common.Transaction,
146+
slot uint64,
147+
ls common.LedgerState,
148+
pp common.ProtocolParameters,
149+
) error {
90150
return shelley.UtxoValidateOutputBootAddrAttrsTooBig(tx, slot, ls, pp)
91151
}
92152

93-
func UtxoValidateMaxTxSizeUtxo(tx common.Transaction, slot uint64, ls common.LedgerState, pp common.ProtocolParameters) error {
153+
func UtxoValidateMaxTxSizeUtxo(
154+
tx common.Transaction,
155+
slot uint64,
156+
ls common.LedgerState,
157+
pp common.ProtocolParameters,
158+
) error {
94159
tmpPparams, ok := pp.(*AllegraProtocolParameters)
95160
if !ok {
96161
return fmt.Errorf("pparams are not expected type")
97162
}
98-
return shelley.UtxoValidateMaxTxSizeUtxo(tx, slot, ls, &tmpPparams.ShelleyProtocolParameters)
163+
return shelley.UtxoValidateMaxTxSizeUtxo(
164+
tx,
165+
slot,
166+
ls,
167+
&tmpPparams.ShelleyProtocolParameters,
168+
)
99169
}

ledger/allegra/rules_test.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ func (ls testLedgerState) NetworkId() uint {
3636
return ls.networkId
3737
}
3838

39-
func (ls testLedgerState) UtxoById(id common.TransactionInput) (common.Utxo, error) {
39+
func (ls testLedgerState) UtxoById(
40+
id common.TransactionInput,
41+
) (common.Utxo, error) {
4042
for _, tmpUtxo := range ls.utxos {
4143
if id.Index() != tmpUtxo.Id.Index() {
4244
continue
@@ -383,8 +385,12 @@ func TestUtxoValidateBadInputsUtxo(t *testing.T) {
383385
}
384386

385387
func TestUtxoValidateWrongNetwork(t *testing.T) {
386-
testCorrectNetworkAddr, _ := common.NewAddress("addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd")
387-
testWrongNetworkAddr, _ := common.NewAddress("addr_test1qqx80sj9nwxdnglmzdl95v2k40d9422au0klwav8jz2dj985v0wma0mza32f8z6pv2jmkn7cen50f9vn9jmp7dd0njcqqpce07")
388+
testCorrectNetworkAddr, _ := common.NewAddress(
389+
"addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd",
390+
)
391+
testWrongNetworkAddr, _ := common.NewAddress(
392+
"addr_test1qqx80sj9nwxdnglmzdl95v2k40d9422au0klwav8jz2dj985v0wma0mza32f8z6pv2jmkn7cen50f9vn9jmp7dd0njcqqpce07",
393+
)
388394
testTx := &allegra.AllegraTransaction{
389395
Body: allegra.AllegraTransactionBody{
390396
ShelleyTransactionBody: shelley.ShelleyTransactionBody{
@@ -451,8 +457,12 @@ func TestUtxoValidateWrongNetwork(t *testing.T) {
451457
}
452458

453459
func TestUtxoValidateWrongNetworkWithdrawal(t *testing.T) {
454-
testCorrectNetworkAddr, _ := common.NewAddress("addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd")
455-
testWrongNetworkAddr, _ := common.NewAddress("addr_test1qqx80sj9nwxdnglmzdl95v2k40d9422au0klwav8jz2dj985v0wma0mza32f8z6pv2jmkn7cen50f9vn9jmp7dd0njcqqpce07")
460+
testCorrectNetworkAddr, _ := common.NewAddress(
461+
"addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd",
462+
)
463+
testWrongNetworkAddr, _ := common.NewAddress(
464+
"addr_test1qqx80sj9nwxdnglmzdl95v2k40d9422au0klwav8jz2dj985v0wma0mza32f8z6pv2jmkn7cen50f9vn9jmp7dd0njcqqpce07",
465+
)
456466
testTx := &allegra.AllegraTransaction{
457467
Body: allegra.AllegraTransactionBody{
458468
ShelleyTransactionBody: shelley.ShelleyTransactionBody{
@@ -696,7 +706,9 @@ func TestUtxoValidateOutputTooSmallUtxo(t *testing.T) {
696706
}
697707

698708
func TestUtxoValidateOutputBootAddrAttrsTooBig(t *testing.T) {
699-
testGoodAddr, _ := common.NewAddress("addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd")
709+
testGoodAddr, _ := common.NewAddress(
710+
"addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd",
711+
)
700712
// Generate random pubkey
701713
testBadAddrPubkey := make([]byte, 28)
702714
if _, err := rand.Read(testBadAddrPubkey); err != nil {

ledger/alonzo/alonzo.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,10 @@ func (r AlonzoRedeemers) Indexes(tag common.RedeemerTag) []uint {
322322
return ret
323323
}
324324

325-
func (r AlonzoRedeemers) Value(index uint, tag common.RedeemerTag) (cbor.LazyValue, common.RedeemerExUnits) {
325+
func (r AlonzoRedeemers) Value(
326+
index uint,
327+
tag common.RedeemerTag,
328+
) (cbor.LazyValue, common.RedeemerExUnits) {
326329
for _, redeemer := range r {
327330
if redeemer.Tag == tag && uint(redeemer.Index) == index {
328331
return redeemer.Data, redeemer.ExUnits

ledger/alonzo/pparams.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,27 @@ func (p *AlonzoProtocolParameters) Utxorpc() *cardano.PParams {
122122
if p.A0.Num().Int64() > math.MaxInt32 ||
123123
p.A0.Denom().Int64() < 0 ||
124124
p.A0.Denom().Int64() > math.MaxUint32 {
125-
return nil
125+
return nil
126126
}
127127
if p.Rho.Num().Int64() > math.MaxInt32 ||
128128
p.Rho.Denom().Int64() < 0 ||
129129
p.Rho.Denom().Int64() > math.MaxUint32 {
130-
return nil
130+
return nil
131131
}
132132
if p.Tau.Num().Int64() > math.MaxInt32 ||
133133
p.Tau.Denom().Int64() < 0 ||
134134
p.Tau.Denom().Int64() > math.MaxUint32 {
135-
return nil
135+
return nil
136136
}
137137
if p.ExecutionCosts.MemPrice.Num().Int64() > math.MaxInt32 ||
138138
p.ExecutionCosts.MemPrice.Denom().Int64() < 0 ||
139139
p.ExecutionCosts.MemPrice.Denom().Int64() > math.MaxUint32 {
140-
return nil
140+
return nil
141141
}
142142
if p.ExecutionCosts.StepPrice.Num().Int64() > math.MaxInt32 ||
143143
p.ExecutionCosts.StepPrice.Denom().Int64() < 0 ||
144144
p.ExecutionCosts.StepPrice.Denom().Int64() > math.MaxUint32 {
145-
return nil
145+
return nil
146146
}
147147
// #nosec G115
148148
return &cardano.PParams{

ledger/babbage/pparams.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,27 +161,27 @@ func (p *BabbageProtocolParameters) Utxorpc() *cardano.PParams {
161161
if p.A0.Num().Int64() > math.MaxInt32 ||
162162
p.A0.Denom().Int64() < 0 ||
163163
p.A0.Denom().Int64() > math.MaxUint32 {
164-
return nil
164+
return nil
165165
}
166166
if p.Rho.Num().Int64() > math.MaxInt32 ||
167167
p.Rho.Denom().Int64() < 0 ||
168168
p.Rho.Denom().Int64() > math.MaxUint32 {
169-
return nil
169+
return nil
170170
}
171171
if p.Tau.Num().Int64() > math.MaxInt32 ||
172172
p.Tau.Denom().Int64() < 0 ||
173173
p.Tau.Denom().Int64() > math.MaxUint32 {
174-
return nil
174+
return nil
175175
}
176176
if p.ExecutionCosts.MemPrice.Num().Int64() > math.MaxInt32 ||
177177
p.ExecutionCosts.MemPrice.Denom().Int64() < 0 ||
178178
p.ExecutionCosts.MemPrice.Denom().Int64() > math.MaxUint32 {
179-
return nil
179+
return nil
180180
}
181181
if p.ExecutionCosts.StepPrice.Num().Int64() > math.MaxInt32 ||
182182
p.ExecutionCosts.StepPrice.Denom().Int64() < 0 ||
183183
p.ExecutionCosts.StepPrice.Denom().Int64() > math.MaxUint32 {
184-
return nil
184+
return nil
185185
}
186186
// #nosec G115
187187
return &cardano.PParams{

ledger/conway/conway.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,10 @@ func (r ConwayRedeemers) Indexes(tag common.RedeemerTag) []uint {
200200
return ret
201201
}
202202

203-
func (r ConwayRedeemers) Value(index uint, tag common.RedeemerTag) (cbor.LazyValue, common.RedeemerExUnits) {
203+
func (r ConwayRedeemers) Value(
204+
index uint,
205+
tag common.RedeemerTag,
206+
) (cbor.LazyValue, common.RedeemerExUnits) {
204207
redeemer, ok := r.Redeemers[ConwayRedeemerKey{
205208
Tag: tag,
206209
Index: uint32(index), // #nosec G115

ledger/conway/pparams.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,27 @@ func (p *ConwayProtocolParameters) Utxorpc() *cardano.PParams {
6464
if p.A0.Num().Int64() > math.MaxInt32 ||
6565
p.A0.Denom().Int64() < 0 ||
6666
p.A0.Denom().Int64() > math.MaxUint32 {
67-
return nil
67+
return nil
6868
}
6969
if p.Rho.Num().Int64() > math.MaxInt32 ||
7070
p.Rho.Denom().Int64() < 0 ||
7171
p.Rho.Denom().Int64() > math.MaxUint32 {
72-
return nil
72+
return nil
7373
}
7474
if p.Tau.Num().Int64() > math.MaxInt32 ||
7575
p.Tau.Denom().Int64() < 0 ||
7676
p.Tau.Denom().Int64() > math.MaxUint32 {
77-
return nil
77+
return nil
7878
}
7979
if p.ExecutionCosts.MemPrice.Num().Int64() > math.MaxInt32 ||
8080
p.ExecutionCosts.MemPrice.Denom().Int64() < 0 ||
8181
p.ExecutionCosts.MemPrice.Denom().Int64() > math.MaxUint32 {
82-
return nil
82+
return nil
8383
}
8484
if p.ExecutionCosts.StepPrice.Num().Int64() > math.MaxInt32 ||
8585
p.ExecutionCosts.StepPrice.Denom().Int64() < 0 ||
8686
p.ExecutionCosts.StepPrice.Denom().Int64() > math.MaxUint32 {
87-
return nil
87+
return nil
8888
}
8989
// #nosec G115
9090
return &cardano.PParams{

0 commit comments

Comments
 (0)