Skip to content

Commit 311fd36

Browse files
committed
feat: consistent naming for ledger constants
1 parent cf8f5bf commit 311fd36

File tree

16 files changed

+147
-146
lines changed

16 files changed

+147
-146
lines changed

cmd/gouroboros/chainsync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ func chainSyncRollForwardHandler(blockType uint, blockData interface{}, tip chai
219219
}
220220
// Display block info
221221
switch blockType {
222-
case ledger.BLOCK_TYPE_BYRON_EBB:
222+
case ledger.BlockTypeByronEbb:
223223
byronEbbBlock := block.(*ledger.ByronEpochBoundaryBlock)
224224
fmt.Printf("era = Byron (EBB), epoch = %d, slot = %d, id = %s\n", byronEbbBlock.Header.ConsensusData.Epoch, byronEbbBlock.SlotNumber(), byronEbbBlock.Hash())
225-
case ledger.BLOCK_TYPE_BYRON_MAIN:
225+
case ledger.BlockTypeByronMain:
226226
byronBlock := block.(*ledger.ByronMainBlock)
227227
fmt.Printf("era = Byron, epoch = %d, slot = %d, id = %s\n", byronBlock.Header.ConsensusData.SlotId.Epoch, byronBlock.SlotNumber(), byronBlock.Hash())
228228
default:

cmd/gouroboros/localtxsubmission.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func testLocalTxSubmission(f *globalFlags) {
107107
}
108108
}
109109

110-
if err = o.LocalTxSubmission().Client.SubmitTx(ledger.TX_TYPE_ALONZO, txBytes); err != nil {
110+
if err = o.LocalTxSubmission().Client.SubmitTx(ledger.TxTypeAlonzo, txBytes); err != nil {
111111
fmt.Printf("Error submitting transaction: %s\n", err)
112112
os.Exit(1)
113113
}

ledger/allegra.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import (
2121
)
2222

2323
const (
24-
ERA_ID_ALLEGRA = 2
24+
EraIdAllegra = 2
2525

26-
BLOCK_TYPE_ALLEGRA = 3
26+
BlockTypeAllegra = 3
2727

28-
BLOCK_HEADER_TYPE_ALLEGRA = 2
28+
BlockHeaderTypeAllegra = 2
2929

30-
TX_TYPE_ALLEGRA = 2
30+
TxTypeAllegra = 2
3131
)
3232

3333
type AllegraBlock struct {
@@ -56,7 +56,7 @@ func (b *AllegraBlock) SlotNumber() uint64 {
5656
}
5757

5858
func (b *AllegraBlock) Era() Era {
59-
return eras[ERA_ID_ALLEGRA]
59+
return eras[EraIdAllegra]
6060
}
6161

6262
func (b *AllegraBlock) Transactions() []Transaction {
@@ -77,7 +77,7 @@ type AllegraBlockHeader struct {
7777
}
7878

7979
func (h *AllegraBlockHeader) Era() Era {
80-
return eras[ERA_ID_ALLEGRA]
80+
return eras[EraIdAllegra]
8181
}
8282

8383
type AllegraTransactionBody struct {

ledger/alonzo.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import (
2222
)
2323

2424
const (
25-
ERA_ID_ALONZO = 4
25+
EraIdAlonzo = 4
2626

27-
BLOCK_TYPE_ALONZO = 5
27+
BlockTypeAlonzo = 5
2828

29-
BLOCK_HEADER_TYPE_ALONZO = 4
29+
BlockHeaderTypeAlonzo = 4
3030

31-
TX_TYPE_ALONZO = 4
31+
TxTypeAlonzo = 4
3232
)
3333

3434
type AlonzoBlock struct {
@@ -58,7 +58,7 @@ func (b *AlonzoBlock) SlotNumber() uint64 {
5858
}
5959

6060
func (b *AlonzoBlock) Era() Era {
61-
return eras[ERA_ID_ALONZO]
61+
return eras[EraIdAlonzo]
6262
}
6363

6464
func (b *AlonzoBlock) Transactions() []Transaction {
@@ -87,7 +87,7 @@ type AlonzoBlockHeader struct {
8787
}
8888

8989
func (h *AlonzoBlockHeader) Era() Era {
90-
return eras[ERA_ID_ALONZO]
90+
return eras[EraIdAlonzo]
9191
}
9292

9393
type AlonzoTransactionBody struct {

ledger/babbage.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import (
2222
)
2323

2424
const (
25-
ERA_ID_BABBAGE = 5
25+
EraIdBabbage = 5
2626

27-
BLOCK_TYPE_BABBAGE = 6
27+
BlockTypeBabbage = 6
2828

29-
BLOCK_HEADER_TYPE_BABBAGE = 5
29+
BlockHeaderTypeBabbage = 5
3030

31-
TX_TYPE_BABBAGE = 5
31+
TxTypeBabbage = 5
3232
)
3333

3434
type BabbageBlock struct {
@@ -58,7 +58,7 @@ func (b *BabbageBlock) SlotNumber() uint64 {
5858
}
5959

6060
func (b *BabbageBlock) Era() Era {
61-
return eras[ERA_ID_BABBAGE]
61+
return eras[EraIdBabbage]
6262
}
6363

6464
func (b *BabbageBlock) Transactions() []Transaction {
@@ -132,7 +132,7 @@ func (h *BabbageBlockHeader) SlotNumber() uint64 {
132132
}
133133

134134
func (h *BabbageBlockHeader) Era() Era {
135-
return eras[ERA_ID_BABBAGE]
135+
return eras[EraIdBabbage]
136136
}
137137

138138
type BabbageTransactionBody struct {

ledger/block.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ type BlockHeader interface {
3636

3737
func NewBlockFromCbor(blockType uint, data []byte) (Block, error) {
3838
switch blockType {
39-
case BLOCK_TYPE_BYRON_EBB:
39+
case BlockTypeByronEbb:
4040
return NewByronEpochBoundaryBlockFromCbor(data)
41-
case BLOCK_TYPE_BYRON_MAIN:
41+
case BlockTypeByronMain:
4242
return NewByronMainBlockFromCbor(data)
43-
case BLOCK_TYPE_SHELLEY:
43+
case BlockTypeShelley:
4444
return NewShelleyBlockFromCbor(data)
45-
case BLOCK_TYPE_ALLEGRA:
45+
case BlockTypeAllegra:
4646
return NewAllegraBlockFromCbor(data)
47-
case BLOCK_TYPE_MARY:
47+
case BlockTypeMary:
4848
return NewMaryBlockFromCbor(data)
49-
case BLOCK_TYPE_ALONZO:
49+
case BlockTypeAlonzo:
5050
return NewAlonzoBlockFromCbor(data)
51-
case BLOCK_TYPE_BABBAGE:
51+
case BlockTypeBabbage:
5252
return NewBabbageBlockFromCbor(data)
5353
}
5454
return nil, fmt.Errorf("unknown node-to-client block type: %d", blockType)
@@ -57,14 +57,14 @@ func NewBlockFromCbor(blockType uint, data []byte) (Block, error) {
5757
// XXX: should this take the block header type instead?
5858
func NewBlockHeaderFromCbor(blockType uint, data []byte) (BlockHeader, error) {
5959
switch blockType {
60-
case BLOCK_TYPE_BYRON_EBB:
60+
case BlockTypeByronEbb:
6161
return NewByronEpochBoundaryBlockHeaderFromCbor(data)
62-
case BLOCK_TYPE_BYRON_MAIN:
62+
case BlockTypeByronMain:
6363
return NewByronMainBlockHeaderFromCbor(data)
6464
// TODO: break into separate cases and parse as specific block header types
65-
case BLOCK_TYPE_SHELLEY, BLOCK_TYPE_ALLEGRA, BLOCK_TYPE_MARY, BLOCK_TYPE_ALONZO:
65+
case BlockTypeShelley, BlockTypeAllegra, BlockTypeMary, BlockTypeAlonzo:
6666
return NewShelleyBlockHeaderFromCbor(data)
67-
case BLOCK_TYPE_BABBAGE:
67+
case BlockTypeBabbage:
6868
return NewBabbageBlockHeaderFromCbor(data)
6969
}
7070
return nil, fmt.Errorf("unknown node-to-node block type: %d", blockType)

ledger/byron.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ import (
2121
)
2222

2323
const (
24-
ERA_ID_BYRON = 0
24+
EraIdByron = 0
2525

26-
BLOCK_TYPE_BYRON_EBB = 0
27-
BLOCK_TYPE_BYRON_MAIN = 1
26+
BlockTypeByronEbb = 0
27+
BlockTypeByronMain = 1
2828

29-
BLOCK_HEADER_TYPE_BYRON = 0
29+
BlockHeaderTypeByron = 0
3030

31-
TX_TYPE_BYRON = 0
31+
TxTypeByron = 0
3232

33-
BYRON_SLOTS_PER_EPOCH = 21600
33+
ByronSlotsPerEpoch = 21600
3434
)
3535

3636
type ByronMainBlockHeader struct {
@@ -82,7 +82,7 @@ func (h *ByronMainBlockHeader) Hash() string {
8282
// Prepend bytes for CBOR list wrapper
8383
// The block hash is calculated with these extra bytes, so we have to add them to
8484
// get the correct value
85-
h.hash = generateBlockHeaderHash(h.Cbor(), []byte{0x82, BLOCK_TYPE_BYRON_MAIN})
85+
h.hash = generateBlockHeaderHash(h.Cbor(), []byte{0x82, BlockTypeByronMain})
8686
}
8787
return h.hash
8888
}
@@ -93,11 +93,11 @@ func (h *ByronMainBlockHeader) BlockNumber() uint64 {
9393
}
9494

9595
func (h *ByronMainBlockHeader) SlotNumber() uint64 {
96-
return uint64((h.ConsensusData.SlotId.Epoch * BYRON_SLOTS_PER_EPOCH) + uint64(h.ConsensusData.SlotId.Slot))
96+
return uint64((h.ConsensusData.SlotId.Epoch * ByronSlotsPerEpoch) + uint64(h.ConsensusData.SlotId.Slot))
9797
}
9898

9999
func (h *ByronMainBlockHeader) Era() Era {
100-
return eras[ERA_ID_BYRON]
100+
return eras[EraIdByron]
101101
}
102102

103103
type ByronTransaction struct {
@@ -169,7 +169,7 @@ func (h *ByronEpochBoundaryBlockHeader) Hash() string {
169169
// Prepend bytes for CBOR list wrapper
170170
// The block hash is calculated with these extra bytes, so we have to add them to
171171
// get the correct value
172-
h.hash = generateBlockHeaderHash(h.Cbor(), []byte{0x82, BLOCK_TYPE_BYRON_EBB})
172+
h.hash = generateBlockHeaderHash(h.Cbor(), []byte{0x82, BlockTypeByronEbb})
173173
}
174174
return h.hash
175175
}
@@ -180,11 +180,11 @@ func (h *ByronEpochBoundaryBlockHeader) BlockNumber() uint64 {
180180
}
181181

182182
func (h *ByronEpochBoundaryBlockHeader) SlotNumber() uint64 {
183-
return uint64(h.ConsensusData.Epoch * BYRON_SLOTS_PER_EPOCH)
183+
return uint64(h.ConsensusData.Epoch * ByronSlotsPerEpoch)
184184
}
185185

186186
func (h *ByronEpochBoundaryBlockHeader) Era() Era {
187-
return eras[ERA_ID_BYRON]
187+
return eras[EraIdByron]
188188
}
189189

190190
type ByronMainBlock struct {

ledger/era.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,28 @@ type Era struct {
2020
}
2121

2222
var eras = map[uint8]Era{
23-
ERA_ID_BYRON: Era{
24-
Id: ERA_ID_BYRON,
23+
EraIdByron: Era{
24+
Id: EraIdByron,
2525
Name: "Byron",
2626
},
27-
ERA_ID_SHELLEY: Era{
28-
Id: ERA_ID_SHELLEY,
27+
EraIdShelley: Era{
28+
Id: EraIdShelley,
2929
Name: "Shelley",
3030
},
31-
ERA_ID_ALLEGRA: Era{
32-
Id: ERA_ID_ALLEGRA,
31+
EraIdAllegra: Era{
32+
Id: EraIdAllegra,
3333
Name: "Allegra",
3434
},
35-
ERA_ID_MARY: Era{
36-
Id: ERA_ID_MARY,
35+
EraIdMary: Era{
36+
Id: EraIdMary,
3737
Name: "Mary",
3838
},
39-
ERA_ID_ALONZO: Era{
40-
Id: ERA_ID_ALONZO,
39+
EraIdAlonzo: Era{
40+
Id: EraIdAlonzo,
4141
Name: "Alonzo",
4242
},
43-
ERA_ID_BABBAGE: Era{
44-
Id: ERA_ID_BABBAGE,
43+
EraIdBabbage: Era{
44+
Id: EraIdBabbage,
4545
Name: "Babbage",
4646
},
4747
}

0 commit comments

Comments
 (0)