mirror of https://github.com/nucypher/nucypher.git
Return meaningful error if there are not enough Ursulas
parent
3200ef05fc
commit
1dd5eb854e
|
@ -14,7 +14,7 @@ GNU Affero General Public License for more details.
|
|||
You should have received a copy of the GNU Affero General Public License
|
||||
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from typing import Iterable, Optional, List
|
||||
from typing import Iterable, List, Optional
|
||||
|
||||
from eth_typing import ChecksumAddress
|
||||
|
||||
|
@ -86,6 +86,8 @@ class MergedReservoir:
|
|||
else:
|
||||
return None
|
||||
|
||||
def __len__(self):
|
||||
return len(self.values) + len(self.reservoir)
|
||||
|
||||
class PrefetchStrategy:
|
||||
"""
|
||||
|
|
|
@ -112,6 +112,10 @@ the Pipe for nucypher network operations
|
|||
exclude_ursulas: Optional[Sequence[ChecksumAddress]] = None,
|
||||
include_ursulas: Optional[Sequence[ChecksumAddress]] = None) -> List[UrsulaInfo]:
|
||||
reservoir = self._make_staker_reservoir(quantity, duration_periods, exclude_ursulas, include_ursulas)
|
||||
|
||||
if len(reservoir) < quantity:
|
||||
raise ValueError(f"Requested quantity={quantity} Ursulas, but only {len(reservoir)} are available")
|
||||
|
||||
value_factory = PrefetchStrategy(reservoir, quantity)
|
||||
|
||||
def get_ursula_info(ursula_address) -> Porter.UrsulaInfo:
|
||||
|
|
Loading…
Reference in New Issue