Skip to content

Commit

Permalink
Merge pull request #49 from spolu/stan-cancel
Browse files Browse the repository at this point in the history
Fixes and TOOD re-reading the cancellation code
  • Loading branch information
Stanislas Polu committed Jul 31, 2017
2 parents 0bf02fe + 8712ffc commit 2b54f7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions TODO
@@ -1,5 +1,6 @@
# mint

[ ] allow cancellation from hop 0 by attempted propagation to last node
[ ] transaction reference and metadata
[ ] async webhooks
[ ] asset.created
Expand Down
14 changes: 7 additions & 7 deletions mint/endpoint/cancel_transaction.go
Expand Up @@ -194,8 +194,8 @@ func (e *CancelTransaction) ExecuteAuthenticated(

// We mark the transaction as cancelled if the hop of this is the minimal
// one for this mint. Cancelation checks only use operations and crossings
// anre the status of a transaction is mostly indicative, but we want to
// mark it as cancelled only after it is cancelled at all hops.
// so the status of a transaction is mostly indicative, but we want to mark
// it as cancelled only after it is cancelled at all hops.
if e.Hop == *minHop {
e.Tx.Status = mint.TxStCanceled
err = e.Tx.Save(ctx)
Expand Down Expand Up @@ -272,7 +272,7 @@ func (e *CancelTransaction) ExecutePropagated(
pl, err := plan.Compute(ctx, e.Client, e.Tx, false)
if err != nil {
return nil, nil, errors.Trace(errors.NewUserErrorf(err,
402, "settlement_failed",
402, "cancellation_failed",
"The plan computation for the transaction failed: %s", e.ID,
))
}
Expand All @@ -289,7 +289,7 @@ func (e *CancelTransaction) ExecutePropagated(
if int(e.Hop) >= len(e.Plan.Hops) ||
e.Plan.Hops[e.Hop].Mint != mint.GetHost(ctx) {
return nil, nil, errors.Trace(errors.NewUserErrorf(nil,
402, "settlement_failed",
402, "cancellation_failed",
"The hop provided (%d) does not match the current mint (%s) for "+
"transaction: %s", e.Hop, mint.GetHost(ctx), e.ID,
))
Expand Down Expand Up @@ -319,8 +319,8 @@ func (e *CancelTransaction) ExecutePropagated(

// We mark the transaction as cancelled if the hop of this is the minimal
// one for this mint. Cancelation checks only use operations and crossings
// anre the status of a transaction is mostly indicative, but we want to
// mark it as cancelled only after it is cancelled at all hops.
// so the status of a transaction is mostly indicative, but we want to mark
// it as cancelled only after it is cancelled at all hops.
if e.Hop == *minHop {
e.Tx.Status = mint.TxStCanceled
err = e.Tx.Save(ctx)
Expand All @@ -339,7 +339,7 @@ func (e *CancelTransaction) ExecutePropagated(
return nil, nil, errors.Trace(err) // 500
}

// Commit the transaction as well as operations and crossings as settled.
// Commit the transaction as well as operations and crossings as canceled..
db.Commit(ctx)

err = e.Propagate(ctx)
Expand Down

0 comments on commit 2b54f7a

Please sign in to comment.