-
Notifications
You must be signed in to change notification settings - Fork 458
Conversation
…uced/missedBlocks as numbers
…s in votes snapshot
@@ -40,8 +40,8 @@ const normalFields = [ | |||
{ name: 'fees', cast: 'bigint', def: '0', skip: ifNotExists }, | |||
{ name: 'rewards', cast: 'bigint', def: '0', skip: ifNotExists }, | |||
{ name: 'vote', cast: 'bigint', def: '0', skip: ifNotExists }, | |||
{ name: 'producedBlocks', cast: 'bigint', def: '0', skip: ifNotExists }, | |||
{ name: 'missedBlocks', cast: 'bigint', def: '0', skip: ifNotExists }, | |||
{ name: 'producedBlocks', def: 0, skip: ifNotExists }, |
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.
(Not related to PR but) aren't def: 0
and skip: ifNotExists
conflicting? Meaning if default is 0 then it will always exist and never be skipped?
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.
@SargeKhan skip
is used by update
and sets
and ignored by inserts
and values
. So the def
covers the use case of inserting records.
api/controllers/accounts.js
Outdated
account.delegate.producedBlocks | ||
); | ||
account.delegate.missedBlocks = account.delegate.missedBlocks; | ||
account.delegate.producedBlocks = account.delegate.producedBlocks; |
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.
If you are not parsing, then you don't need these lines anymore.
api/controllers/delegates.js
Outdated
delegate.missedBlocks = parseInt(delegate.missedBlocks); | ||
delegate.producedBlocks = parseInt(delegate.producedBlocks); | ||
delegate.missedBlocks = delegate.missedBlocks; | ||
delegate.producedBlocks = delegate.producedBlocks; |
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.
Same here. If you are not parsing, then no need these lines.
@@ -20,6 +20,6 @@ | |||
*/ | |||
|
|||
UPDATE mem_accounts m | |||
SET vote = b.vote | |||
SET vote = b.vote, "missedBlocks" = b."missedBlocks", "producedBlocks" = b."producedBlocks" | |||
FROM mem_votes_snapshot b |
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.
As you are refactoring, I suggest to use FROM mem_votes_snapshot snapshot
and UPDATE mem_accounts accounts
. That will make the query more readable like SET accounts.vote = snapshot.vote
.
@nazarhussain Resolved, please check. |
What was the problem?
Inconsistencies in round module:
missedBlocks
andproducedBlocks
skipped during round snapshot creationland
andbackwardLand
in round logicmissedBlocks
andproducedBlocks
casted to big integer (database type isINT
)How did I fix it?
missedBlocks
andproducedBlocks
during round snapshot and then restoring them when we restore the snapshotland
(removedflushRound
call)backwardLand
(removedupdateMissedBlocks
,flushRound
,updateVotes
calls - because they will be overwritten anyway from snapshot)BIGINT
cast onmissedBlocks
andproducedBlocks
How to test it?
Run test suite.
Review checklist