@@ -35,15 +35,40 @@ func init() {
3535 snapcfg .RegisterKnownTypes (networkname .ChiadoChainName , ethereumTypes )
3636}
3737
38+ var Enums = struct {
39+ snaptype.Enums
40+ Headers ,
41+ Bodies ,
42+ Transactions snaptype.Enum
43+ }{
44+ Enums : snaptype.Enums {},
45+ Headers : snaptype .MinCoreEnum ,
46+ Bodies : snaptype .MinCoreEnum + 1 ,
47+ Transactions : snaptype .MinCoreEnum + 2 ,
48+ }
49+
50+ var Indexes = struct {
51+ HeaderHash ,
52+ BodyHash ,
53+ TxnHash ,
54+ TxnHash2BlockNum snaptype.Index
55+ }{
56+ HeaderHash : snaptype.Index {Name : "headers" },
57+ BodyHash : snaptype.Index {Name : "bodies" },
58+ TxnHash : snaptype.Index {Name : "transactions" },
59+ TxnHash2BlockNum : snaptype.Index {Name : "transactions-to-block" , Offset : 1 },
60+ }
61+
3862var (
3963 Headers = snaptype .RegisterType (
40- snaptype .Enums .Headers ,
64+ Enums .Headers ,
65+ "headers" ,
4166 snaptype.Versions {
4267 Current : 1 , //2,
4368 MinSupported : 1 ,
4469 },
4570 nil ,
46- []snaptype.Index {snaptype . Indexes .HeaderHash },
71+ []snaptype.Index {Indexes .HeaderHash },
4772 snaptype .IndexBuilderFunc (
4873 func (ctx context.Context , info snaptype.FileInfo , salt uint32 , _ * chain.Config , tmpDir string , p * background.Progress , lvl log.Lvl , logger log.Logger ) (err error ) {
4974 hasher := crypto .NewKeccakState ()
@@ -70,13 +95,14 @@ var (
7095 )
7196
7297 Bodies = snaptype .RegisterType (
73- snaptype .Enums .Bodies ,
98+ Enums .Bodies ,
99+ "bodies" ,
74100 snaptype.Versions {
75101 Current : 1 , //2,
76102 MinSupported : 1 ,
77103 },
78104 nil ,
79- []snaptype.Index {snaptype . Indexes .BodyHash },
105+ []snaptype.Index {Indexes .BodyHash },
80106 snaptype .IndexBuilderFunc (
81107 func (ctx context.Context , info snaptype.FileInfo , salt uint32 , _ * chain.Config , tmpDir string , p * background.Progress , lvl log.Lvl , logger log.Logger ) (err error ) {
82108 num := make ([]byte , 8 )
@@ -98,13 +124,14 @@ var (
98124 )
99125
100126 Transactions = snaptype .RegisterType (
101- snaptype .Enums .Transactions ,
127+ Enums .Transactions ,
128+ "transactions" ,
102129 snaptype.Versions {
103130 Current : 1 , //2,
104131 MinSupported : 1 ,
105132 },
106133 nil ,
107- []snaptype.Index {snaptype . Indexes .TxnHash , snaptype . Indexes .TxnHash2BlockNum },
134+ []snaptype.Index {Indexes .TxnHash , Indexes .TxnHash2BlockNum },
108135 snaptype .IndexBuilderFunc (
109136 func (ctx context.Context , sn snaptype.FileInfo , salt uint32 , chainConfig * chain.Config , tmpDir string , p * background.Progress , lvl log.Lvl , logger log.Logger ) (err error ) {
110137 defer func () {
@@ -162,7 +189,7 @@ var (
162189 BucketSize : 2000 ,
163190 LeafSize : 8 ,
164191 TmpDir : tmpDir ,
165- IndexFile : filepath .Join (sn .Dir (), sn .Type .IdxFileName (sn .Version , sn .From , sn .To , snaptype . Indexes .TxnHash2BlockNum )),
192+ IndexFile : filepath .Join (sn .Dir (), sn .Type .IdxFileName (sn .Version , sn .From , sn .To , Indexes .TxnHash2BlockNum )),
166193 BaseDataID : firstBlockNum ,
167194 }, logger )
168195 if err != nil {
0 commit comments