Bound crypto protocol regeneration
This commit is contained in:
parent
aac83cb345
commit
11a4c9c6f1
1 changed files with 6 additions and 3 deletions
|
|
@ -188,19 +188,22 @@ class CryptoVentureService:
|
||||||
def regenerate_rejected_slots(self, cohort: VentureCohort, *, reason: str = "novelty_or_token_gate") -> list[CompanyProposal]:
|
def regenerate_rejected_slots(self, cohort: VentureCohort, *, reason: str = "novelty_or_token_gate") -> list[CompanyProposal]:
|
||||||
created = []
|
created = []
|
||||||
attempts = 0
|
attempts = 0
|
||||||
max_attempts = cohort.cohort_size * 3
|
max_attempts = min(6, max(2, (cohort.cohort_size - cohort.members.count()) * 2))
|
||||||
while cohort.members.count() < cohort.cohort_size and attempts < max_attempts:
|
while cohort.members.count() < cohort.cohort_size and attempts < max_attempts:
|
||||||
attempts += 1
|
attempts += 1
|
||||||
index = cohort.members.count() + attempts
|
index = cohort.members.count() + attempts
|
||||||
territory = CRYPTO_TERRITORIES[index % len(CRYPTO_TERRITORIES)]
|
territory = CRYPTO_TERRITORIES[index % len(CRYPTO_TERRITORIES)]
|
||||||
payload, source = self._protocol_payload(index, territory)
|
if attempts <= 2:
|
||||||
|
payload, source = self._protocol_payload(index, territory)
|
||||||
|
else:
|
||||||
|
payload, source = self._fallback_payload(index, territory), "deterministic_crypto_repair"
|
||||||
proposal = self._create_proposal(cohort.mandate, payload, source, territory)
|
proposal = self._create_proposal(cohort.mandate, payload, source, territory)
|
||||||
VentureCohortMember.objects.create(cohort=cohort, proposal=proposal, metadata={"territory": territory, "regenerated_for": reason})
|
VentureCohortMember.objects.create(cohort=cohort, proposal=proposal, metadata={"territory": territory, "regenerated_for": reason})
|
||||||
created.append(proposal)
|
created.append(proposal)
|
||||||
self.assess_token_necessity(proposal)
|
self.assess_token_necessity(proposal)
|
||||||
self.novelty_gate(cohort)
|
self.novelty_gate(cohort)
|
||||||
self._remove_weak_token_members(cohort)
|
self._remove_weak_token_members(cohort)
|
||||||
cohort.metrics = {**cohort.metrics, "regeneration_attempts": cohort.metrics.get("regeneration_attempts", 0) + attempts, "regenerated_protocols": cohort.metrics.get("regenerated_protocols", 0) + len(created), "accepted_protocols": cohort.members.count()}
|
cohort.metrics = {**cohort.metrics, "regeneration_attempts": cohort.metrics.get("regeneration_attempts", 0) + attempts, "regenerated_protocols": cohort.metrics.get("regenerated_protocols", 0) + len(created), "accepted_protocols": cohort.members.count(), "unfilled_slots_after_regeneration": max(0, cohort.cohort_size - cohort.members.count())}
|
||||||
cohort.save(update_fields=["metrics", "updated_at"])
|
cohort.save(update_fields=["metrics", "updated_at"])
|
||||||
return created
|
return created
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue