Fixes last open invite bucket distribution
This commit is contained in:
parent
906577f6a8
commit
420d3be4bd
|
@ -156,6 +156,7 @@ pub struct BridgeDb {
|
|||
pub pubkey: VerifyingKey,
|
||||
/// The set of open-invitation buckets
|
||||
openinv_buckets: HashSet<u32>,
|
||||
/// The set of open invitation buckets that have been distributed
|
||||
distributed_buckets: Vec<u32>,
|
||||
#[serde(skip)]
|
||||
today: DateTime<Utc>,
|
||||
|
@ -229,14 +230,14 @@ impl BridgeDb {
|
|||
self.today = Utc::now();
|
||||
self.daily_bridges_distributed = 0;
|
||||
}
|
||||
if self.openinv_buckets.is_empty() {
|
||||
return Err(OpenInvitationError::NoBridgesAvailable);
|
||||
}
|
||||
if self.daily_bridges_distributed < MAX_DAILY_BRIDGES {
|
||||
if self.current_k < OPENINV_K && !self.distributed_buckets.is_empty() {
|
||||
bucket_num = *self.distributed_buckets.last().unwrap();
|
||||
self.current_k += 1;
|
||||
} else {
|
||||
if self.openinv_buckets.is_empty() {
|
||||
return Err(OpenInvitationError::NoBridgesAvailable);
|
||||
}
|
||||
// Choose a random bucket number (from the set of open
|
||||
// invitation buckets) and serialize it
|
||||
let openinv_vec: Vec<&u32> = self.openinv_buckets.iter().collect();
|
||||
|
|
Loading…
Reference in New Issue