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?