@@ -30,8 +30,6 @@ import (
30
30
"github.com/iotexproject/iotex-core/consensus"
31
31
"github.com/iotexproject/iotex-core/db"
32
32
"github.com/iotexproject/iotex-core/dispatcher"
33
- "github.com/iotexproject/iotex-core/explorer"
34
- explorerapi "github.com/iotexproject/iotex-core/explorer/idl/explorer"
35
33
"github.com/iotexproject/iotex-core/indexservice"
36
34
"github.com/iotexproject/iotex-core/p2p"
37
35
"github.com/iotexproject/iotex-core/pkg/log"
@@ -47,30 +45,21 @@ type ChainService struct {
47
45
chain blockchain.Blockchain
48
46
electionCommittee committee.Committee
49
47
rDPoSProtocol * rolldpos.Protocol
50
- explorer * explorer. Server
51
- api * api.Server
52
- indexBuilder * blockchain.IndexBuilder
53
- indexservice * indexservice.Server
54
- registry * protocol.Registry
48
+ // TODO: explorer dependency deleted at #1085, need to api related params
49
+ api * api.Server
50
+ indexBuilder * blockchain.IndexBuilder
51
+ indexservice * indexservice.Server
52
+ registry * protocol.Registry
55
53
}
56
54
57
55
type optionParams struct {
58
- rootChainAPI explorerapi.Explorer
59
56
isTesting bool
60
57
genesisConfig genesis.Genesis
61
58
}
62
59
63
60
// Option sets ChainService construction parameter.
64
61
type Option func (ops * optionParams ) error
65
62
66
- // WithRootChainAPI is an option to add a root chain api to ChainService.
67
- func WithRootChainAPI (exp explorerapi.Explorer ) Option {
68
- return func (ops * optionParams ) error {
69
- ops .rootChainAPI = exp
70
- return nil
71
- }
72
- }
73
-
74
63
// WithTesting is an option to create a testing ChainService.
75
64
func WithTesting () Option {
76
65
return func (ops * optionParams ) error {
@@ -183,9 +172,7 @@ func New(
183
172
}),
184
173
consensus .WithRollDPoSProtocol (rDPoSProtocol ),
185
174
}
186
- if ops .rootChainAPI != nil {
187
- copts = append (copts , consensus .WithRootChainAPI (ops .rootChainAPI ))
188
- }
175
+ // TODO: explorer dependency deleted at #1085, need to revive by migrating to api
189
176
consensus , err := consensus .NewConsensus (cfg , chain , actPool , copts ... )
190
177
if err != nil {
191
178
return nil , errors .Wrap (err , "failed to create consensus" )
@@ -209,27 +196,7 @@ func New(
209
196
idx = indexservice .NewServer (cfg , chain )
210
197
if idx == nil {
211
198
return nil , errors .Wrap (err , "failed to create index service" )
212
- }
213
- }
214
-
215
- var exp * explorer.Server
216
- if cfg .Explorer .Enabled {
217
- exp , err = explorer .NewServer (
218
- cfg .Explorer ,
219
- chain ,
220
- consensus ,
221
- dispatcher ,
222
- actPool ,
223
- idx ,
224
- explorer .WithBroadcastOutbound (func (ctx context.Context , chainID uint32 , msg proto.Message ) error {
225
- ctx = p2p .WitContext (ctx , p2p.Context {ChainID : chainID })
226
- return p2pAgent .BroadcastOutbound (ctx , msg )
227
- }),
228
- explorer .WithNeighbors (p2pAgent .Neighbors ),
229
- explorer .WithNetworkInfo (p2pAgent .Info ),
230
- )
231
- if err != nil {
232
- return nil , err
199
+ // TODO: explorer dependency deleted at #1085, need to revive by migrating to api
233
200
}
234
201
}
235
202
@@ -261,7 +228,6 @@ func New(
261
228
electionCommittee : electionCommittee ,
262
229
indexservice : idx ,
263
230
indexBuilder : indexBuilder ,
264
- explorer : exp ,
265
231
api : apiSvr ,
266
232
registry : & registry ,
267
233
}, nil
@@ -288,11 +254,7 @@ func (cs *ChainService) Start(ctx context.Context) error {
288
254
if err := cs .blocksync .Start (ctx ); err != nil {
289
255
return errors .Wrap (err , "error when starting blocksync" )
290
256
}
291
- if cs .explorer != nil {
292
- if err := cs .explorer .Start (ctx ); err != nil {
293
- return errors .Wrap (err , "error when starting explorer" )
294
- }
295
- }
257
+ // TODO: explorer dependency deleted at #1085, need to revive by migrating to api
296
258
if cs .api != nil {
297
259
if err := cs .api .Start (); err != nil {
298
260
return errors .Wrap (err , "err when starting API server" )
@@ -313,11 +275,7 @@ func (cs *ChainService) Stop(ctx context.Context) error {
313
275
return errors .Wrap (err , "error when stopping index builder" )
314
276
}
315
277
}
316
- if cs .explorer != nil {
317
- if err := cs .explorer .Stop (ctx ); err != nil {
318
- return errors .Wrap (err , "error when stopping explorer" )
319
- }
320
- }
278
+ // TODO: explorer dependency deleted at #1085, need to revive by migrating to api
321
279
if cs .api != nil {
322
280
if err := cs .api .Stop (); err != nil {
323
281
return errors .Wrap (err , "error when stopping API server" )
@@ -415,11 +373,6 @@ func (cs *ChainService) IndexService() *indexservice.Server {
415
373
return cs .indexservice
416
374
}
417
375
418
- // Explorer returns the explorer instance
419
- func (cs * ChainService ) Explorer () * explorer.Server {
420
- return cs .explorer
421
- }
422
-
423
376
// RegisterProtocol register a protocol
424
377
func (cs * ChainService ) RegisterProtocol (id string , p protocol.Protocol ) error {
425
378
if err := cs .registry .Register (id , p ); err != nil {
0 commit comments