@@ -15,9 +15,7 @@ import (
15
15
// SyncIndexers is a special index that includes multiple indexes,
16
16
// which stay in sync when blocks are added.
17
17
type SyncIndexers struct {
18
- indexers []blockdao.BlockIndexer
19
- startHeights []uint64 // start height of each indexer, which will be determined when the indexer is started
20
- minStartHeight uint64 // minimum start height of all indexers
18
+ indexers []blockdao.BlockIndexer
21
19
}
22
20
23
21
// NewSyncIndexers creates a new SyncIndexers
@@ -33,7 +31,7 @@ func (ig *SyncIndexers) Start(ctx context.Context) error {
33
31
return err
34
32
}
35
33
}
36
- return ig . initStartHeight ()
34
+ return nil
37
35
}
38
36
39
37
// Stop stops the indexer group
@@ -48,11 +46,7 @@ func (ig *SyncIndexers) Stop(ctx context.Context) error {
48
46
49
47
// PutBlock puts a block into the indexers in the group
50
48
func (ig * SyncIndexers ) PutBlock (ctx context.Context , blk * block.Block ) error {
51
- for i , indexer := range ig .indexers {
52
- // check if the block is higher than the indexer's start height
53
- if blk .Height () < ig .startHeights [i ] {
54
- continue
55
- }
49
+ for _ , indexer := range ig .indexers {
56
50
// check if the block is higher than the indexer's height
57
51
height , err := indexer .Height ()
58
52
if err != nil {
@@ -79,11 +73,6 @@ func (ig *SyncIndexers) DeleteTipBlock(ctx context.Context, blk *block.Block) er
79
73
return nil
80
74
}
81
75
82
- // StartHeight returns the minimum start height of the indexers in the group
83
- func (ig * SyncIndexers ) StartHeight () uint64 {
84
- return ig .minStartHeight
85
- }
86
-
87
76
// Height returns the minimum height of the indexers in the group
88
77
func (ig * SyncIndexers ) Height () (uint64 , error ) {
89
78
var height uint64
@@ -98,28 +87,3 @@ func (ig *SyncIndexers) Height() (uint64, error) {
98
87
}
99
88
return height , nil
100
89
}
101
-
102
- // initStartHeight initializes the start height of the indexers in the group
103
- // for every indexer, the start height is the maximum of tipheight+1 and startheight
104
- func (ig * SyncIndexers ) initStartHeight () error {
105
- ig .minStartHeight = 0
106
- ig .startHeights = make ([]uint64 , len (ig .indexers ))
107
- for i , indexer := range ig .indexers {
108
- tipHeight , err := indexer .Height ()
109
- if err != nil {
110
- return err
111
- }
112
- indexStartHeight := tipHeight + 1
113
- if indexerWithStart , ok := indexer .(blockdao.BlockIndexerWithStart ); ok {
114
- startHeight := indexerWithStart .StartHeight ()
115
- if startHeight > indexStartHeight {
116
- indexStartHeight = startHeight
117
- }
118
- }
119
- ig .startHeights [i ] = indexStartHeight
120
- if i == 0 || indexStartHeight < ig .minStartHeight {
121
- ig .minStartHeight = indexStartHeight
122
- }
123
- }
124
- return nil
125
- }
0 commit comments