MCPcopy
hub / github.com/yeasy/blockchain_guide / readHomeByID

Function readHomeByID

11_app_dev/chaincode_example05.go:217–226  ·  view source on GitHub ↗
(ctx contractapi.TransactionContextInterface, id int)

Source from the content-addressed store, hash-verified

215}
216
217func readHomeByID(ctx contractapi.TransactionContextInterface, id int) (*Home, error) {
218 addressBytes, err := ctx.GetStub().GetState(homeIDKey(id))
219 if err != nil {
220 return nil, fmt.Errorf("failed to read home id %d: %w", id, err)
221 }
222 if addressBytes == nil {
223 return nil, fmt.Errorf("home id %d does not exist", id)
224 }
225 return readHome(ctx, string(addressBytes))
226}
227
228func validSignature(address string, signature string) bool {
229 return signature == address+"1"

Callers 1

GetHomesMethod · 0.85

Calls 2

homeIDKeyFunction · 0.85
readHomeFunction · 0.85

Tested by

no test coverage detected