-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: block broadcast when block comes from forger #2430
Conversation
@@ -63,8 +63,9 @@ export async function postBlock({ req }): Promise<void> { | |||
const blockchain: Blockchain.IBlockchain = app.resolvePlugin<Blockchain.IBlockchain>("blockchain"); | |||
|
|||
const block: Interfaces.IBlockData = req.data.block; | |||
const fromForger = isWhitelisted(app.resolveOptions("p2p").remoteAccess, req.headers.remoteAddress); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const fromForger = isWhitelisted(app.resolveOptions("p2p").remoteAccess, req.headers.remoteAddress); | |
const fromForger: boolean = isWhitelisted(app.resolveOptions("p2p").remoteAccess, req.headers.remoteAddress); |
@@ -310,9 +310,9 @@ export class NetworkMonitor implements P2P.INetworkMonitor { | |||
// wait a bit before broadcasting if a bit early | |||
const diff = blockPing.last - blockPing.first; | |||
const maxHop = 4; | |||
let proba = (maxHop - blockPing.count) / maxHop; | |||
let broadcastQuota = (maxHop - blockPing.count) / maxHop; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let broadcastQuota = (maxHop - blockPing.count) / maxHop; | |
let broadcastQuota: number = (maxHop - blockPing.count) / maxHop; |
Codecov Report
@@ Coverage Diff @@
## 2.4 #2430 +/- ##
==========================================
+ Coverage 67.91% 67.92% +<.01%
==========================================
Files 385 385
Lines 8438 8443 +5
Branches 430 392 -38
==========================================
+ Hits 5731 5735 +4
- Misses 2659 2660 +1
Partials 48 48
Continue to review full report at Codecov.
|
Proposed changes
When block is received from forger, always broadcast to all peers.
Also refactored the block broadcast general logic, to use "peer quotas" based on block pings, instead of using randomization to select peers to broadcast to.
Types of changes
Checklist