1
1
using Libplanet . Crypto ;
2
+ using Libplanet . Serialization ;
2
3
using Libplanet . Types . Assets ;
3
4
using Libplanet . Types . Consensus ;
4
5
@@ -57,16 +58,20 @@ public static FungibleAssetValue GetTotalSupply(this IWorldState @this, Currency
57
58
=> @this . GetCurrencyAccount ( currency ) . GetTotalSupply ( currency ) ;
58
59
59
60
public static ImmutableSortedSet < Validator > GetValidatorSet ( this IWorldState @this )
60
- => @this . GetValidatorSetAccount ( ) . GetValidatorSet ( ) ;
61
+ {
62
+ var accountState = @this . GetAccountState ( ReservedAddresses . ValidatorSetAddress ) ;
63
+ var value = accountState . GetState ( ReservedAddresses . ValidatorSetAddress ) ;
64
+ return ModelSerializer . Deserialize < ImmutableSortedSet < Validator > > ( value ) ;
65
+ }
61
66
62
- public static IWorld SetValidatorSet ( this IWorld @this , ImmutableSortedSet < Validator > validatorSet )
63
- => @this . SetValidatorSetAccount (
64
- @this . GetValidatorSetAccount ( ) . SetValidatorSet ( validatorSet ) ) ;
67
+ // public static IWorld SetValidatorSet(this IWorld @this, ImmutableSortedSet<Validator> validatorSet)
68
+ // => @this.SetValidatorSetAccount(
69
+ // @this.GetValidatorSetAccount().SetValidatorSet(validatorSet));
65
70
66
- internal static ValidatorSetAccount GetValidatorSetAccount ( this IWorldState @this )
67
- => new (
68
- @this . GetAccountState ( ReservedAddresses . ValidatorSetAccount ) . Trie ,
69
- @this . Version ) ;
71
+ // internal static ValidatorSetAccount GetValidatorSetAccount(this IWorldState @this)
72
+ // => new(
73
+ // @this.GetAccountState(ReservedAddresses.ValidatorSetAccount).Trie,
74
+ // @this.Version);
70
75
71
76
internal static CurrencyAccount GetCurrencyAccount (
72
77
this IWorldState @this , Currency currency )
@@ -92,20 +97,20 @@ internal static IWorld SetCurrencyAccount(
92
97
currencyAccount . AsAccount ( ) ) ;
93
98
}
94
99
95
- internal static IWorld SetValidatorSetAccount (
96
- this IWorld @this , ValidatorSetAccount validatorSetAccount )
97
- {
98
- if ( @this . Version != validatorSetAccount . WorldVersion )
99
- {
100
- throw new ArgumentException (
101
- $ "Given { nameof ( validatorSetAccount ) } must have the same version as " +
102
- $ "the version of the world { @this . Version } : " +
103
- $ "{ validatorSetAccount . WorldVersion } ",
104
- nameof ( validatorSetAccount ) ) ;
105
- }
106
-
107
- return @this . SetAccount (
108
- ReservedAddresses . ValidatorSetAccount ,
109
- validatorSetAccount . AsAccount ( ) ) ;
110
- }
100
+ // internal static IWorld SetValidatorSetAccount(
101
+ // this IWorld @this, ValidatorSetAccount validatorSetAccount)
102
+ // {
103
+ // if (@this.Version != validatorSetAccount.WorldVersion)
104
+ // {
105
+ // throw new ArgumentException(
106
+ // $"Given {nameof(validatorSetAccount)} must have the same version as " +
107
+ // $"the version of the world {@this.Version}: " +
108
+ // $"{validatorSetAccount.WorldVersion}",
109
+ // nameof(validatorSetAccount));
110
+ // }
111
+
112
+ // return @this.SetAccount(
113
+ // ReservedAddresses.ValidatorSetAccount,
114
+ // validatorSetAccount.AsAccount());
115
+ // }
111
116
}
0 commit comments