Spend a hashcash stamp only when the request succeeds (closes #158)
check / check (push) Waiting to run
check / check (push) Waiting to run
A session request refused with 400 or 409, or a +H channel message refused for membership, a ban or +m, used to spend its stamp, so a retry with the same stamp was refused as already used. hashcash.Validator.Validate is split into Check, which spends nothing, and Claim, which records the stamp; Release undoes a claim. Session creation checks the stamp first, claims it just before CreateSession and releases it if CreateSession fails. SendChannelMessage checks the stamp after the membership, ban and +m checks. Model: opus-5-5
This commit is contained in:
@@ -207,7 +207,7 @@ func TestCreateSessionSendsNickAndStamp(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = validator.Validate(payload.Hashcash, stampBits)
|
||||
err = validator.Claim(payload.Hashcash, stampBits)
|
||||
if err != nil {
|
||||
writer.WriteHeader(http.StatusPaymentRequired)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user