(ctx contractapi.TransactionContextInterface, counterKey string)
| 364 | } |
| 365 | |
| 366 | func nextID(ctx contractapi.TransactionContextInterface, counterKey string) (int, error) { |
| 367 | id, err := currentID(ctx, counterKey) |
| 368 | if err != nil { |
| 369 | return 0, err |
| 370 | } |
| 371 | if err := ctx.GetStub().PutState(counterKey, []byte(strconv.Itoa(id+1))); err != nil { |
| 372 | return 0, fmt.Errorf("failed to update counter %s: %w", counterKey, err) |
| 373 | } |
| 374 | return id, nil |
| 375 | } |
| 376 | |
| 377 | func currentID(ctx contractapi.TransactionContextInterface, counterKey string) (int, error) { |
| 378 | data, err := ctx.GetStub().GetState(counterKey) |
no test coverage detected