What is the use case of fields?


gqqnb2005 <gqqnb2005@...>
 

As a contract in Hyperledger Fabric is a class with an annotation, how
should we use the class fields?

@Contract
public final class AssetTransfer implements ContractInterface {
private Asset currentAsset;

@Transaction
public void setAsset(final Context ctx, final String assetID) {
currentAsset = loadAsset(assetId);
}
}

In this code snippet, contract AssetTransfer has a method setAsset
that changes its field currentAsset.

From my experiments, if I have peer1 and peer2 running the contract,
and peer2 somehow goes offline, the value of currentAsset in peer2 is
lost.

As a chaincode developer, should I avoid using fields? Are there any
documentations or code patterns on contract fields?

Join {fabric@lists.hyperledger.org to automatically receive all group messages.