Reconcile byte-identical historical offers without allowing another execution
This commit is contained in:
@@ -24,7 +24,6 @@ pub fn accept(
|
||||
&& hex_hash(&offer.plan_hash),
|
||||
"OFFER_BINDING"
|
||||
);
|
||||
ensure!(supported(&job), "UNSUPPORTED_CAPABILITY");
|
||||
let bytes = offer.encode_to_vec();
|
||||
let existing: Option<Vec<u8>> = db
|
||||
.query_row(
|
||||
@@ -37,6 +36,9 @@ pub fn accept(
|
||||
ensure!(old == bytes, "OFFER_CONFLICT");
|
||||
return Ok(false);
|
||||
}
|
||||
// An identical journal receipt is evidence of a previous delivery. Current
|
||||
// executable capabilities apply to newly accepted offers.
|
||||
ensure!(supported(&job), "UNSUPPORTED_CAPABILITY");
|
||||
let count: i64 = db.query_row("SELECT count(*) FROM job_attempts", [], |r| r.get(0))?;
|
||||
ensure!(count < 10000, "JOURNAL_CAPACITY_NEW_EFFECTS_BLOCKED");
|
||||
db.execute(
|
||||
|
||||
Reference in New Issue
Block a user