(ctx contractapi.TransactionContextInterface, counterKey string)
| 265 | } |
| 266 | |
| 267 | func nextID(ctx contractapi.TransactionContextInterface, counterKey string) (int, error) { |
| 268 | id, err := currentID(ctx, counterKey) |
| 269 | if err != nil { |
| 270 | return 0, err |
| 271 | } |
| 272 | if err := ctx.GetStub().PutState(counterKey, []byte(strconv.Itoa(id+1))); err != nil { |
| 273 | return 0, fmt.Errorf("failed to update counter %s: %w", counterKey, err) |
| 274 | } |
| 275 | return id, nil |
| 276 | } |
| 277 | |
| 278 | func currentID(ctx contractapi.TransactionContextInterface, counterKey string) (int, error) { |
| 279 | data, err := ctx.GetStub().GetState(counterKey) |
no test coverage detected