diff options
author | holisticode <holistic.computing@gmail.com> | 2018-10-21 15:30:41 +0800 |
---|---|---|
committer | Viktor Trón <viktor.tron@gmail.com> | 2018-10-21 15:30:41 +0800 |
commit | 88b41a9e680a764aa079051aa7c71b3c6879d60a (patch) | |
tree | ede6da904a9791d2ecc7e3fa5ec9dfb3d91e5007 /swarm/network/stream/delivery.go | |
parent | 66debd91d9268067000c061093a674ce34f18d48 (diff) | |
download | dexon-88b41a9e680a764aa079051aa7c71b3c6879d60a.tar dexon-88b41a9e680a764aa079051aa7c71b3c6879d60a.tar.gz dexon-88b41a9e680a764aa079051aa7c71b3c6879d60a.tar.bz2 dexon-88b41a9e680a764aa079051aa7c71b3c6879d60a.tar.lz dexon-88b41a9e680a764aa079051aa7c71b3c6879d60a.tar.xz dexon-88b41a9e680a764aa079051aa7c71b3c6879d60a.tar.zst dexon-88b41a9e680a764aa079051aa7c71b3c6879d60a.zip |
swarm/network/stream: disambiguate chunk delivery messages (retrieval… (#17920)
* swarm/network/stream: disambiguate chunk delivery messages (retrieval vs syncing)
* swarm/network/stream: addressed PR comments
* swarm/network/stream: stream protocol version change due to new message types in this PR
Diffstat (limited to 'swarm/network/stream/delivery.go')
-rw-r--r-- | swarm/network/stream/delivery.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/swarm/network/stream/delivery.go b/swarm/network/stream/delivery.go index 0429c4dff..9092ffe3e 100644 --- a/swarm/network/stream/delivery.go +++ b/swarm/network/stream/delivery.go @@ -173,7 +173,8 @@ func (d *Delivery) handleRetrieveRequestMsg(ctx context.Context, sp *Peer, req * return } if req.SkipCheck { - err = sp.Deliver(ctx, chunk, s.priority) + syncing := false + err = sp.Deliver(ctx, chunk, s.priority, syncing) if err != nil { log.Warn("ERROR in handleRetrieveRequestMsg", "err", err) } @@ -189,12 +190,22 @@ func (d *Delivery) handleRetrieveRequestMsg(ctx context.Context, sp *Peer, req * return nil } +//Chunk delivery always uses the same message type.... type ChunkDeliveryMsg struct { Addr storage.Address SData []byte // the stored chunk Data (incl size) peer *Peer // set in handleChunkDeliveryMsg } +//...but swap accounting needs to disambiguate if it is a delivery for syncing or for retrieval +//as it decides based on message type if it needs to account for this message or not + +//defines a chunk delivery for retrieval (with accounting) +type ChunkDeliveryMsgRetrieval ChunkDeliveryMsg + +//defines a chunk delivery for syncing (without accounting) +type ChunkDeliveryMsgSyncing ChunkDeliveryMsg + // TODO: Fix context SNAFU func (d *Delivery) handleChunkDeliveryMsg(ctx context.Context, sp *Peer, req *ChunkDeliveryMsg) error { var osp opentracing.Span |