From 6566a0a3b82f5d24d478d3876d5fa2b1b0e8684c Mon Sep 17 00:00:00 2001 From: Viktor TrĂ³n Date: Fri, 12 Oct 2018 16:26:16 +0200 Subject: swarm/network/stream: generalise setting of next batch (#17818) * swarm/network/stream: generalize SetNextBatch and add Server SessionIndex * swarm/network/stream: fix a typo in comment * swarm/network/stream: remove live argument from NewSwarmSyncerServer --- swarm/network/stream/intervals_test.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'swarm/network/stream/intervals_test.go') diff --git a/swarm/network/stream/intervals_test.go b/swarm/network/stream/intervals_test.go index 269259423..3164193b3 100644 --- a/swarm/network/stream/intervals_test.go +++ b/swarm/network/stream/intervals_test.go @@ -345,8 +345,6 @@ func (c *testExternalClient) BatchDone(Stream, uint64, []byte, []byte) func() (* func (c *testExternalClient) Close() {} -const testExternalServerBatchSize = 10 - type testExternalServer struct { t string keyFunc func(key []byte, index uint64) @@ -366,17 +364,11 @@ func newTestExternalServer(t string, sessionAt, maxKeys uint64, keyFunc func(key } } +func (s *testExternalServer) SessionIndex() (uint64, error) { + return s.sessionAt, nil +} + func (s *testExternalServer) SetNextBatch(from uint64, to uint64) ([]byte, uint64, uint64, *HandoverProof, error) { - if from == 0 && to == 0 { - from = s.sessionAt - to = s.sessionAt + testExternalServerBatchSize - } - if to-from > testExternalServerBatchSize { - to = from + testExternalServerBatchSize - 1 - } - if from >= s.maxKeys && to > s.maxKeys { - return nil, 0, 0, nil, io.EOF - } if to > s.maxKeys { to = s.maxKeys } -- cgit