diff options
author | Attila Gazso <attila.gazso@prezi.com> | 2018-10-18 01:22:37 +0800 |
---|---|---|
committer | Viktor TrĂ³n <viktor.tron@gmail.com> | 2018-10-18 01:22:37 +0800 |
commit | cdf5982cfca2cd7d5fea85c226af5e48fde837df (patch) | |
tree | adcd4a5b24d285ca72174c085bd17a898b628721 /swarm/network/stream/stream.go | |
parent | 4e693ad5a6f118dcf4f3586938c17fc8ef5822b5 (diff) | |
download | go-tangerine-cdf5982cfca2cd7d5fea85c226af5e48fde837df.tar go-tangerine-cdf5982cfca2cd7d5fea85c226af5e48fde837df.tar.gz go-tangerine-cdf5982cfca2cd7d5fea85c226af5e48fde837df.tar.bz2 go-tangerine-cdf5982cfca2cd7d5fea85c226af5e48fde837df.tar.lz go-tangerine-cdf5982cfca2cd7d5fea85c226af5e48fde837df.tar.xz go-tangerine-cdf5982cfca2cd7d5fea85c226af5e48fde837df.tar.zst go-tangerine-cdf5982cfca2cd7d5fea85c226af5e48fde837df.zip |
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
Diffstat (limited to 'swarm/network/stream/stream.go')
-rw-r--r-- | swarm/network/stream/stream.go | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/swarm/network/stream/stream.go b/swarm/network/stream/stream.go index 3861cfcf6..1dc2a8cba 100644 --- a/swarm/network/stream/stream.go +++ b/swarm/network/stream/stream.go @@ -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 |