Skip to content

Commit 8669bbf

Browse files
committed
feat: add issuer's vkey and block body size to block interface
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 54800ce commit 8669bbf

File tree

7 files changed

+104
-10
lines changed

7 files changed

+104
-10
lines changed

ledger/allegra.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ func (b *AllegraBlock) SlotNumber() uint64 {
5555
return b.Header.SlotNumber()
5656
}
5757

58+
func (b *AllegraBlock) IssuerVkey() []byte {
59+
return b.Header.IssuerVkey()
60+
}
61+
62+
func (b *AllegraBlock) BlockBodySize() uint64 {
63+
return b.Header.BlockBodySize()
64+
}
65+
5866
func (b *AllegraBlock) Era() Era {
5967
return eras[EraIdAllegra]
6068
}

ledger/alonzo.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ func (b *AlonzoBlock) SlotNumber() uint64 {
5757
return b.Header.SlotNumber()
5858
}
5959

60+
func (b *AlonzoBlock) IssuerVkey() []byte {
61+
return b.Header.IssuerVkey()
62+
}
63+
64+
func (b *AlonzoBlock) BlockBodySize() uint64 {
65+
return b.Header.BlockBodySize()
66+
}
67+
6068
func (b *AlonzoBlock) Era() Era {
6169
return eras[EraIdAlonzo]
6270
}

ledger/babbage.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ func (b *BabbageBlock) SlotNumber() uint64 {
5757
return b.Header.SlotNumber()
5858
}
5959

60+
func (b *BabbageBlock) IssuerVkey() []byte {
61+
return b.Header.IssuerVkey()
62+
}
63+
64+
func (b *BabbageBlock) BlockBodySize() uint64 {
65+
return b.Header.BlockBodySize()
66+
}
67+
6068
func (b *BabbageBlock) Era() Era {
6169
return eras[EraIdBabbage]
6270
}
@@ -91,17 +99,17 @@ type BabbageBlockHeader struct {
9199
BlockNumber uint64
92100
Slot uint64
93101
PrevHash Blake2b256
94-
IssuerVkey interface{}
95-
VrfKey interface{}
102+
IssuerVkey []byte
103+
VrfKey []byte
96104
VrfResult interface{}
97-
BlockBodySize uint32
105+
BlockBodySize uint64
98106
BlockBodyHash Blake2b256
99107
OpCert struct {
100108
cbor.StructAsArray
101-
HotVkey interface{}
109+
HotVkey []byte
102110
SequenceNumber uint32
103111
KesPeriod uint32
104-
Signature interface{}
112+
Signature []byte
105113
}
106114
ProtoVersion struct {
107115
cbor.StructAsArray
@@ -131,6 +139,14 @@ func (h *BabbageBlockHeader) SlotNumber() uint64 {
131139
return h.Body.Slot
132140
}
133141

142+
func (h *BabbageBlockHeader) IssuerVkey() []byte {
143+
return h.Body.IssuerVkey
144+
}
145+
146+
func (h *BabbageBlockHeader) BlockBodySize() uint64 {
147+
return h.Body.BlockBodySize
148+
}
149+
134150
func (h *BabbageBlockHeader) Era() Era {
135151
return eras[EraIdBabbage]
136152
}

ledger/block.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ type BlockHeader interface {
3030
Hash() string
3131
BlockNumber() uint64
3232
SlotNumber() uint64
33+
IssuerVkey() []byte
34+
BlockBodySize() uint64
3335
Era() Era
3436
Cbor() []byte
3537
}

ledger/byron.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ func (h *ByronMainBlockHeader) SlotNumber() uint64 {
9696
return uint64((h.ConsensusData.SlotId.Epoch * ByronSlotsPerEpoch) + uint64(h.ConsensusData.SlotId.Slot))
9797
}
9898

99+
func (h *ByronMainBlockHeader) IssuerVkey() []byte {
100+
// Byron blocks don't have an issuer
101+
return nil
102+
}
103+
104+
func (h *ByronMainBlockHeader) BlockBodySize() uint64 {
105+
// TODO: calculate this
106+
return 0
107+
}
108+
99109
func (h *ByronMainBlockHeader) Era() Era {
100110
return eras[EraIdByron]
101111
}
@@ -183,6 +193,16 @@ func (h *ByronEpochBoundaryBlockHeader) SlotNumber() uint64 {
183193
return uint64(h.ConsensusData.Epoch * ByronSlotsPerEpoch)
184194
}
185195

196+
func (h *ByronEpochBoundaryBlockHeader) IssuerVkey() []byte {
197+
// Byron blocks don't have an issuer
198+
return nil
199+
}
200+
201+
func (h *ByronEpochBoundaryBlockHeader) BlockBodySize() uint64 {
202+
// TODO: calculate this
203+
return 0
204+
}
205+
186206
func (h *ByronEpochBoundaryBlockHeader) Era() Era {
187207
return eras[EraIdByron]
188208
}
@@ -211,6 +231,14 @@ func (b *ByronMainBlock) SlotNumber() uint64 {
211231
return b.Header.SlotNumber()
212232
}
213233

234+
func (b *ByronMainBlock) IssuerVkey() []byte {
235+
return b.Header.IssuerVkey()
236+
}
237+
238+
func (b *ByronMainBlock) BlockBodySize() uint64 {
239+
return b.Header.BlockBodySize()
240+
}
241+
214242
func (b *ByronMainBlock) Era() Era {
215243
return b.Header.Era()
216244
}
@@ -244,6 +272,14 @@ func (b *ByronEpochBoundaryBlock) SlotNumber() uint64 {
244272
return b.Header.SlotNumber()
245273
}
246274

275+
func (b *ByronEpochBoundaryBlock) IssuerVkey() []byte {
276+
return b.Header.IssuerVkey()
277+
}
278+
279+
func (b *ByronEpochBoundaryBlock) BlockBodySize() uint64 {
280+
return b.Header.BlockBodySize()
281+
}
282+
247283
func (b *ByronEpochBoundaryBlock) Era() Era {
248284
return b.Header.Era()
249285
}

ledger/mary.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ func (b *MaryBlock) SlotNumber() uint64 {
5656
return b.Header.SlotNumber()
5757
}
5858

59+
func (b *MaryBlock) IssuerVkey() []byte {
60+
return b.Header.IssuerVkey()
61+
}
62+
63+
func (b *MaryBlock) BlockBodySize() uint64 {
64+
return b.Header.BlockBodySize()
65+
}
66+
5967
func (b *MaryBlock) Era() Era {
6068
return eras[EraIdMary]
6169
}

ledger/shelley.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ func (b *ShelleyBlock) SlotNumber() uint64 {
5555
return b.Header.SlotNumber()
5656
}
5757

58+
func (b *ShelleyBlock) IssuerVkey() []byte {
59+
return b.Header.IssuerVkey()
60+
}
61+
62+
func (b *ShelleyBlock) BlockBodySize() uint64 {
63+
return b.Header.BlockBodySize()
64+
}
65+
5866
func (b *ShelleyBlock) Era() Era {
5967
return eras[EraIdShelley]
6068
}
@@ -81,16 +89,16 @@ type ShelleyBlockHeader struct {
8189
BlockNumber uint64
8290
Slot uint64
8391
PrevHash Blake2b256
84-
IssuerVkey interface{}
85-
VrfKey interface{}
92+
IssuerVkey []byte
93+
VrfKey []byte
8694
NonceVrf interface{}
8795
LeaderVrf interface{}
88-
BlockBodySize uint32
96+
BlockBodySize uint64
8997
BlockBodyHash Blake2b256
90-
OpCertHotVkey interface{}
98+
OpCertHotVkey []byte
9199
OpCertSequenceNumber uint32
92100
OpCertKesPeriod uint32
93-
OpCertSignature interface{}
101+
OpCertSignature []byte
94102
ProtoMajorVersion uint64
95103
ProtoMinorVersion uint64
96104
}
@@ -116,6 +124,14 @@ func (h *ShelleyBlockHeader) SlotNumber() uint64 {
116124
return h.Body.Slot
117125
}
118126

127+
func (h *ShelleyBlockHeader) IssuerVkey() []byte {
128+
return h.Body.IssuerVkey
129+
}
130+
131+
func (h *ShelleyBlockHeader) BlockBodySize() uint64 {
132+
return h.Body.BlockBodySize
133+
}
134+
119135
func (h *ShelleyBlockHeader) Era() Era {
120136
return eras[EraIdShelley]
121137
}

0 commit comments

Comments
 (0)