Skip to content

Commit e7f2e2e

Browse files
authored
fix: use LazyValue for metadata to avoid decoding issues (#638)
The TX metadata isn't guaranteed to be well-formed, so we don't decode it immediately
1 parent 6eebf27 commit e7f2e2e

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

ledger/allegra.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type AllegraBlock struct {
3939
Header *AllegraBlockHeader
4040
TransactionBodies []AllegraTransactionBody
4141
TransactionWitnessSets []ShelleyTransactionWitnessSet
42-
TransactionMetadataSet map[uint]*cbor.Value
42+
TransactionMetadataSet map[uint]*cbor.LazyValue
4343
}
4444

4545
func (b *AllegraBlock) UnmarshalCBOR(cborData []byte) error {
@@ -135,7 +135,7 @@ type AllegraTransaction struct {
135135
cbor.DecodeStoreCbor
136136
Body AllegraTransactionBody
137137
WitnessSet ShelleyTransactionWitnessSet
138-
TxMetadata *cbor.Value
138+
TxMetadata *cbor.LazyValue
139139
}
140140

141141
func (t AllegraTransaction) Hash() string {
@@ -210,7 +210,7 @@ func (t AllegraTransaction) ProposalProcedures() []ProposalProcedure {
210210
return t.Body.ProposalProcedures()
211211
}
212212

213-
func (t AllegraTransaction) Metadata() *cbor.Value {
213+
func (t AllegraTransaction) Metadata() *cbor.LazyValue {
214214
return t.TxMetadata
215215
}
216216

ledger/alonzo.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type AlonzoBlock struct {
4040
Header *AlonzoBlockHeader
4141
TransactionBodies []AlonzoTransactionBody
4242
TransactionWitnessSets []AlonzoTransactionWitnessSet
43-
TransactionMetadataSet map[uint]*cbor.Value
43+
TransactionMetadataSet map[uint]*cbor.LazyValue
4444
InvalidTransactions []uint
4545
}
4646

@@ -249,7 +249,7 @@ type AlonzoTransaction struct {
249249
Body AlonzoTransactionBody
250250
WitnessSet AlonzoTransactionWitnessSet
251251
IsTxValid bool
252-
TxMetadata *cbor.Value
252+
TxMetadata *cbor.LazyValue
253253
}
254254

255255
func (t AlonzoTransaction) Hash() string {
@@ -324,7 +324,7 @@ func (t AlonzoTransaction) ProposalProcedures() []ProposalProcedure {
324324
return t.Body.ProposalProcedures()
325325
}
326326

327-
func (t AlonzoTransaction) Metadata() *cbor.Value {
327+
func (t AlonzoTransaction) Metadata() *cbor.LazyValue {
328328
return t.TxMetadata
329329
}
330330

ledger/babbage.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type BabbageBlock struct {
4040
Header *BabbageBlockHeader
4141
TransactionBodies []BabbageTransactionBody
4242
TransactionWitnessSets []BabbageTransactionWitnessSet
43-
TransactionMetadataSet map[uint]*cbor.Value
43+
TransactionMetadataSet map[uint]*cbor.LazyValue
4444
InvalidTransactions []uint
4545
}
4646

@@ -417,7 +417,7 @@ type BabbageTransaction struct {
417417
Body BabbageTransactionBody
418418
WitnessSet BabbageTransactionWitnessSet
419419
IsTxValid bool
420-
TxMetadata *cbor.Value
420+
TxMetadata *cbor.LazyValue
421421
}
422422

423423
func (t BabbageTransaction) Hash() string {
@@ -492,7 +492,7 @@ func (t BabbageTransaction) ProposalProcedures() []ProposalProcedure {
492492
return t.Body.ProposalProcedures()
493493
}
494494

495-
func (t BabbageTransaction) Metadata() *cbor.Value {
495+
func (t BabbageTransaction) Metadata() *cbor.LazyValue {
496496
return t.TxMetadata
497497
}
498498

ledger/byron.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ type ByronTransaction struct {
126126
hash string
127127
TxInputs []ByronTransactionInput
128128
TxOutputs []ByronTransactionOutput
129-
Attributes *cbor.Value
129+
Attributes *cbor.LazyValue
130130
}
131131

132132
func (t *ByronTransaction) UnmarshalCBOR(data []byte) error {
@@ -235,7 +235,7 @@ func (t *ByronTransaction) ProposalProcedures() []ProposalProcedure {
235235
return nil
236236
}
237237

238-
func (t *ByronTransaction) Metadata() *cbor.Value {
238+
func (t *ByronTransaction) Metadata() *cbor.LazyValue {
239239
return t.Attributes
240240
}
241241

ledger/conway.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type ConwayBlock struct {
3939
Header *ConwayBlockHeader
4040
TransactionBodies []ConwayTransactionBody
4141
TransactionWitnessSets []BabbageTransactionWitnessSet
42-
TransactionMetadataSet map[uint]*cbor.Value
42+
TransactionMetadataSet map[uint]*cbor.LazyValue
4343
InvalidTransactions []uint
4444
}
4545

@@ -322,7 +322,7 @@ type ConwayTransaction struct {
322322
Body ConwayTransactionBody
323323
WitnessSet BabbageTransactionWitnessSet
324324
IsTxValid bool
325-
TxMetadata *cbor.Value
325+
TxMetadata *cbor.LazyValue
326326
}
327327

328328
func (t ConwayTransaction) Hash() string {
@@ -397,7 +397,7 @@ func (t ConwayTransaction) ProposalProcedures() []ProposalProcedure {
397397
return t.Body.ProposalProcedures()
398398
}
399399

400-
func (t ConwayTransaction) Metadata() *cbor.Value {
400+
func (t ConwayTransaction) Metadata() *cbor.LazyValue {
401401
return t.TxMetadata
402402
}
403403

ledger/mary.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type MaryBlock struct {
4040
Header *MaryBlockHeader
4141
TransactionBodies []MaryTransactionBody
4242
TransactionWitnessSets []MaryTransactionWitnessSet
43-
TransactionMetadataSet map[uint]*cbor.Value
43+
TransactionMetadataSet map[uint]*cbor.LazyValue
4444
}
4545

4646
func (b *MaryBlock) UnmarshalCBOR(cborData []byte) error {
@@ -146,7 +146,7 @@ type MaryTransaction struct {
146146
cbor.DecodeStoreCbor
147147
Body MaryTransactionBody
148148
WitnessSet MaryTransactionWitnessSet
149-
TxMetadata *cbor.Value
149+
TxMetadata *cbor.LazyValue
150150
}
151151

152152
type MaryTransactionWitnessSet struct {
@@ -227,7 +227,7 @@ func (t MaryTransaction) ProposalProcedures() []ProposalProcedure {
227227
return t.Body.ProposalProcedures()
228228
}
229229

230-
func (t MaryTransaction) Metadata() *cbor.Value {
230+
func (t MaryTransaction) Metadata() *cbor.LazyValue {
231231
return t.TxMetadata
232232
}
233233

ledger/shelley.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type ShelleyBlock struct {
3939
Header *ShelleyBlockHeader
4040
TransactionBodies []ShelleyTransactionBody
4141
TransactionWitnessSets []ShelleyTransactionWitnessSet
42-
TransactionMetadataSet map[uint]*cbor.Value
42+
TransactionMetadataSet map[uint]*cbor.LazyValue
4343
}
4444

4545
func (b *ShelleyBlock) UnmarshalCBOR(cborData []byte) error {
@@ -389,7 +389,7 @@ type ShelleyTransaction struct {
389389
cbor.DecodeStoreCbor
390390
Body ShelleyTransactionBody
391391
WitnessSet ShelleyTransactionWitnessSet
392-
TxMetadata *cbor.Value
392+
TxMetadata *cbor.LazyValue
393393
}
394394

395395
func (t ShelleyTransaction) Hash() string {
@@ -464,7 +464,7 @@ func (t ShelleyTransaction) ProposalProcedures() []ProposalProcedure {
464464
return t.Body.ProposalProcedures()
465465
}
466466

467-
func (t ShelleyTransaction) Metadata() *cbor.Value {
467+
func (t ShelleyTransaction) Metadata() *cbor.LazyValue {
468468
return t.TxMetadata
469469
}
470470

ledger/tx.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
type Transaction interface {
2828
TransactionBody
29-
Metadata() *cbor.Value
29+
Metadata() *cbor.LazyValue
3030
IsValid() bool
3131
Consumed() []TransactionInput
3232
Produced() []TransactionOutput

0 commit comments

Comments
 (0)