mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22: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
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
|
@ -197,9 +198,10 @@ func (d *Delivery) handleRetrieveRequestMsg(ctx context.Context, sp *Peer, req *
|
|||
}
|
||||
|
||||
type ChunkDeliveryMsg struct {
|
||||
Addr storage.Address
|
||||
SData []byte // the stored chunk Data (incl size)
|
||||
peer *Peer // set in handleChunkDeliveryMsg
|
||||
Addr storage.Address
|
||||
SData []byte // the stored chunk Data (incl size)
|
||||
peer *Peer // set in handleChunkDeliveryMsg
|
||||
Syncing bool // if true, this is a delivery for syncing (no SWAP accounting needed)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ func NewPeer(peer *protocols.Peer, streamer *Registry) *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
|
||||
ctx, sp = spancontext.StartSpan(
|
||||
ctx,
|
||||
|
|
@ -138,8 +138,9 @@ func (p *Peer) Deliver(ctx context.Context, chunk storage.Chunk, priority uint8)
|
|||
defer sp.Finish()
|
||||
|
||||
msg := &ChunkDeliveryMsg{
|
||||
Addr: chunk.Address(),
|
||||
SData: chunk.Data(),
|
||||
Addr: chunk.Address(),
|
||||
SData: chunk.Data(),
|
||||
Syncing: syncing,
|
||||
}
|
||||
return p.SendPriority(ctx, msg, priority)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue