-
Notifications
You must be signed in to change notification settings - Fork 456
Balance change after new block is delayed by several seconds - Closes #2403 #2519
Balance change after new block is delayed by several seconds - Closes #2403 #2519
Conversation
This PR is changing the behavior of broadcasting of blocks. By which I mean that earlier the node was broadcasting blocks even they were invalid whereas after this change node will only broadcast blocks which it considers to be valid. Therefore, this change will affect how the network behaves during fork recovery. |
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.
I agree with @SargeKhan, we should not change the behavior when we don't need to.
Good point @SargeKhan |
This reverts commit b07a837.
@lsilvs So what is currently wrong with the logic here is that
And remove emitting this event from |
This is required due to the use of Cache Module inside Blocks Module
As discussed with @4miners and @nazarhussain , just adding The solution was to refactor |
* @param {function} cb | ||
* @todo Add description for the params | ||
* @todo Add @returns tag | ||
*/ | ||
Cache.prototype.onNewBlock = function(block, cb) { | ||
Cache.prototype.clearBlockRelatedCache = function(cb) { | ||
cb = cb || function() {}; | ||
|
||
logger.debug( |
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.
Please change this log message. As its not Cache - onNewBlock
now.
modules/blocks.js
Outdated
* @todo Add @returns tag | ||
*/ | ||
Blocks.prototype.onNewBlock = function(block) { | ||
modules.cache.clearBlockRelatedCache(err => { |
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.
There is already two methods removeByPattern
and deleteJsonForKey
in general. I would rather suggest to develop a generic method clearCacheFor(scope)
, scope can be blocks
, transactions
or in future any thing. This way we can make that single method useable on different cases.
@@ -404,6 +402,9 @@ Cache.prototype.onSyncFinished = function() { | |||
|
|||
Cache.prototype.KEYS = { | |||
transactionCount: 'transactionCount', | |||
blocksApi: '/api/blocks*', | |||
transactionsApi: '/api/transactions*', | |||
delegatesApi: '/api/delegates*', |
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.
Where this is used?
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.
You mean the delegatesApi
?
If so, I meant to use it in onFinishRound
and onTransactionsSaved
to keep consistency but it seems I've forgotten.
Good catch! I will added it.
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.
Yep, thanks.
It might solve the #955 as well. |
What was the problem?
New blocks were been broadcasted before cache for blocks and transactions been cleared.
How did I fix it?
Changed the
broadcastBlock
operation to be executed afterapplyBlock
How to test it?
Run the tests.
Follow the steps described in the issue #2403
Review checklist