Skip to content

Commit 69fdfa5

Browse files
authored
feat: Byron block version updates decode support (#754)
1 parent 160b264 commit 69fdfa5

File tree

1 file changed

+58
-14
lines changed

1 file changed

+58
-14
lines changed

ledger/byron/byron.go

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,10 @@ type ByronMainBlockHeader struct {
7373
}
7474
ExtraData struct {
7575
cbor.StructAsArray
76-
BlockVersion struct {
77-
cbor.StructAsArray
78-
Major uint16
79-
Minor uint16
80-
Unknown uint8
81-
}
82-
SoftwareVersion struct {
83-
cbor.StructAsArray
84-
Name string
85-
Unknown uint32
86-
}
87-
Attributes interface{}
88-
ExtraProof common.Blake2b256
76+
BlockVersion ByronBlockVersion
77+
SoftwareVersion ByronSoftwareVersion
78+
Attributes interface{}
79+
ExtraProof common.Blake2b256
8980
}
9081
}
9182

@@ -422,6 +413,59 @@ func (o ByronTransactionOutput) Utxorpc() *utxorpc.TxOutput {
422413
}
423414
}
424415

416+
type ByronBlockVersion struct {
417+
cbor.StructAsArray
418+
Major uint16
419+
Minor uint16
420+
Unknown uint8
421+
}
422+
423+
type ByronSoftwareVersion struct {
424+
cbor.StructAsArray
425+
Name string
426+
Version uint32
427+
}
428+
429+
type ByronUpdatePayload struct {
430+
cbor.StructAsArray
431+
Proposals []ByronUpdateProposal
432+
Votes []any
433+
}
434+
435+
type ByronUpdateProposal struct {
436+
cbor.DecodeStoreCbor
437+
cbor.StructAsArray
438+
BlockVersion ByronBlockVersion
439+
BlockVersionMod ByronUpdateProposalBlockVersionMod
440+
SoftwareVersion ByronSoftwareVersion
441+
Data any
442+
Attributes any
443+
From []byte
444+
Signature []byte
445+
}
446+
447+
func (p *ByronUpdateProposal) UnmarshalCBOR(data []byte) error {
448+
return p.UnmarshalCbor(data, p)
449+
}
450+
451+
type ByronUpdateProposalBlockVersionMod struct {
452+
cbor.StructAsArray
453+
ScriptVersion []uint16
454+
SlotDuration []uint64
455+
MaxBlockSize []uint64
456+
MaxHeaderSize []uint64
457+
MaxTxSize []uint64
458+
MaxProposalSize []uint64
459+
MpcThd []uint64
460+
HeavyDelThd []uint64
461+
UpdateVoteThd []uint64
462+
UpdateProposalThd []uint64
463+
UpdateImplicit []uint64
464+
SoftForkRule []any
465+
TxFeePolicy []any
466+
UnlockStakeEpoch []uint64
467+
}
468+
425469
type ByronMainBlockBody struct {
426470
cbor.StructAsArray
427471
cbor.DecodeStoreCbor
@@ -434,7 +478,7 @@ type ByronMainBlockBody struct {
434478
}
435479
SscPayload cbor.Value
436480
DlgPayload []interface{}
437-
UpdPayload []interface{}
481+
UpdPayload ByronUpdatePayload
438482
}
439483

440484
func (b *ByronMainBlockBody) UnmarshalCBOR(data []byte) error {

0 commit comments

Comments
 (0)