Skip to content

Commit

Permalink
feat: add issuer's vkey and block body size to block interface
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
  • Loading branch information
wolf31o2 committed Oct 16, 2023
1 parent 54800ce commit d66cc41
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 10 deletions.
8 changes: 8 additions & 0 deletions ledger/allegra.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ func (b *AllegraBlock) SlotNumber() uint64 {
return b.Header.SlotNumber()
}

func (b *AllegraBlock) IssuerVkey() []byte {
return b.Header.IssuerVkey()
}

func (b *AllegraBlock) BlockBodySize() uint64 {
return b.Header.BlockBodySize()
}

func (b *AllegraBlock) Era() Era {
return eras[EraIdAllegra]
}
Expand Down
8 changes: 8 additions & 0 deletions ledger/alonzo.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ func (b *AlonzoBlock) SlotNumber() uint64 {
return b.Header.SlotNumber()
}

func (b *AlonzoBlock) IssuerVkey() []byte {
return b.Header.IssuerVkey()
}

func (b *AlonzoBlock) BlockBodySize() uint64 {
return b.Header.BlockBodySize()
}

func (b *AlonzoBlock) Era() Era {
return eras[EraIdAlonzo]
}
Expand Down
26 changes: 21 additions & 5 deletions ledger/babbage.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ func (b *BabbageBlock) SlotNumber() uint64 {
return b.Header.SlotNumber()
}

func (b *BabbageBlock) IssuerVkey() []byte {
return b.Header.IssuerVkey()
}

func (b *BabbageBlock) BlockBodySize() uint64 {
return b.Header.BlockBodySize()
}

func (b *BabbageBlock) Era() Era {
return eras[EraIdBabbage]
}
Expand Down Expand Up @@ -91,17 +99,17 @@ type BabbageBlockHeader struct {
BlockNumber uint64
Slot uint64
PrevHash Blake2b256
IssuerVkey interface{}
VrfKey interface{}
IssuerVkey []byte
VrfKey []byte
VrfResult interface{}
BlockBodySize uint32
BlockBodySize uint64
BlockBodyHash Blake2b256
OpCert struct {
cbor.StructAsArray
HotVkey interface{}
HotVkey []byte
SequenceNumber uint32
KesPeriod uint32
Signature interface{}
Signature []byte
}
ProtoVersion struct {
cbor.StructAsArray
Expand Down Expand Up @@ -131,6 +139,14 @@ func (h *BabbageBlockHeader) SlotNumber() uint64 {
return h.Body.Slot
}

func (h *BabbageBlockHeader) IssuerVkey() []byte {
return h.Body.IssuerVkey
}

func (h *BabbageBlockHeader) BlockBodySize() uint64 {
return h.Body.BlockBodySize
}

func (h *BabbageBlockHeader) Era() Era {
return eras[EraIdBabbage]
}
Expand Down
2 changes: 2 additions & 0 deletions ledger/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type BlockHeader interface {
Hash() string
BlockNumber() uint64
SlotNumber() uint64
IssuerVkey() []byte
BlockBodySize() uint64
Era() Era
Cbor() []byte
}
Expand Down
36 changes: 36 additions & 0 deletions ledger/byron.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ func (h *ByronMainBlockHeader) SlotNumber() uint64 {
return uint64((h.ConsensusData.SlotId.Epoch * ByronSlotsPerEpoch) + uint64(h.ConsensusData.SlotId.Slot))
}

func (h *ByronMainBlockHeader) IssuerVkey() []byte {
// Byron blocks don't have an issuer
return []byte{}
}

func (h *ByronMainBlockHeader) BlockBodySize() uint64 {
// TODO: calculate this
return 0
}

func (h *ByronMainBlockHeader) Era() Era {
return eras[EraIdByron]
}
Expand Down Expand Up @@ -183,6 +193,16 @@ func (h *ByronEpochBoundaryBlockHeader) SlotNumber() uint64 {
return uint64(h.ConsensusData.Epoch * ByronSlotsPerEpoch)
}

func (h *ByronEpochBoundaryBlockHeader) IssuerVkey() []byte {
// Byron blocks don't have an issuer
return []byte{}
}

func (h *ByronEpochBoundaryBlockHeader) BlockBodySize() uint64 {
// TODO: calculate this
return 0
}

func (h *ByronEpochBoundaryBlockHeader) Era() Era {
return eras[EraIdByron]
}
Expand Down Expand Up @@ -211,6 +231,14 @@ func (b *ByronMainBlock) SlotNumber() uint64 {
return b.Header.SlotNumber()
}

func (b *ByronMainBlock) IssuerVkey() []byte {
return b.Header.IssuerVkey()
}

func (b *ByronMainBlock) BlockBodySize() uint64 {
return b.Header.BlockBodySize()
}

func (b *ByronMainBlock) Era() Era {
return b.Header.Era()
}
Expand Down Expand Up @@ -244,6 +272,14 @@ func (b *ByronEpochBoundaryBlock) SlotNumber() uint64 {
return b.Header.SlotNumber()
}

func (b *ByronEpochBoundaryBlock) IssuerVkey() []byte {
return b.Header.IssuerVkey()
}

func (b *ByronEpochBoundaryBlock) BlockBodySize() uint64 {
return b.Header.BlockBodySize()
}

func (b *ByronEpochBoundaryBlock) Era() Era {
return b.Header.Era()
}
Expand Down
8 changes: 8 additions & 0 deletions ledger/mary.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ func (b *MaryBlock) SlotNumber() uint64 {
return b.Header.SlotNumber()
}

func (b *MaryBlock) IssuerVkey() []byte {
return b.Header.IssuerVkey()
}

func (b *MaryBlock) BlockBodySize() uint64 {
return b.Header.BlockBodySize()
}

func (b *MaryBlock) Era() Era {
return eras[EraIdMary]
}
Expand Down
26 changes: 21 additions & 5 deletions ledger/shelley.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ func (b *ShelleyBlock) SlotNumber() uint64 {
return b.Header.SlotNumber()
}

func (b *ShelleyBlock) IssuerVkey() []byte {
return b.Header.IssuerVkey()
}

func (b *ShelleyBlock) BlockBodySize() uint64 {
return b.Header.BlockBodySize()
}

func (b *ShelleyBlock) Era() Era {
return eras[EraIdShelley]
}
Expand All @@ -81,16 +89,16 @@ type ShelleyBlockHeader struct {
BlockNumber uint64
Slot uint64
PrevHash Blake2b256
IssuerVkey interface{}
VrfKey interface{}
IssuerVkey []byte
VrfKey []byte
NonceVrf interface{}
LeaderVrf interface{}
BlockBodySize uint32
BlockBodySize uint64
BlockBodyHash Blake2b256
OpCertHotVkey interface{}
OpCertHotVkey []byte
OpCertSequenceNumber uint32
OpCertKesPeriod uint32
OpCertSignature interface{}
OpCertSignature []byte
ProtoMajorVersion uint64
ProtoMinorVersion uint64
}
Expand All @@ -116,6 +124,14 @@ func (h *ShelleyBlockHeader) SlotNumber() uint64 {
return h.Body.Slot
}

func (h *ShelleyBlockHeader) IssuerVkey() []byte {
return h.Body.IssuerVkey
}

func (h *ShelleyBlockHeader) BlockBodySize() uint64 {
return h.Body.BlockBodySize
}

func (h *ShelleyBlockHeader) Era() Era {
return eras[EraIdShelley]
}
Expand Down

0 comments on commit d66cc41

Please sign in to comment.