aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorFelföldi Zsolt <zsfelfoldi@gmail.com>2019-02-26 19:32:48 +0800
committerFelix Lange <fjl@users.noreply.github.com>2019-02-26 19:32:48 +0800
commitc2003ed63b975c6318e4dd7e65b69c60777b0ddf (patch)
tree0045c39070c4d2b9fcaa93cbcbdd8d5ea4f4a29f /core
parentc2b33a117f686069e36d58d937e1c75d72d7b94c (diff)
downloadgo-tangerine-c2003ed63b975c6318e4dd7e65b69c60777b0ddf.tar
go-tangerine-c2003ed63b975c6318e4dd7e65b69c60777b0ddf.tar.gz
go-tangerine-c2003ed63b975c6318e4dd7e65b69c60777b0ddf.tar.bz2
go-tangerine-c2003ed63b975c6318e4dd7e65b69c60777b0ddf.tar.lz
go-tangerine-c2003ed63b975c6318e4dd7e65b69c60777b0ddf.tar.xz
go-tangerine-c2003ed63b975c6318e4dd7e65b69c60777b0ddf.tar.zst
go-tangerine-c2003ed63b975c6318e4dd7e65b69c60777b0ddf.zip
les, les/flowcontrol: improved request serving and flow control (#18230)
This change - implements concurrent LES request serving even for a single peer. - replaces the request cost estimation method with a cost table based on benchmarks which gives much more consistent results. Until now the allowed number of light peers was just a guess which probably contributed a lot to the fluctuating quality of available service. Everything related to request cost is implemented in a single object, the 'cost tracker'. It uses a fixed cost table with a global 'correction factor'. Benchmark code is included and can be run at any time to adapt costs to low-level implementation changes. - reimplements flowcontrol.ClientManager in a cleaner and more efficient way, with added capabilities: There is now control over bandwidth, which allows using the flow control parameters for client prioritization. Target utilization over 100 percent is now supported to model concurrent request processing. Total serving bandwidth is reduced during block processing to prevent database contention. - implements an RPC API for the LES servers allowing server operators to assign priority bandwidth to certain clients and change prioritized status even while the client is connected. The new API is meant for cases where server operators charge for LES using an off-protocol mechanism. - adds a unit test for the new client manager. - adds an end-to-end test using the network simulator that tests bandwidth control functions through the new API.
Diffstat (limited to 'core')
-rw-r--r--core/blockchain.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index d6dad2799..7b4f4b303 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -111,6 +111,7 @@ type BlockChain struct {
chainSideFeed event.Feed
chainHeadFeed event.Feed
logsFeed event.Feed
+ blockProcFeed event.Feed
scope event.SubscriptionScope
genesisBlock *types.Block
@@ -1090,6 +1091,10 @@ func (bc *BlockChain) InsertChain(chain types.Blocks) (int, error) {
if len(chain) == 0 {
return 0, nil
}
+
+ bc.blockProcFeed.Send(true)
+ defer bc.blockProcFeed.Send(false)
+
// Remove already known canon-blocks
var (
block, prev *types.Block
@@ -1725,3 +1730,9 @@ func (bc *BlockChain) SubscribeChainSideEvent(ch chan<- ChainSideEvent) event.Su
func (bc *BlockChain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription {
return bc.scope.Track(bc.logsFeed.Subscribe(ch))
}
+
+// SubscribeBlockProcessingEvent registers a subscription of bool where true means
+// block processing has started while false means it has stopped.
+func (bc *BlockChain) SubscribeBlockProcessingEvent(ch chan<- bool) event.Subscription {
+ return bc.scope.Track(bc.blockProcFeed.Subscribe(ch))
+}