MCPcopy Index your code
hub / github.com/yeasy/blockchain_guide / currentID

Function currentID

11_app_dev/chaincode_example05.go:278–287  ·  view source on GitHub ↗
(ctx contractapi.TransactionContextInterface, counterKey string)

Source from the content-addressed store, hash-verified

276}
277
278func currentID(ctx contractapi.TransactionContextInterface, counterKey string) (int, error) {
279 data, err := ctx.GetStub().GetState(counterKey)
280 if err != nil {
281 return 0, fmt.Errorf("failed to read counter %s: %w", counterKey, err)
282 }
283 if data == nil {
284 return 0, nil
285 }
286 return strconv.Atoi(string(data))
287}
288
289func readJSON(ctx contractapi.TransactionContextInterface, key string, target interface{}) error {
290 data, err := ctx.GetStub().GetState(key)

Callers 3

GetHomesMethod · 0.70
GetTransactionsMethod · 0.70
nextIDFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected