-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
consensus_rights_delay
for ghostnet (#180)
- Loading branch information
Showing
6 changed files
with
92 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Tzkt.Sync/Protocols/Handlers/Proto21/Commits/BakerCycleCommit.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Tzkt.Sync/Protocols/Handlers/Proto21/Commits/BakingRightsCommit.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 38 additions & 1 deletion
39
Tzkt.Sync/Protocols/Handlers/Proto21/Commits/CycleCommit.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,44 @@ | ||
namespace Tzkt.Sync.Protocols.Proto21 | ||
using Tzkt.Data.Models; | ||
|
||
namespace Tzkt.Sync.Protocols.Proto21 | ||
{ | ||
class CycleCommit : Proto20.CycleCommit | ||
{ | ||
public CycleCommit(ProtocolHandler protocol) : base(protocol) { } | ||
|
||
public override async Task Apply(Block block) | ||
{ | ||
if (block.Cycle == block.Protocol.FirstCycle) | ||
{ | ||
var prevProto = await Cache.Protocols.GetAsync(block.Protocol.Code - 1); | ||
if (prevProto.ConsensusRightsDelay != block.Protocol.ConsensusRightsDelay) | ||
{ | ||
Cache.AppState.Get().CyclesCount--; | ||
return; | ||
} | ||
} | ||
|
||
await base.Apply(block); | ||
} | ||
|
||
public override async Task Revert(Block block) | ||
{ | ||
if (!block.Events.HasFlag(BlockEvents.CycleBegin)) | ||
return; | ||
|
||
block.Protocol ??= await Cache.Protocols.GetAsync(block.ProtoCode); | ||
|
||
if (block.Cycle == block.Protocol.FirstCycle) | ||
{ | ||
var prevProto = await Cache.Protocols.GetAsync(block.Protocol.Code - 1); | ||
if (prevProto.ConsensusRightsDelay != block.Protocol.ConsensusRightsDelay) | ||
{ | ||
Cache.AppState.Get().CyclesCount++; | ||
return; | ||
} | ||
} | ||
|
||
await base.Revert(block); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Tzkt.Sync/Protocols/Handlers/Proto21/Commits/DelegatorCycleCommit.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters