swarm: Lightnode mode: disable sync, retrieve, subscription (#17899)
* swarm: Lightnode mode: disable sync, retrieve, subscription * swarm/network/stream: assign error and check in one line * swarm: restructured RegistryOption initializing * swarm: empty commit to retrigger CI build * swarm/network/stream: Added comments explaining RegistryOptions
This commit is contained in:
committed by
Viktor Trón
parent
4e693ad5a6
commit
cdf5982cfc
@@ -66,8 +66,9 @@ type Registry struct {
|
||||
// RegistryOptions holds optional values for NewRegistry constructor.
|
||||
type RegistryOptions struct {
|
||||
SkipCheck bool
|
||||
DoSync bool
|
||||
DoRetrieve bool
|
||||
DoSync bool // Sets if the server syncs with peers. Default is true, set to false by lightnode or nosync flags.
|
||||
DoRetrieve bool // Sets if the server issues Retrieve requests. Default is true.
|
||||
DoServeRetrieve bool // Sets if the server serves Retrieve requests. Default is true, set to false by lightnode flag.
|
||||
SyncUpdateDelay time.Duration
|
||||
MaxPeerServers int // The limit of servers for each peer in registry
|
||||
}
|
||||
@@ -93,14 +94,21 @@ func NewRegistry(localID enode.ID, delivery *Delivery, syncChunkStore storage.Sy
|
||||
}
|
||||
streamer.api = NewAPI(streamer)
|
||||
delivery.getPeer = streamer.getPeer
|
||||
streamer.RegisterServerFunc(swarmChunkServerStreamName, func(_ *Peer, _ string, _ bool) (Server, error) {
|
||||
return NewSwarmChunkServer(delivery.chunkStore), nil
|
||||
})
|
||||
|
||||
if options.DoServeRetrieve {
|
||||
streamer.RegisterServerFunc(swarmChunkServerStreamName, func(_ *Peer, _ string, _ bool) (Server, error) {
|
||||
return NewSwarmChunkServer(delivery.chunkStore), nil
|
||||
})
|
||||
}
|
||||
|
||||
streamer.RegisterClientFunc(swarmChunkServerStreamName, func(p *Peer, t string, live bool) (Client, error) {
|
||||
return NewSwarmSyncerClient(p, syncChunkStore, NewStream(swarmChunkServerStreamName, t, live))
|
||||
})
|
||||
RegisterSwarmSyncerServer(streamer, syncChunkStore)
|
||||
RegisterSwarmSyncerClient(streamer, syncChunkStore)
|
||||
|
||||
if options.DoSync {
|
||||
RegisterSwarmSyncerServer(streamer, syncChunkStore)
|
||||
RegisterSwarmSyncerClient(streamer, syncChunkStore)
|
||||
}
|
||||
|
||||
if options.DoSync {
|
||||
// latestIntC function ensures that
|
||||
|
Reference in New Issue
Block a user