mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
swarm/network/stream: addressed PR comments
This commit is contained in:
parent
492095764a
commit
ae36406238
2 changed files with 16 additions and 15 deletions
|
|
@ -195,7 +195,6 @@ 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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//...but swap accounting needs to disambiguate if it is a delivery for syncing or for retrieval
|
//...but swap accounting needs to disambiguate if it is a delivery for syncing or for retrieval
|
||||||
|
|
|
||||||
|
|
@ -131,13 +131,10 @@ func NewPeer(peer *protocols.Peer, streamer *Registry) *Peer {
|
||||||
// Depending on the `syncing` parameter we send different message types
|
// Depending on the `syncing` parameter we send different message types
|
||||||
func (p *Peer) Deliver(ctx context.Context, chunk storage.Chunk, priority uint8, syncing bool) 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,
|
|
||||||
"send.chunk.delivery")
|
|
||||||
defer sp.Finish()
|
|
||||||
|
|
||||||
var msg interface{}
|
var msg interface{}
|
||||||
|
|
||||||
|
spanName := "send.chunk.delivery"
|
||||||
|
|
||||||
//we send different types of messages if delivery is for syncing or retrievals,
|
//we send different types of messages if delivery is for syncing or retrievals,
|
||||||
//even if handling and content of the message are the same,
|
//even if handling and content of the message are the same,
|
||||||
//because swap accounting decides which messages need accounting based on the message type
|
//because swap accounting decides which messages need accounting based on the message type
|
||||||
|
|
@ -145,15 +142,20 @@ func (p *Peer) Deliver(ctx context.Context, chunk storage.Chunk, priority uint8,
|
||||||
msg = &ChunkDeliveryMsgSyncing{
|
msg = &ChunkDeliveryMsgSyncing{
|
||||||
Addr: chunk.Address(),
|
Addr: chunk.Address(),
|
||||||
SData: chunk.Data(),
|
SData: chunk.Data(),
|
||||||
Syncing: syncing,
|
|
||||||
}
|
}
|
||||||
|
spanName += ".syncing"
|
||||||
} else {
|
} else {
|
||||||
msg = &ChunkDeliveryMsgRetrieval{
|
msg = &ChunkDeliveryMsgRetrieval{
|
||||||
Addr: chunk.Address(),
|
Addr: chunk.Address(),
|
||||||
SData: chunk.Data(),
|
SData: chunk.Data(),
|
||||||
Syncing: syncing,
|
|
||||||
}
|
}
|
||||||
|
spanName += ".retrieval"
|
||||||
}
|
}
|
||||||
|
ctx, sp = spancontext.StartSpan(
|
||||||
|
ctx,
|
||||||
|
spanName)
|
||||||
|
defer sp.Finish()
|
||||||
|
|
||||||
return p.SendPriority(ctx, msg, priority)
|
return p.SendPriority(ctx, msg, priority)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue