mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
swarm/network/stream: Syncing flag for ChunkDeliveryMsg
This commit is contained in:
parent
006ff30c78
commit
f5d736d107
3 changed files with 12 additions and 8 deletions
|
|
@ -180,7 +180,8 @@ func (d *Delivery) handleRetrieveRequestMsg(ctx context.Context, sp *Peer, req *
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if req.SkipCheck {
|
if req.SkipCheck {
|
||||||
err = sp.Deliver(ctx, chunk, s.priority)
|
syncing := false
|
||||||
|
err = sp.Deliver(ctx, chunk, s.priority, syncing)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("ERROR in handleRetrieveRequestMsg", "err", err)
|
log.Warn("ERROR in handleRetrieveRequestMsg", "err", err)
|
||||||
}
|
}
|
||||||
|
|
@ -200,6 +201,7 @@ type ChunkDeliveryMsg struct {
|
||||||
Addr storage.Address
|
Addr storage.Address
|
||||||
SData []byte // the stored chunk Data (incl size)
|
SData []byte // the stored chunk Data (incl size)
|
||||||
peer *Peer // set in handleChunkDeliveryMsg
|
peer *Peer // set in handleChunkDeliveryMsg
|
||||||
|
Syncing bool // if true, this is a delivery for syncing (no SWAP accounting needed)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix context SNAFU
|
// TODO: Fix context SNAFU
|
||||||
|
|
|
||||||
|
|
@ -347,7 +347,8 @@ func (p *Peer) handleWantedHashesMsg(ctx context.Context, req *WantedHashesMsg)
|
||||||
return fmt.Errorf("handleWantedHashesMsg get data %x: %v", hash, err)
|
return fmt.Errorf("handleWantedHashesMsg get data %x: %v", hash, err)
|
||||||
}
|
}
|
||||||
chunk := storage.NewChunk(hash, data)
|
chunk := storage.NewChunk(hash, data)
|
||||||
if err := p.Deliver(ctx, chunk, s.priority); err != nil {
|
syncing := true
|
||||||
|
if err := p.Deliver(ctx, chunk, s.priority, syncing); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ func NewPeer(peer *protocols.Peer, streamer *Registry) *Peer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deliver sends a storeRequestMsg protocol message to the peer
|
// Deliver sends a storeRequestMsg protocol message to the peer
|
||||||
func (p *Peer) Deliver(ctx context.Context, chunk storage.Chunk, priority uint8) error {
|
func (p *Peer) Deliver(ctx context.Context, chunk storage.Chunk, priority uint8, syncing bool) error {
|
||||||
var sp opentracing.Span
|
var sp opentracing.Span
|
||||||
ctx, sp = spancontext.StartSpan(
|
ctx, sp = spancontext.StartSpan(
|
||||||
ctx,
|
ctx,
|
||||||
|
|
@ -140,6 +140,7 @@ func (p *Peer) Deliver(ctx context.Context, chunk storage.Chunk, priority uint8)
|
||||||
msg := &ChunkDeliveryMsg{
|
msg := &ChunkDeliveryMsg{
|
||||||
Addr: chunk.Address(),
|
Addr: chunk.Address(),
|
||||||
SData: chunk.Data(),
|
SData: chunk.Data(),
|
||||||
|
Syncing: syncing,
|
||||||
}
|
}
|
||||||
return p.SendPriority(ctx, msg, priority)
|
return p.SendPriority(ctx, msg, priority)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue