diff options
author | Viktor TrĂ³n <viktor.tron@gmail.com> | 2018-10-12 22:26:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-12 22:26:16 +0800 |
commit | 6566a0a3b82f5d24d478d3876d5fa2b1b0e8684c (patch) | |
tree | 52f31f4bc541ed6bf9643bef11ceefd75e831d0e /swarm/network/stream/intervals_test.go | |
parent | dc3c3fb1e177c5d01ae3ca63717130eea924271e (diff) | |
download | dexon-6566a0a3b82f5d24d478d3876d5fa2b1b0e8684c.tar dexon-6566a0a3b82f5d24d478d3876d5fa2b1b0e8684c.tar.gz dexon-6566a0a3b82f5d24d478d3876d5fa2b1b0e8684c.tar.bz2 dexon-6566a0a3b82f5d24d478d3876d5fa2b1b0e8684c.tar.lz dexon-6566a0a3b82f5d24d478d3876d5fa2b1b0e8684c.tar.xz dexon-6566a0a3b82f5d24d478d3876d5fa2b1b0e8684c.tar.zst dexon-6566a0a3b82f5d24d478d3876d5fa2b1b0e8684c.zip |
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
Diffstat (limited to 'swarm/network/stream/intervals_test.go')
-rw-r--r-- | swarm/network/stream/intervals_test.go | 16 |
1 files changed, 4 insertions, 12 deletions
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 } |