@@ -37,12 +37,19 @@ abstract contract ValidatorInfoStorageV2 is IValidatorInfoV2, HasContracts, HasT
37
37
/**
38
38
* @inheritdoc IValidatorInfoV2
39
39
*/
40
- function getValidators () public view override returns (address [] memory validatorList_ ) {
41
- validatorList_ = new address [](_validatorCount);
40
+ function getValidators () public view override returns (TConsensus[] memory consensusList ) {
41
+ return __cid2cssBatch (getValidatorIds ());
42
+ }
43
+
44
+ /**
45
+ * @inheritdoc IValidatorInfoV2
46
+ */
47
+ function getValidatorIds () public view override returns (address [] memory cids ) {
48
+ cids = new address [](_validatorCount);
42
49
address iValidator;
43
- for (uint i; i < validatorList_ .length ; ) {
50
+ for (uint i; i < cids .length ; ) {
44
51
iValidator = _validatorIds[i];
45
- validatorList_ [i] = iValidator;
52
+ cids [i] = iValidator;
46
53
47
54
unchecked {
48
55
++ i;
@@ -53,13 +60,20 @@ abstract contract ValidatorInfoStorageV2 is IValidatorInfoV2, HasContracts, HasT
53
60
/**
54
61
* @inheritdoc IValidatorInfoV2
55
62
*/
56
- function getBlockProducers () public view override returns (address [] memory result ) {
57
- result = new address [](_validatorCount);
63
+ function getBlockProducers () public view override returns (TConsensus[] memory consensusList ) {
64
+ return __cid2cssBatch (getBlockProducerIds ());
65
+ }
66
+
67
+ /**
68
+ * @inheritdoc IValidatorInfoV2
69
+ */
70
+ function getBlockProducerIds () public view override returns (address [] memory cids ) {
71
+ cids = new address [](_validatorCount);
58
72
uint256 count = 0 ;
59
- for (uint i; i < result .length ; ) {
73
+ for (uint i; i < cids .length ; ) {
60
74
address validatorId = _validatorIds[i];
61
75
if (_isBlockProducerById (validatorId)) {
62
- result [count++ ] = validatorId;
76
+ cids [count++ ] = validatorId;
63
77
}
64
78
65
79
unchecked {
@@ -68,7 +82,7 @@ abstract contract ValidatorInfoStorageV2 is IValidatorInfoV2, HasContracts, HasT
68
82
}
69
83
70
84
assembly {
71
- mstore (result , count)
85
+ mstore (cids , count)
72
86
}
73
87
}
74
88
@@ -146,4 +160,7 @@ abstract contract ValidatorInfoStorageV2 is IValidatorInfoV2, HasContracts, HasT
146
160
147
161
/// @dev See {RoninValidatorSet-__css2cidBatch}
148
162
function __css2cidBatch (TConsensus[] memory consensusAddrs ) internal view virtual returns (address [] memory );
163
+
164
+ /// @dev See {RoninValidatorSet-__cid2cssBatch}
165
+ function __cid2cssBatch (address [] memory cids ) internal view virtual returns (TConsensus[] memory );
149
166
}
0 commit comments