Skip to content

Commit 7463b05

Browse files
authored
chore: split ledger era compat types to separate files (#696)
1 parent 6119836 commit 7463b05

File tree

8 files changed

+324
-191
lines changed

8 files changed

+324
-191
lines changed

ledger/allegra.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2024 Blink Labs Software
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package ledger
16+
17+
import "github.com/blinklabs-io/gouroboros/ledger/allegra"
18+
19+
// The below are compatability types, constants, and functions for the Allegra era
20+
// to keep existing code working after a refactor of the ledger package
21+
22+
// Allegra types
23+
type AllegraBlock = allegra.AllegraBlock
24+
type AllegraTransaction = allegra.AllegraTransaction
25+
type AllegraTransactionBody = allegra.AllegraTransactionBody
26+
type AllegraProtocolParameters = allegra.AllegraProtocolParameters
27+
type AllegraProtocolParameterUpdate = allegra.AllegraProtocolParameterUpdate
28+
29+
// Allegra constants
30+
const (
31+
EraIdAllegra = allegra.EraIdAllegra
32+
BlockTypeAllegra = allegra.BlockTypeAllegra
33+
BlockHeaderTypeAllegra = allegra.BlockHeaderTypeAllegra
34+
TxTypeAllegra = allegra.TxTypeAllegra
35+
)
36+
37+
// Allegra functions
38+
var (
39+
NewAllegraBlockFromCbor = allegra.NewAllegraBlockFromCbor
40+
NewAllegraTransactionFromCbor = allegra.NewAllegraTransactionFromCbor
41+
NewAllegraTransactionBodyFromCbor = allegra.NewAllegraTransactionBodyFromCbor
42+
)

ledger/alonzo.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2024 Blink Labs Software
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package ledger
16+
17+
import "github.com/blinklabs-io/gouroboros/ledger/alonzo"
18+
19+
// The below are compatability types, constants, and functions for the Alonzo era
20+
// to keep existing code working after a refactor of the ledger package
21+
22+
// Alonzo types
23+
type AlonzoBlock = alonzo.AlonzoBlock
24+
type AlonzoBlockHeader = alonzo.AlonzoBlockHeader
25+
type AlonzoTransaction = alonzo.AlonzoTransaction
26+
type AlonzoTransactionBody = alonzo.AlonzoTransactionBody
27+
type AlonzoTransactionOutput = alonzo.AlonzoTransactionOutput
28+
type AlonzoTransactionWitnessSet = alonzo.AlonzoTransactionWitnessSet
29+
type AlonzoProtocolParameters = alonzo.AlonzoProtocolParameters
30+
type AlonzoProtocolParameterUpdate = alonzo.AlonzoProtocolParameterUpdate
31+
32+
// Alonzo constants
33+
const (
34+
EraIdAlonzo = alonzo.EraIdAlonzo
35+
BlockTypeAlonzo = alonzo.BlockTypeAlonzo
36+
BlockHeaderTypeAlonzo = alonzo.BlockHeaderTypeAlonzo
37+
TxTypeAlonzo = alonzo.TxTypeAlonzo
38+
)
39+
40+
// Alonzo functions
41+
var (
42+
NewAlonzoBlockFromCbor = alonzo.NewAlonzoBlockFromCbor
43+
NewAlonzoTransactionFromCbor = alonzo.NewAlonzoTransactionFromCbor
44+
NewAlonzoTransactionBodyFromCbor = alonzo.NewAlonzoTransactionBodyFromCbor
45+
NewAlonzoTransactionOutputFromCbor = alonzo.NewAlonzoTransactionOutputFromCbor
46+
)

ledger/babbage.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2024 Blink Labs Software
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package ledger
16+
17+
import "github.com/blinklabs-io/gouroboros/ledger/babbage"
18+
19+
// The below are compatability types, constants, and functions for the Babbage era
20+
// to keep existing code working after a refactor of the ledger package
21+
22+
// Babbage types
23+
type BabbageBlock = babbage.BabbageBlock
24+
type BabbageBlockHeader = babbage.BabbageBlockHeader
25+
type BabbageTransaction = babbage.BabbageTransaction
26+
type BabbageTransactionBody = babbage.BabbageTransactionBody
27+
type BabbageTransactionOutput = babbage.BabbageTransactionOutput
28+
type BabbageTransactionWitnessSet = babbage.BabbageTransactionWitnessSet
29+
type BabbageProtocolParameters = babbage.BabbageProtocolParameters
30+
type BabbageProtocolParameterUpdate = babbage.BabbageProtocolParameterUpdate
31+
32+
// Babbage constants
33+
const (
34+
EraIdBabbage = babbage.EraIdBabbage
35+
BlockTypeBabbage = babbage.BlockTypeBabbage
36+
BlockHeaderTypeBabbage = babbage.BlockHeaderTypeBabbage
37+
TxTypeBabbage = babbage.TxTypeBabbage
38+
)
39+
40+
// Babbage functions
41+
var (
42+
NewBabbageBlockFromCbor = babbage.NewBabbageBlockFromCbor
43+
NewBabbageBlockHeaderFromCbor = babbage.NewBabbageBlockHeaderFromCbor
44+
NewBabbageTransactionFromCbor = babbage.NewBabbageTransactionFromCbor
45+
NewBabbageTransactionBodyFromCbor = babbage.NewBabbageTransactionBodyFromCbor
46+
NewBabbageTransactionOutputFromCbor = babbage.NewBabbageTransactionOutputFromCbor
47+
)

ledger/byron.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2024 Blink Labs Software
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package ledger
16+
17+
import "github.com/blinklabs-io/gouroboros/ledger/byron"
18+
19+
// The below are compatability types, constants, and functions for the Byron era
20+
// to keep existing code working after a refactor of the ledger package
21+
22+
// Byron types
23+
type ByronEpochBoundaryBlock = byron.ByronEpochBoundaryBlock
24+
type ByronMainBlock = byron.ByronMainBlock
25+
type ByronEpochBounaryBlockHeader = byron.ByronEpochBoundaryBlockHeader
26+
type ByronMainBlockHeader = byron.ByronMainBlockHeader
27+
type ByronTransaction = byron.ByronTransaction
28+
type ByronTransactionInput = byron.ByronTransactionInput
29+
type ByronTransactionOutput = byron.ByronTransactionOutput
30+
31+
// Byron constants
32+
const (
33+
EraIdByron = byron.EraIdByron
34+
BlockTypeByronEbb = byron.BlockTypeByronEbb
35+
BlockTypeByronMain = byron.BlockTypeByronMain
36+
BlockHeaderTypeByron = byron.BlockHeaderTypeByron
37+
TxTypeByron = byron.TxTypeByron
38+
)
39+
40+
// Byron functions
41+
var (
42+
NewByronEpochBoundaryBlockFromCbor = byron.NewByronEpochBoundaryBlockFromCbor
43+
NewByronMainBlockFromCbor = byron.NewByronMainBlockFromCbor
44+
NewByronEpochBoundaryBlockHeaderFromCbor = byron.NewByronEpochBoundaryBlockHeaderFromCbor
45+
NewByronMainBlockHeaderFromCbor = byron.NewByronMainBlockHeaderFromCbor
46+
NewByronTransactionInput = byron.NewByronTransactionInput
47+
NewByronTransactionFromCbor = byron.NewByronTransactionFromCbor
48+
)

ledger/compat.go

Lines changed: 0 additions & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,7 @@
1515
package ledger
1616

1717
import (
18-
"github.com/blinklabs-io/gouroboros/ledger/allegra"
19-
"github.com/blinklabs-io/gouroboros/ledger/alonzo"
20-
"github.com/blinklabs-io/gouroboros/ledger/babbage"
21-
"github.com/blinklabs-io/gouroboros/ledger/byron"
2218
"github.com/blinklabs-io/gouroboros/ledger/common"
23-
"github.com/blinklabs-io/gouroboros/ledger/conway"
24-
"github.com/blinklabs-io/gouroboros/ledger/mary"
25-
"github.com/blinklabs-io/gouroboros/ledger/shelley"
2619
)
2720

2821
// The below are compatability types and functions to keep existing code working
@@ -79,187 +72,3 @@ type AssetFingerprint = common.AssetFingerprint
7972
func NewAssetFingerprint(policyId []byte, assetName []byte) AssetFingerprint {
8073
return common.NewAssetFingerprint(policyId, assetName)
8174
}
82-
83-
// Byron types
84-
type ByronEpochBoundaryBlock = byron.ByronEpochBoundaryBlock
85-
type ByronMainBlock = byron.ByronMainBlock
86-
type ByronEpochBounaryBlockHeader = byron.ByronEpochBoundaryBlockHeader
87-
type ByronMainBlockHeader = byron.ByronMainBlockHeader
88-
type ByronTransaction = byron.ByronTransaction
89-
type ByronTransactionInput = byron.ByronTransactionInput
90-
type ByronTransactionOutput = byron.ByronTransactionOutput
91-
92-
// Byron constants
93-
const (
94-
EraIdByron = byron.EraIdByron
95-
BlockTypeByronEbb = byron.BlockTypeByronEbb
96-
BlockTypeByronMain = byron.BlockTypeByronMain
97-
BlockHeaderTypeByron = byron.BlockHeaderTypeByron
98-
TxTypeByron = byron.TxTypeByron
99-
)
100-
101-
// Byron functions
102-
var (
103-
NewByronEpochBoundaryBlockFromCbor = byron.NewByronEpochBoundaryBlockFromCbor
104-
NewByronMainBlockFromCbor = byron.NewByronMainBlockFromCbor
105-
NewByronEpochBoundaryBlockHeaderFromCbor = byron.NewByronEpochBoundaryBlockHeaderFromCbor
106-
NewByronMainBlockHeaderFromCbor = byron.NewByronMainBlockHeaderFromCbor
107-
NewByronTransactionInput = byron.NewByronTransactionInput
108-
NewByronTransactionFromCbor = byron.NewByronTransactionFromCbor
109-
)
110-
111-
// Shelley types
112-
type ShelleyBlock = shelley.ShelleyBlock
113-
type ShelleyBlockHeader = shelley.ShelleyBlockHeader
114-
type ShelleyTransaction = shelley.ShelleyTransaction
115-
type ShelleyTransactionBody = shelley.ShelleyTransactionBody
116-
type ShelleyTransactionInput = shelley.ShelleyTransactionInput
117-
type ShelleyTransactionOutput = shelley.ShelleyTransactionOutput
118-
type ShelleyTransactionWitnessSet = shelley.ShelleyTransactionWitnessSet
119-
type ShelleyProtocolParameters = shelley.ShelleyProtocolParameters
120-
type ShelleyProtocolParameterUpdate = shelley.ShelleyProtocolParameterUpdate
121-
122-
// Shelley constants
123-
const (
124-
EraIdShelley = shelley.EraIdShelley
125-
BlockTypeShelley = shelley.BlockTypeShelley
126-
BlockHeaderTypeShelley = shelley.BlockHeaderTypeShelley
127-
TxTypeShelley = shelley.TxTypeShelley
128-
)
129-
130-
// Shelley functions
131-
var (
132-
NewShelleyBlockFromCbor = shelley.NewShelleyBlockFromCbor
133-
NewShelleyBlockHeaderFromCbor = shelley.NewShelleyBlockHeaderFromCbor
134-
NewShelleyTransactionInput = shelley.NewShelleyTransactionInput
135-
NewShelleyTransactionFromCbor = shelley.NewShelleyTransactionFromCbor
136-
NewShelleyTransactionBodyFromCbor = shelley.NewShelleyTransactionBodyFromCbor
137-
NewShelleyTransactionOutputFromCbor = shelley.NewShelleyTransactionOutputFromCbor
138-
)
139-
140-
// Allegra types
141-
type AllegraBlock = allegra.AllegraBlock
142-
type AllegraTransaction = allegra.AllegraTransaction
143-
type AllegraTransactionBody = allegra.AllegraTransactionBody
144-
type AllegraProtocolParameters = allegra.AllegraProtocolParameters
145-
type AllegraProtocolParameterUpdate = allegra.AllegraProtocolParameterUpdate
146-
147-
// Allegra constants
148-
const (
149-
EraIdAllegra = allegra.EraIdAllegra
150-
BlockTypeAllegra = allegra.BlockTypeAllegra
151-
BlockHeaderTypeAllegra = allegra.BlockHeaderTypeAllegra
152-
TxTypeAllegra = allegra.TxTypeAllegra
153-
)
154-
155-
// Allegra functions
156-
var (
157-
NewAllegraBlockFromCbor = allegra.NewAllegraBlockFromCbor
158-
NewAllegraTransactionFromCbor = allegra.NewAllegraTransactionFromCbor
159-
NewAllegraTransactionBodyFromCbor = allegra.NewAllegraTransactionBodyFromCbor
160-
)
161-
162-
// Mary types
163-
type MaryBlock = mary.MaryBlock
164-
type MaryBlockHeader = mary.MaryBlockHeader
165-
type MaryTransaction = mary.MaryTransaction
166-
type MaryTransactionBody = mary.MaryTransactionBody
167-
type MaryTransactionOutput = mary.MaryTransactionOutput
168-
type MaryTransactionOutputValue = mary.MaryTransactionOutputValue
169-
type MaryTransactionWitnessSet = mary.MaryTransactionWitnessSet
170-
type MaryProtocolParameters = mary.MaryProtocolParameters
171-
type MaryProtocolParameterUpdate = mary.MaryProtocolParameterUpdate
172-
173-
// Mary constants
174-
const (
175-
EraIdMary = mary.EraIdMary
176-
BlockTypeMary = mary.BlockTypeMary
177-
BlockHeaderTypeMary = mary.BlockHeaderTypeMary
178-
TxTypeMary = mary.TxTypeMary
179-
)
180-
181-
// Mary functions
182-
var (
183-
NewMaryBlockFromCbor = mary.NewMaryBlockFromCbor
184-
NewMaryTransactionFromCbor = mary.NewMaryTransactionFromCbor
185-
NewMaryTransactionBodyFromCbor = mary.NewMaryTransactionBodyFromCbor
186-
NewMaryTransactionOutputFromCbor = mary.NewMaryTransactionOutputFromCbor
187-
)
188-
189-
// Alonzo types
190-
type AlonzoBlock = alonzo.AlonzoBlock
191-
type AlonzoBlockHeader = alonzo.AlonzoBlockHeader
192-
type AlonzoTransaction = alonzo.AlonzoTransaction
193-
type AlonzoTransactionBody = alonzo.AlonzoTransactionBody
194-
type AlonzoTransactionOutput = alonzo.AlonzoTransactionOutput
195-
type AlonzoTransactionWitnessSet = alonzo.AlonzoTransactionWitnessSet
196-
type AlonzoProtocolParameters = alonzo.AlonzoProtocolParameters
197-
type AlonzoProtocolParameterUpdate = alonzo.AlonzoProtocolParameterUpdate
198-
199-
// Alonzo constants
200-
const (
201-
EraIdAlonzo = alonzo.EraIdAlonzo
202-
BlockTypeAlonzo = alonzo.BlockTypeAlonzo
203-
BlockHeaderTypeAlonzo = alonzo.BlockHeaderTypeAlonzo
204-
TxTypeAlonzo = alonzo.TxTypeAlonzo
205-
)
206-
207-
// Alonzo functions
208-
var (
209-
NewAlonzoBlockFromCbor = alonzo.NewAlonzoBlockFromCbor
210-
NewAlonzoTransactionFromCbor = alonzo.NewAlonzoTransactionFromCbor
211-
NewAlonzoTransactionBodyFromCbor = alonzo.NewAlonzoTransactionBodyFromCbor
212-
NewAlonzoTransactionOutputFromCbor = alonzo.NewAlonzoTransactionOutputFromCbor
213-
)
214-
215-
// Babbage types
216-
type BabbageBlock = babbage.BabbageBlock
217-
type BabbageBlockHeader = babbage.BabbageBlockHeader
218-
type BabbageTransaction = babbage.BabbageTransaction
219-
type BabbageTransactionBody = babbage.BabbageTransactionBody
220-
type BabbageTransactionOutput = babbage.BabbageTransactionOutput
221-
type BabbageTransactionWitnessSet = babbage.BabbageTransactionWitnessSet
222-
type BabbageProtocolParameters = babbage.BabbageProtocolParameters
223-
type BabbageProtocolParameterUpdate = babbage.BabbageProtocolParameterUpdate
224-
225-
// Babbage constants
226-
const (
227-
EraIdBabbage = babbage.EraIdBabbage
228-
BlockTypeBabbage = babbage.BlockTypeBabbage
229-
BlockHeaderTypeBabbage = babbage.BlockHeaderTypeBabbage
230-
TxTypeBabbage = babbage.TxTypeBabbage
231-
)
232-
233-
// Babbage functions
234-
var (
235-
NewBabbageBlockFromCbor = babbage.NewBabbageBlockFromCbor
236-
NewBabbageBlockHeaderFromCbor = babbage.NewBabbageBlockHeaderFromCbor
237-
NewBabbageTransactionFromCbor = babbage.NewBabbageTransactionFromCbor
238-
NewBabbageTransactionBodyFromCbor = babbage.NewBabbageTransactionBodyFromCbor
239-
NewBabbageTransactionOutputFromCbor = babbage.NewBabbageTransactionOutputFromCbor
240-
)
241-
242-
// Conway types
243-
type ConwayBlock = conway.ConwayBlock
244-
type ConwayBlockHeader = conway.ConwayBlockHeader
245-
type ConwayTransaction = conway.ConwayTransaction
246-
type ConwayTransactionBody = conway.ConwayTransactionBody
247-
type ConwayTransactionWitnessSet = conway.ConwayTransactionWitnessSet
248-
type ConwayProtocolParameters = conway.ConwayProtocolParameters
249-
type ConwayProtocolParameterUpdate = conway.ConwayProtocolParameterUpdate
250-
251-
// Conway constants
252-
const (
253-
EraIdConway = conway.EraIdConway
254-
BlockTypeConway = conway.BlockTypeConway
255-
BlockHeaderTypeConway = conway.BlockHeaderTypeConway
256-
TxTypeConway = conway.TxTypeConway
257-
)
258-
259-
// Conway functions
260-
var (
261-
NewConwayBlockFromCbor = conway.NewConwayBlockFromCbor
262-
NewConwayBlockHeaderFromCbor = conway.NewConwayBlockHeaderFromCbor
263-
NewConwayTransactionFromCbor = conway.NewConwayTransactionFromCbor
264-
NewConwayTransactionBodyFromCbor = conway.NewConwayTransactionBodyFromCbor
265-
)

0 commit comments

Comments
 (0)