-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from Concordium/ss/update-to-p6
Updated SDK to align with Protocol 6
- Loading branch information
Showing
9 changed files
with
143 additions
and
21 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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Concordium.Grpc.V2; | ||
using Concordium.Sdk.Exceptions; | ||
using Concordium.Sdk.Helpers; | ||
|
||
namespace Concordium.Sdk.Types; | ||
|
||
/// <summary> | ||
/// Pending change in the baker's stake. | ||
/// </summary> | ||
public abstract record BakerPoolPendingChange | ||
{ | ||
internal static BakerPoolPendingChange? From(PoolPendingChange? pendingChange) | ||
{ | ||
if (pendingChange is null) | ||
{ | ||
return null; | ||
} | ||
|
||
return pendingChange.ChangeCase switch | ||
{ | ||
PoolPendingChange.ChangeOneofCase.Reduce => | ||
new BakerPoolReduceStakePending(CcdAmount.From(pendingChange.Reduce.ReducedEquityCapital), pendingChange.Reduce.EffectiveTime.ToDateTimeOffset()), | ||
PoolPendingChange.ChangeOneofCase.Remove => | ||
new BakerPoolRemovePending(pendingChange.Remove.EffectiveTime.ToDateTimeOffset()), | ||
PoolPendingChange.ChangeOneofCase.None => null, | ||
_ => throw new MissingEnumException<PoolPendingChange.ChangeOneofCase>(pendingChange.ChangeCase) | ||
}; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The baker will be removed at the given time. | ||
/// </summary> | ||
/// <param name="EffectiveTime">Time when the baker will be removed.</param> | ||
public sealed record BakerPoolRemovePending(DateTimeOffset EffectiveTime) : BakerPoolPendingChange; | ||
/// <summary> | ||
/// The stake is being reduced. The new stake will take affect at the given time. | ||
/// </summary> | ||
/// <param name="NewStake">New stake which will take effect.</param> | ||
/// <param name="EffectiveTime">Time when the baker will be removed.</param> | ||
public sealed record BakerPoolReduceStakePending(CcdAmount NewStake, DateTimeOffset EffectiveTime) : BakerPoolPendingChange; | ||
|
||
|
||
|
||
|
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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Concordium.Sdk.Helpers; | ||
|
||
namespace Concordium.Sdk.Types; | ||
|
||
/// <summary> | ||
/// Parameters pertaining to the Concordium BFT consensus. | ||
/// </summary> | ||
/// <param name="CurrentTimeoutDuration">The current duration to wait before a round times out.</param> | ||
/// <param name="CurrentRound">The current round.</param> | ||
/// <param name="CurrentEpoch">The current epoch.</param> | ||
/// <param name="TriggerBlockTime"> | ||
/// The first block in the epoc with a timestamp equal to or later than this timestamp, is considered | ||
/// to be the trigger block for the epoch transition. | ||
/// </param> | ||
public sealed record ConcordiumBftDetails(TimeSpan CurrentTimeoutDuration, Round CurrentRound, Epoch CurrentEpoch, DateTimeOffset TriggerBlockTime) | ||
{ | ||
internal static ConcordiumBftDetails? From(Grpc.V2.ConsensusInfo info) | ||
{ | ||
if (info.CurrentTimeoutDuration == null || info.CurrentRound == null || | ||
info.CurrentEpoch == null || info.TriggerBlockTime == null) | ||
{ | ||
return null; | ||
} | ||
|
||
return new ConcordiumBftDetails( | ||
info.CurrentTimeoutDuration.ToTimeSpan(), | ||
Round.From(info.CurrentRound), | ||
Epoch.From(info.CurrentEpoch), | ||
info.TriggerBlockTime.ToDateTimeOffset()); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Concordium.Sdk.Types; | ||
|
||
/// <summary> | ||
/// Round number. Applies to protocol 6 and onward. | ||
/// </summary> | ||
/// <param name="RoundNumber"></param> | ||
public readonly record struct Round(ulong RoundNumber) | ||
{ | ||
internal static Round From(Grpc.V2.Round round) => new(round.Value); | ||
} |