Correct formatting

This commit is contained in:
Frank Szendzielarz 2019-06-06 12:42:52 +02:00
parent a986522822
commit 4e10c85518
3 changed files with 44 additions and 46 deletions

View file

@ -1502,47 +1502,56 @@ func SetDashboardConfig(ctx *cli.Context, cfg *dashboard.Config) {
func RegisterLesClientService(stack *node.Node, cfg *eth.Config) { func RegisterLesClientService(stack *node.Node, cfg *eth.Config) {
//if the light client is requested //if the light client is requested
if cfg.SyncMode == downloader.LightSync { if cfg.SyncMode != downloader.LightSync {
//register a light client return
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
return les.New(ctx, cfg)
}); err != nil {
Fatalf("Failed to register the Light Client service: %v", err)
}
} }
//register a light client
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
return les.New(ctx, cfg)
}); err != nil {
Fatalf("Failed to register the Light Client service: %v", err)
}
} }
// RegisterLesServerService adds a Light Server service to the stack if the config permits // RegisterLesServerService adds a Light Server service to the stack if the config permits
func RegisterLesServerService(stack *node.Node, cfg *eth.Config) { func RegisterLesServerService(stack *node.Node, cfg *eth.Config) {
//if the light client is not requested and the light server is requested //if the light client is not requested and the light server is requested
if cfg.SyncMode != downloader.LightSync && cfg.LightServ > 0 { if cfg.SyncMode == downloader.LightSync || cfg.LightServ <= 0 {
//register a light server service return
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
//check if the main Eth protocol service is running
var ethService *eth.Ethereum
if ctx.Service(&ethService) != nil {
return nil, errors.New("Failed to start the Les Server service because Ethereum service is not running")
}
return les.NewLesServer(ethService, cfg)
}); err != nil {
Fatalf("Failed to register the Light Server service: %v", err)
}
} }
//register a light server service
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
//check if the main Eth protocol service is running
var ethService *eth.Ethereum
if ctx.Service(&ethService) != nil {
return nil, errors.New("Failed to start the Les Server service because Ethereum service is not running")
}
return les.NewLesServer(ethService, cfg)
}); err != nil {
Fatalf("Failed to register the Light Server service: %v", err)
}
} }
// RegisterEthService adds an Ethereum client to the stack if the config permits // RegisterEthService adds an Ethereum client to the stack if the config permits
func RegisterEthService(stack *node.Node, cfg *eth.Config) { func RegisterEthService(stack *node.Node, cfg *eth.Config) {
//if the light client is not requested //if the light client is not requested
if cfg.SyncMode != downloader.LightSync { if cfg.SyncMode == downloader.LightSync {
//register a service for the Eth protocol return
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
return eth.New(ctx, cfg)
}); err != nil {
Fatalf("Failed to register the Ethereum service: %v", err)
}
} }
//register a service for the Eth protocol
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
return eth.New(ctx, cfg)
}); err != nil {
Fatalf("Failed to register the Ethereum service: %v", err)
}
} }
// RegisterDashboardService adds a dashboard to the stack. // RegisterDashboardService adds a dashboard to the stack.

View file

@ -47,25 +47,16 @@ import (
const ( const (
softResponseLimit = 2 * 1024 * 1024 // Target maximum size of returned blocks, headers or node data. softResponseLimit = 2 * 1024 * 1024 // Target maximum size of returned blocks, headers or node data.
estHeaderRlpSize = 500 // Approximate size of an RLP encoded block header estHeaderRlpSize = 500 // Approximate size of an RLP encoded block header
ethVersion = 63 // equivalent eth version for the downloader
ethVersion = 63 // equivalent eth version for the downloader MaxHeaderFetch = 192 // the maximum number of block headers to be fetched per retrieval request
MaxBodyFetch = 32 // the maximum number of block bodies to be fetched per retrieval request
// MaxHeaderFetch is the maximum number of block headers to be fetched per retrieval request MaxReceiptFetch = 128 // is the maximum number of transaction receipts to allow to be fetched per request
MaxHeaderFetch = 192 MaxCodeFetch = 64 // is the maximum number of contract codes to allow to be fetched per request
// MaxBodyFetch is the maximum number of block bodies to be fetched per retrieval request MaxProofsFetch = 64 // is the maximum number of merkle proofs to be fetched per retrieval request
MaxBodyFetch = 32 MaxHelperTrieProofsFetch = 64 // is the maximum number of merkle proofs to be fetched per retrieval request
// MaxReceiptFetch is the maximum number of transaction receipts to allow to be fetched per request MaxTxSend = 64 // is the maximum number of transactions to be sent per request
MaxReceiptFetch = 128 MaxTxStatus = 256 // is the maximum number of transactions to queried per request
// MaxCodeFetch is the maximum number of contract codes to allow to be fetched per request
MaxCodeFetch = 64
// MaxProofsFetch is the maximum number of merkle proofs to be fetched per retrieval request
MaxProofsFetch = 64
// MaxHelperTrieProofsFetch is the maximum number of merkle proofs to be fetched per retrieval request
MaxHelperTrieProofsFetch = 64
// MaxTxSend is the maximum number of transactions to be sent per request
MaxTxSend = 64
// MaxTxStatus is the maximum number of transactions to queried per request
MaxTxStatus = 256
disableClientRemovePeer = false disableClientRemovePeer = false
) )

View file

@ -308,9 +308,7 @@ func (s *LesServer) Stop() error {
}() }()
s.freeClientPool.stop() s.freeClientPool.stop()
s.costTracker.stop() s.costTracker.stop()
s.protocolManager.Stop() s.protocolManager.Stop()
s.csvLogger.Stop() s.csvLogger.Stop()
return nil return nil