|
|
@ -85,6 +85,10 @@ type LesServer struct { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func NewLesServer(node *node.Node, e ethBackend, config *ethconfig.Config) (*LesServer, error) { |
|
|
|
func NewLesServer(node *node.Node, e ethBackend, config *ethconfig.Config) (*LesServer, error) { |
|
|
|
|
|
|
|
lesDb, err := node.OpenDatabase("les.server", 0, 0, "eth/db/les.server") |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
ns := nodestate.NewNodeStateMachine(nil, nil, mclock.System{}, serverSetup) |
|
|
|
ns := nodestate.NewNodeStateMachine(nil, nil, mclock.System{}, serverSetup) |
|
|
|
// Calculate the number of threads used to service the light client
|
|
|
|
// Calculate the number of threads used to service the light client
|
|
|
|
// requests based on the user-specified value.
|
|
|
|
// requests based on the user-specified value.
|
|
|
@ -99,6 +103,7 @@ func NewLesServer(node *node.Node, e ethBackend, config *ethconfig.Config) (*Les |
|
|
|
chainConfig: e.BlockChain().Config(), |
|
|
|
chainConfig: e.BlockChain().Config(), |
|
|
|
iConfig: light.DefaultServerIndexerConfig, |
|
|
|
iConfig: light.DefaultServerIndexerConfig, |
|
|
|
chainDb: e.ChainDb(), |
|
|
|
chainDb: e.ChainDb(), |
|
|
|
|
|
|
|
lesDb: lesDb, |
|
|
|
chainReader: e.BlockChain(), |
|
|
|
chainReader: e.BlockChain(), |
|
|
|
chtIndexer: light.NewChtIndexer(e.ChainDb(), nil, params.CHTFrequency, params.HelperTrieProcessConfirmations, true), |
|
|
|
chtIndexer: light.NewChtIndexer(e.ChainDb(), nil, params.CHTFrequency, params.HelperTrieProcessConfirmations, true), |
|
|
|
bloomTrieIndexer: light.NewBloomTrieIndexer(e.ChainDb(), nil, params.BloomBitsBlocks, params.BloomTrieFrequency, true), |
|
|
|
bloomTrieIndexer: light.NewBloomTrieIndexer(e.ChainDb(), nil, params.BloomBitsBlocks, params.BloomTrieFrequency, true), |
|
|
@ -136,7 +141,7 @@ func NewLesServer(node *node.Node, e ethBackend, config *ethconfig.Config) (*Les |
|
|
|
srv.maxCapacity = totalRecharge |
|
|
|
srv.maxCapacity = totalRecharge |
|
|
|
} |
|
|
|
} |
|
|
|
srv.fcManager.SetCapacityLimits(srv.minCapacity, srv.maxCapacity, srv.minCapacity*2) |
|
|
|
srv.fcManager.SetCapacityLimits(srv.minCapacity, srv.maxCapacity, srv.minCapacity*2) |
|
|
|
srv.clientPool = newClientPool(ns, srv.chainDb, srv.minCapacity, defaultConnectedBias, mclock.System{}, srv.dropClient) |
|
|
|
srv.clientPool = newClientPool(ns, lesDb, srv.minCapacity, defaultConnectedBias, mclock.System{}, srv.dropClient) |
|
|
|
srv.clientPool.setDefaultFactors(vfs.PriceFactors{TimeFactor: 0, CapacityFactor: 1, RequestFactor: 1}, vfs.PriceFactors{TimeFactor: 0, CapacityFactor: 1, RequestFactor: 1}) |
|
|
|
srv.clientPool.setDefaultFactors(vfs.PriceFactors{TimeFactor: 0, CapacityFactor: 1, RequestFactor: 1}, vfs.PriceFactors{TimeFactor: 0, CapacityFactor: 1, RequestFactor: 1}) |
|
|
|
|
|
|
|
|
|
|
|
checkpoint := srv.latestLocalCheckpoint() |
|
|
|
checkpoint := srv.latestLocalCheckpoint() |
|
|
@ -222,6 +227,7 @@ func (s *LesServer) Stop() error { |
|
|
|
|
|
|
|
|
|
|
|
// Note, bloom trie indexer is closed by parent bloombits indexer.
|
|
|
|
// Note, bloom trie indexer is closed by parent bloombits indexer.
|
|
|
|
s.chtIndexer.Close() |
|
|
|
s.chtIndexer.Close() |
|
|
|
|
|
|
|
s.lesDb.Close() |
|
|
|
s.wg.Wait() |
|
|
|
s.wg.Wait() |
|
|
|
log.Info("Les server stopped") |
|
|
|
log.Info("Les server stopped") |
|
|
|
|
|
|
|
|
|
|
|