mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 07:25:10 +00:00
Fix ledger queries chaincode-go InitLedger (#293)
The InitLedger was not writing the composite key for the color index. Therefore TransferAssetByColor was not working. Now InitLedger will call CreateAsset which creates both the asset and the color index entry. Signed-off-by: David Enyeart <enyeart@us.ibm.com>
This commit is contained in:
parent
155a3e7e26
commit
8e2535ee65
1 changed files with 1 additions and 6 deletions
|
|
@ -436,15 +436,10 @@ func (t *SimpleChaincode) InitLedger(ctx contractapi.TransactionContextInterface
|
|||
}
|
||||
|
||||
for _, asset := range assets {
|
||||
assetBytes, err := json.Marshal(asset)
|
||||
err := t.CreateAsset(ctx, asset.ID, asset.Color, asset.Size, asset.Owner, asset.AppraisedValue)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = ctx.GetStub().PutState(asset.ID, assetBytes)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to put to world state. %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue