diff --git a/Lib9c.DPoS.Tests/DistributeTest.cs b/Lib9c.DPoS.Tests/DistributeTest.cs
index 9c50484e87..36b8060e9d 100644
--- a/Lib9c.DPoS.Tests/DistributeTest.cs
+++ b/Lib9c.DPoS.Tests/DistributeTest.cs
@@ -186,14 +186,14 @@ public void ValidatorSetTest()
= (validatorRewardSum * 205)
.DivRem(100 + (101 + 200) * 50 - 101 - 102 + 204 + 306);
var (commissionA, _)
- = (validatorRewardA * Validator.CommissionNumer)
- .DivRem(Validator.CommissionDenom);
+ = (validatorRewardA * Validator.CommissionNumerator)
+ .DivRem(Validator.CommissionDenominator);
var (validatorRewardB, _)
= (validatorRewardSum * 307)
.DivRem(100 + (101 + 200) * 50 - 101 - 102 + 204 + 306);
var (commissionB, _)
- = (validatorRewardB * Validator.CommissionNumer)
- .DivRem(Validator.CommissionDenom);
+ = (validatorRewardB * Validator.CommissionNumerator)
+ .DivRem(Validator.CommissionDenominator);
Assert.Equal(
Asset.ConsensusToken * 0,
diff --git a/Lib9c.DPoS/Action/DPoSModule.cs b/Lib9c.DPoS/Action/DPoSModule.cs
index c6f7e5e9ea..6e280e9086 100644
--- a/Lib9c.DPoS/Action/DPoSModule.cs
+++ b/Lib9c.DPoS/Action/DPoSModule.cs
@@ -7,9 +7,9 @@ namespace Lib9c.DPoS.Action
{
public static class DPoSModule
{
- public static IValue? GetDPoSState(this IWorld world, Address address)
+ public static IValue? GetDPoSState(this IWorldState world, Address address)
{
- return world.GetAccount(ReservedAddress.DPoSAccountAddress).GetState(address);
+ return world.GetAccountState(ReservedAddress.DPoSAccountAddress).GetState(address);
}
public static IWorld SetDPoSState(this IWorld world, Address address, IValue value)
diff --git a/Lib9c.DPoS/Control/AllocateReward.cs b/Lib9c.DPoS/Control/AllocateReward.cs
index 6cc0039330..1fac7519a3 100644
--- a/Lib9c.DPoS/Control/AllocateReward.cs
+++ b/Lib9c.DPoS/Control/AllocateReward.cs
@@ -153,8 +153,8 @@ FungibleAssetValue powerDenom
= (validatorRewardSum * powerNumer.RawValue)
.DivRem(powerDenom.RawValue);
var (commission, _)
- = (validatorReward * Validator.CommissionNumer)
- .DivRem(Validator.CommissionDenom);
+ = (validatorReward * Validator.CommissionNumerator)
+ .DivRem(Validator.CommissionDenominator);
FungibleAssetValue delegationRewardSum = validatorReward - commission;
diff --git a/Lib9c.DPoS/Control/DelegateCtrl.cs b/Lib9c.DPoS/Control/DelegateCtrl.cs
index 791bff0be3..11f56036f2 100644
--- a/Lib9c.DPoS/Control/DelegateCtrl.cs
+++ b/Lib9c.DPoS/Control/DelegateCtrl.cs
@@ -13,9 +13,7 @@ namespace Lib9c.DPoS.Control
{
internal static class DelegateCtrl
{
- internal static Delegation? GetDelegation(
- IWorld states,
- Address delegationAddress)
+ internal static Delegation? GetDelegation(IWorldState states, Address delegationAddress)
{
if (states.GetDPoSState(delegationAddress) is { } value)
{
diff --git a/Lib9c.DPoS/Control/RedelegateCtrl.cs b/Lib9c.DPoS/Control/RedelegateCtrl.cs
index ae1eaca279..fd235db5dd 100644
--- a/Lib9c.DPoS/Control/RedelegateCtrl.cs
+++ b/Lib9c.DPoS/Control/RedelegateCtrl.cs
@@ -15,7 +15,7 @@ namespace Lib9c.DPoS.Control
internal static class RedelegateCtrl
{
internal static Redelegation? GetRedelegation(
- IWorld states,
+ IWorldState states,
Address redelegationAddress)
{
if (states.GetDPoSState(redelegationAddress) is { } value)
diff --git a/Lib9c.DPoS/Control/UnbondingSetCtrl.cs b/Lib9c.DPoS/Control/UnbondingSetCtrl.cs
index aea9974758..06e5d47b6a 100644
--- a/Lib9c.DPoS/Control/UnbondingSetCtrl.cs
+++ b/Lib9c.DPoS/Control/UnbondingSetCtrl.cs
@@ -9,6 +9,16 @@ namespace Lib9c.DPoS.Control
{
internal static class UnbondingSetCtrl
{
+ internal static UnbondingSet? GetUnbondingSet(IWorldState states)
+ {
+ if (states.GetDPoSState(ReservedAddress.UnbondingSet) is { } value)
+ {
+ return new UnbondingSet(value);
+ }
+
+ return null;
+ }
+
internal static (IWorld, UnbondingSet) FetchUnbondingSet(IWorld states)
{
UnbondingSet unbondingSet;
diff --git a/Lib9c.DPoS/Control/UndelegateCtrl.cs b/Lib9c.DPoS/Control/UndelegateCtrl.cs
index 782144ef2e..143f33fc1a 100644
--- a/Lib9c.DPoS/Control/UndelegateCtrl.cs
+++ b/Lib9c.DPoS/Control/UndelegateCtrl.cs
@@ -15,7 +15,7 @@ namespace Lib9c.DPoS.Control
internal static class UndelegateCtrl
{
internal static Undelegation? GetUndelegation(
- IWorld state,
+ IWorldState state,
Address undelegationAddress)
{
if (state.GetDPoSState(undelegationAddress) is { } value)
diff --git a/Lib9c.DPoS/Control/ValidatorCtrl.cs b/Lib9c.DPoS/Control/ValidatorCtrl.cs
index 3fb6f4189a..0b4e7c32a8 100644
--- a/Lib9c.DPoS/Control/ValidatorCtrl.cs
+++ b/Lib9c.DPoS/Control/ValidatorCtrl.cs
@@ -13,9 +13,7 @@ namespace Lib9c.DPoS.Control
{
internal static class ValidatorCtrl
{
- internal static Validator? GetValidator(
- IWorld states,
- Address validatorAddress)
+ internal static Validator? GetValidator(IWorldState states, Address validatorAddress)
{
if (states.GetDPoSState(validatorAddress) is { } value)
{
diff --git a/Lib9c.DPoS/Control/ValidatorDelegationSetCtrl.cs b/Lib9c.DPoS/Control/ValidatorDelegationSetCtrl.cs
index 967dda206e..7464180764 100644
--- a/Lib9c.DPoS/Control/ValidatorDelegationSetCtrl.cs
+++ b/Lib9c.DPoS/Control/ValidatorDelegationSetCtrl.cs
@@ -7,6 +7,20 @@ namespace Lib9c.DPoS.Control
{
internal static class ValidatorDelegationSetCtrl
{
+ internal static ValidatorDelegationSet? GetValidatorDelegationSet(
+ IWorldState states, Address validatorAddress)
+ {
+ Address validatorDelegationSetAddress = ValidatorDelegationSet.DeriveAddress(
+ validatorAddress);
+
+ if (states.GetDPoSState(validatorDelegationSetAddress) is { } value)
+ {
+ return new ValidatorDelegationSet(value);
+ }
+
+ return null;
+ }
+
internal static (IWorld, ValidatorDelegationSet) FetchValidatorDelegationSet(
IWorld states, Address validatorAddress)
{
diff --git a/Lib9c.DPoS/Control/ValidatorPowerIndexCtrl.cs b/Lib9c.DPoS/Control/ValidatorPowerIndexCtrl.cs
index fee7a3640c..1d4bd558eb 100644
--- a/Lib9c.DPoS/Control/ValidatorPowerIndexCtrl.cs
+++ b/Lib9c.DPoS/Control/ValidatorPowerIndexCtrl.cs
@@ -11,8 +11,17 @@ namespace Lib9c.DPoS.Control
{
internal static class ValidatorPowerIndexCtrl
{
- internal static (IWorld, ValidatorPowerIndex) FetchValidatorPowerIndex(
- IWorld states)
+ internal static ValidatorPowerIndex? GetValidatorPowerIndex(IWorldState states)
+ {
+ if (states.GetDPoSState(ReservedAddress.ValidatorPowerIndex) is { } value)
+ {
+ return new ValidatorPowerIndex(value);
+ }
+
+ return null;
+ }
+
+ internal static (IWorld, ValidatorPowerIndex) FetchValidatorPowerIndex(IWorld states)
{
ValidatorPowerIndex validatorPowerIndex;
if (states.GetDPoSState(ReservedAddress.ValidatorPowerIndex) is { } value)
diff --git a/Lib9c.DPoS/Control/ValidatorRewardsCtrl.cs b/Lib9c.DPoS/Control/ValidatorRewardsCtrl.cs
index ef001fef83..3a5999c5c0 100644
--- a/Lib9c.DPoS/Control/ValidatorRewardsCtrl.cs
+++ b/Lib9c.DPoS/Control/ValidatorRewardsCtrl.cs
@@ -10,7 +10,7 @@ namespace Lib9c.DPoS.Control
internal static class ValidatorRewardsCtrl
{
internal static ValidatorRewards? GetValidatorRewards(
- IWorld states,
+ IWorldState states,
Address validatorAddress)
{
if (states.GetDPoSState(validatorAddress) is { } value)
diff --git a/Lib9c.DPoS/Control/ValidatorSetCtrl.cs b/Lib9c.DPoS/Control/ValidatorSetCtrl.cs
index 8230662c8f..3efb68c792 100644
--- a/Lib9c.DPoS/Control/ValidatorSetCtrl.cs
+++ b/Lib9c.DPoS/Control/ValidatorSetCtrl.cs
@@ -11,6 +11,16 @@ namespace Lib9c.DPoS.Control
{
internal static class ValidatorSetCtrl
{
+ internal static ValidatorSet? GetValidatorSet(IWorldState states, Address address)
+ {
+ if (states.GetDPoSState(address) is { } value)
+ {
+ return new ValidatorSet(value);
+ }
+
+ return null;
+ }
+
internal static (IWorld, ValidatorSet) FetchValidatorSet(IWorld states, Address address)
{
ValidatorSet validatorSet;
diff --git a/Lib9c.DPoS/Model/Validator.cs b/Lib9c.DPoS/Model/Validator.cs
index da84e75b83..6a56745ffc 100644
--- a/Lib9c.DPoS/Model/Validator.cs
+++ b/Lib9c.DPoS/Model/Validator.cs
@@ -43,9 +43,9 @@ public Validator(IValue serialized)
// May be it would be better to be serialized
public static FungibleAssetValue MinSelfDelegation => Asset.ConsensusToken * 1;
- public static BigInteger CommissionNumer => 1;
+ public static BigInteger CommissionNumerator => 1;
- public static BigInteger CommissionDenom => 10;
+ public static BigInteger CommissionDenominator => 10;
public static double CommissionMaxRate => 0.2;
diff --git a/Lib9c.sln.DotSettings b/Lib9c.sln.DotSettings
index f0ba53d29f..a8a315c16f 100644
--- a/Lib9c.sln.DotSettings
+++ b/Lib9c.sln.DotSettings
@@ -10,8 +10,12 @@
True
True
True
+ True
True
True
True
+ True
+ True
+ True
True
True
\ No newline at end of file