/**
* @param {org.example.mynetwork.TransactionCar} transactionCar
* @transaction
*/
async function transactionCarFun(transactionCar){
const factory = getFactory();
const NS = "org.example.mynetwork";
const registry = await getParticipantRegistry(NS + '.Person');
const assetRegistry = await getAssetRegistry(NS+".Car");
const from =await registry.get( transactionCar.from);
const to =await registry.get( transactionCar.to);
const price = transactionCar.price;
from.balance = from.balance + price;
to.balance = to.balance - price;
const partRegistry = await getParticipantRegistry(NS+'.Person')
await partRegistry.update(from);
await partRegistry.update(to);
debugger
const car =await assetRegistry.get(transactionCar.car);
car.personId = to.id;
if(!car.transactionCars){
car.transactionCars = []
}
car.transactionCars.push(transactionCar)
await assetRegistry.update(car);
}
xxxx
猜你喜欢
转载自my.oschina.net/u/3688108/blog/1802793
今日推荐
周排行