Composite Key functions in Hyperledger

前端 未结 3 1681
梦如初夏
梦如初夏 2021-01-15 01:02

I need to implement composite keys in hyperledger so that I could have a unique key based on the attributes put into the ledger. The function CreateCompositeKey(object

3条回答
  •  难免孤独
    2021-01-15 01:53

    For Java implementation it did not clearly come out in the documentation/ examples, did a little digging around and you can use 'compositeKey.toString()' as the composite key.

    Example below:

    final String compositeKey = stub.createCompositeKey("my-key-part-1", "my-key-part-2").toString();
    stub.putStringState(compositeKey, myJSONString); // use this
    stub.putState(compositeKey, myJSONString.getBytes()); // or this
    

提交回复
热议问题