Skip to content

Commit e28e9be

Browse files
authored
fix(ledger): remove unnecessary type conversions (#912)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent f4d340d commit e28e9be

File tree

6 files changed

+19
-21
lines changed

6 files changed

+19
-21
lines changed

ledger/alonzo/pparams.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ func (p *AlonzoProtocolParameters) Utxorpc() *cardano.PParams {
190190
},
191191
},
192192
MaxExecutionUnitsPerTransaction: &cardano.ExUnits{
193-
Memory: uint64(p.MaxTxExUnits.Memory),
194-
Steps: uint64(p.MaxTxExUnits.Steps),
193+
Memory: p.MaxTxExUnits.Memory,
194+
Steps: p.MaxTxExUnits.Steps,
195195
},
196196
MaxExecutionUnitsPerBlock: &cardano.ExUnits{
197-
Memory: uint64(p.MaxBlockExUnits.Memory),
198-
Steps: uint64(p.MaxBlockExUnits.Steps),
197+
Memory: p.MaxBlockExUnits.Memory,
198+
Steps: p.MaxBlockExUnits.Steps,
199199
},
200200
}
201201
}

ledger/babbage/pparams.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ func (p *BabbageProtocolParameters) Utxorpc() *cardano.PParams {
229229
},
230230
},
231231
MaxExecutionUnitsPerTransaction: &cardano.ExUnits{
232-
Memory: uint64(p.MaxTxExUnits.Memory),
233-
Steps: uint64(p.MaxTxExUnits.Steps),
232+
Memory: p.MaxTxExUnits.Memory,
233+
Steps: p.MaxTxExUnits.Steps,
234234
},
235235
MaxExecutionUnitsPerBlock: &cardano.ExUnits{
236-
Memory: uint64(p.MaxBlockExUnits.Memory),
237-
Steps: uint64(p.MaxBlockExUnits.Steps),
236+
Memory: p.MaxBlockExUnits.Memory,
237+
Steps: p.MaxBlockExUnits.Steps,
238238
},
239239
}
240240
}

ledger/byron/byron.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,8 @@ func (h *ByronMainBlockHeader) BlockNumber() uint64 {
112112
}
113113

114114
func (h *ByronMainBlockHeader) SlotNumber() uint64 {
115-
return uint64(
116-
(h.ConsensusData.SlotId.Epoch * ByronSlotsPerEpoch) + uint64(
117-
h.ConsensusData.SlotId.Slot,
118-
),
115+
return (h.ConsensusData.SlotId.Epoch * ByronSlotsPerEpoch) + uint64(
116+
h.ConsensusData.SlotId.Slot,
119117
)
120118
}
121119

@@ -548,7 +546,7 @@ func (h *ByronEpochBoundaryBlockHeader) BlockNumber() uint64 {
548546
}
549547

550548
func (h *ByronEpochBoundaryBlockHeader) SlotNumber() uint64 {
551-
return uint64(h.ConsensusData.Epoch * ByronSlotsPerEpoch)
549+
return h.ConsensusData.Epoch * ByronSlotsPerEpoch
552550
}
553551

554552
func (h *ByronEpochBoundaryBlockHeader) IssuerVkey() common.IssuerVkey {

ledger/common/address.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ func (a Address) Bytes() []byte {
405405
ret := []byte{}
406406
ret = append(
407407
ret,
408-
(byte(a.addressType)<<4)|(byte(a.networkId)&AddressHeaderNetworkMask),
408+
(a.addressType<<4)|(a.networkId&AddressHeaderNetworkMask),
409409
)
410410
ret = append(ret, a.paymentAddress...)
411411
ret = append(ret, a.stakingAddress...)

ledger/common/common.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func NewBlake2b256(data []byte) Blake2b256 {
4040
}
4141

4242
func (b Blake2b256) String() string {
43-
return hex.EncodeToString([]byte(b[:]))
43+
return hex.EncodeToString(b[:])
4444
}
4545

4646
func (b Blake2b256) Bytes() []byte {
@@ -71,7 +71,7 @@ func NewBlake2b224(data []byte) Blake2b224 {
7171
}
7272

7373
func (b Blake2b224) String() string {
74-
return hex.EncodeToString([]byte(b[:]))
74+
return hex.EncodeToString(b[:])
7575
}
7676

7777
func (b Blake2b224) Bytes() []byte {
@@ -106,7 +106,7 @@ func NewBlake2b160(data []byte) Blake2b160 {
106106
}
107107

108108
func (b Blake2b160) String() string {
109-
return hex.EncodeToString([]byte(b[:]))
109+
return hex.EncodeToString(b[:])
110110
}
111111

112112
func (b Blake2b160) Bytes() []byte {

ledger/conway/pparams.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ func (p *ConwayProtocolParameters) Utxorpc() *cardano.PParams {
132132
},
133133
},
134134
MaxExecutionUnitsPerTransaction: &cardano.ExUnits{
135-
Memory: uint64(p.MaxTxExUnits.Memory),
136-
Steps: uint64(p.MaxTxExUnits.Steps),
135+
Memory: p.MaxTxExUnits.Memory,
136+
Steps: p.MaxTxExUnits.Steps,
137137
},
138138
MaxExecutionUnitsPerBlock: &cardano.ExUnits{
139-
Memory: uint64(p.MaxBlockExUnits.Memory),
140-
Steps: uint64(p.MaxBlockExUnits.Steps),
139+
Memory: p.MaxBlockExUnits.Memory,
140+
Steps: p.MaxBlockExUnits.Steps,
141141
},
142142
}
143143
}

0 commit comments

Comments
 (0)