Skip to content

Commit

Permalink
fix:make offered content async gossip
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Kai <[email protected]>
  • Loading branch information
GrapeBaBa committed Apr 18, 2024
1 parent e97bca6 commit be7fc97
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
20 changes: 14 additions & 6 deletions portalnetwork/beacon/beacon_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,20 @@ func (bn *BeaconNetwork) processContentLoop(ctx context.Context) {
bn.log.Error("validate content failed", "err", err)
continue
}
gossippedNum, err := bn.portalProtocol.Gossip(&contentElement.Node, contentElement.ContentKeys, contentElement.Contents)
bn.log.Trace("gossippedNum", "gossippedNum", gossippedNum)
if err != nil {
bn.log.Error("gossip failed", "err", err)
continue
}
go func(ctx context.Context) {
select {
case <-ctx.Done():
return
default:
var gossippedNum int
gossippedNum, err = bn.portalProtocol.Gossip(&contentElement.Node, contentElement.ContentKeys, contentElement.Contents)
bn.log.Trace("gossippedNum", "gossippedNum", gossippedNum)
if err != nil {
bn.log.Error("gossip failed", "err", err)
return
}
}
}(ctx)
}
}
}
21 changes: 15 additions & 6 deletions portalnetwork/history/history_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,21 @@ func (h *HistoryNetwork) processContentLoop(ctx context.Context) {
h.log.Error("validate content failed", "err", err)
continue
}
gossippedNum, err := h.portalProtocol.Gossip(&contentElement.Node, contentElement.ContentKeys, contentElement.Contents)
h.log.Trace("gossippedNum", "gossippedNum", gossippedNum)
if err != nil {
h.log.Error("gossip failed", "err", err)
continue
}

go func(ctx context.Context) {
select {
case <-ctx.Done():
return
default:
var gossippedNum int
gossippedNum, err = h.portalProtocol.Gossip(&contentElement.Node, contentElement.ContentKeys, contentElement.Contents)
h.log.Trace("gossippedNum", "gossippedNum", gossippedNum)
if err != nil {
h.log.Error("gossip failed", "err", err)
return
}
}
}(ctx)
}
}
}
Expand Down

0 comments on commit be7fc97

Please sign in to comment.