From bd189038a481210416dfdee92041765c55b660bb Mon Sep 17 00:00:00 2001 From: Attila Gazso Date: Tue, 16 Oct 2018 14:39:15 +0200 Subject: [PATCH] swarm/network/stream: Added comments explaining RegistryOptions --- swarm/network/stream/lightnode_test.go | 23 +++++++++++++++++++++++ swarm/network/stream/stream.go | 6 +++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/swarm/network/stream/lightnode_test.go b/swarm/network/stream/lightnode_test.go index 1cecead2e5..0d3bc7f544 100644 --- a/swarm/network/stream/lightnode_test.go +++ b/swarm/network/stream/lightnode_test.go @@ -1,3 +1,18 @@ +// Copyright 2018 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . package stream import ( @@ -6,6 +21,8 @@ import ( p2ptest "github.com/ethereum/go-ethereum/p2p/testing" ) +// This test checks the default behavior of the server, that is +// when it is serving Retrieve requests. func TestLigthnodeRetrieveRequestWithRetrieve(t *testing.T) { registryOptions := &RegistryOptions{ DoServeRetrieve: true, @@ -42,6 +59,8 @@ func TestLigthnodeRetrieveRequestWithRetrieve(t *testing.T) { } } +// This test checks the Lightnode behavior of server, when serving Retrieve +// requests are disabled func TestLigthnodeRetrieveRequestWithoutRetrieve(t *testing.T) { registryOptions := &RegistryOptions{ DoServeRetrieve: false, @@ -83,6 +102,8 @@ func TestLigthnodeRetrieveRequestWithoutRetrieve(t *testing.T) { } } +// This test checks the default behavior of the server, that is +// when syncing is enabled. func TestLigthnodeRequestSubscriptionWithSync(t *testing.T) { registryOptions := &RegistryOptions{ DoSync: true, @@ -125,6 +146,8 @@ func TestLigthnodeRequestSubscriptionWithSync(t *testing.T) { } } +// This test checks the Lightnode behavior of the server, that is +// when syncing is disabled. func TestLigthnodeRequestSubscriptionWithoutSync(t *testing.T) { registryOptions := &RegistryOptions{ DoSync: false, diff --git a/swarm/network/stream/stream.go b/swarm/network/stream/stream.go index bf7a859f64..183383f751 100644 --- a/swarm/network/stream/stream.go +++ b/swarm/network/stream/stream.go @@ -66,9 +66,9 @@ type Registry struct { // RegistryOptions holds optional values for NewRegistry constructor. type RegistryOptions struct { SkipCheck bool - DoSync bool - DoRetrieve bool - DoServeRetrieve 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 }