@@ -57,8 +57,7 @@ type LightEthereum struct {
5757 handler * clientHandler
5858 txPool * light.TxPool
5959 blockchain * light.LightChain
60- serverPool * serverPool
61- valueTracker * vfc.ValueTracker
60+ serverPool * vfc.ServerPool
6261 dialCandidates enode.Iterator
6362 pruner * pruner
6463
@@ -109,17 +108,14 @@ func New(stack *node.Node, config *ethconfig.Config) (*LightEthereum, error) {
109108 engine : ethconfig .CreateConsensusEngine (stack , chainConfig , & config .Ethash , nil , false , chainDb ),
110109 bloomRequests : make (chan chan * bloombits.Retrieval ),
111110 bloomIndexer : core .NewBloomIndexer (chainDb , params .BloomBitsBlocksClient , params .HelperTrieConfirmations ),
112- valueTracker : vfc .NewValueTracker (lesDb , & mclock.System {}, requestList , time .Minute , 1 / float64 (time .Hour ), 1 / float64 (time .Hour * 100 ), 1 / float64 (time .Hour * 1000 )),
113111 p2pServer : stack .Server (),
114112 p2pConfig : & stack .Config ().P2P ,
115113 }
116- peers .subscribe ((* vtSubscription )(leth .valueTracker ))
117114
118- leth .serverPool = newServerPool (lesDb , []byte ("serverpool:" ), leth .valueTracker , time .Second , nil , & mclock.System {}, config .UltraLightServers )
119- peers .subscribe (leth .serverPool )
120- leth .dialCandidates = leth .serverPool .dialIterator
115+ leth .serverPool , leth .dialCandidates = vfc .NewServerPool (lesDb , []byte ("serverpool:" ), time .Second , nil , & mclock.System {}, config .UltraLightServers , requestList )
116+ leth .serverPool .AddMetrics (suggestedTimeoutGauge , totalValueGauge , serverSelectableGauge , serverConnectedGauge , sessionValueMeter , serverDialedMeter )
121117
122- leth .retriever = newRetrieveManager (peers , leth .reqDist , leth .serverPool .getTimeout )
118+ leth .retriever = newRetrieveManager (peers , leth .reqDist , leth .serverPool .GetTimeout )
123119 leth .relay = newLesTxRelay (peers , leth .retriever )
124120
125121 leth .odr = NewLesOdr (chainDb , light .DefaultClientIndexerConfig , leth .peers , leth .retriever )
@@ -193,23 +189,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*LightEthereum, error) {
193189 return leth , nil
194190}
195191
196- // vtSubscription implements serverPeerSubscriber
197- type vtSubscription vfc.ValueTracker
198-
199- // registerPeer implements serverPeerSubscriber
200- func (v * vtSubscription ) registerPeer (p * serverPeer ) {
201- vt := (* vfc .ValueTracker )(v )
202- p .setValueTracker (vt , vt .Register (p .ID ()))
203- p .updateVtParams ()
204- }
205-
206- // unregisterPeer implements serverPeerSubscriber
207- func (v * vtSubscription ) unregisterPeer (p * serverPeer ) {
208- vt := (* vfc .ValueTracker )(v )
209- vt .Unregister (p .ID ())
210- p .setValueTracker (nil , nil )
211- }
212-
213192type LightDummyAPI struct {}
214193
215194// Etherbase is the address that mining rewards will be send to
@@ -266,7 +245,7 @@ func (s *LightEthereum) APIs() []rpc.API {
266245 }, {
267246 Namespace : "vflux" ,
268247 Version : "1.0" ,
269- Service : vfc . NewPrivateClientAPI ( s . valueTracker ),
248+ Service : s . serverPool . API ( ),
270249 Public : false ,
271250 },
272251 }... )
@@ -302,8 +281,8 @@ func (s *LightEthereum) Start() error {
302281 if err != nil {
303282 return err
304283 }
305- s .serverPool .addSource (discovery )
306- s .serverPool .start ()
284+ s .serverPool .AddSource (discovery )
285+ s .serverPool .Start ()
307286 // Start bloom request workers.
308287 s .wg .Add (bloomServiceThreads )
309288 s .startBloomHandlers (params .BloomBitsBlocksClient )
@@ -316,8 +295,7 @@ func (s *LightEthereum) Start() error {
316295// Ethereum protocol.
317296func (s * LightEthereum ) Stop () error {
318297 close (s .closeCh )
319- s .serverPool .stop ()
320- s .valueTracker .Stop ()
298+ s .serverPool .Stop ()
321299 s .peers .close ()
322300 s .reqDist .close ()
323301 s .odr .Stop ()
0 commit comments