是否有確定性的方式來獲取交易功能中的時間戳,類似於可用於Fabric版鏈式代碼的Go版中的stub.GetTxTimestamp()。在Hyperledger Composer交易中以確定性方式獲取時間戳
2
A
回答
1
公正地分享與basic-sample-network
網絡工作的例子:
在模型文件(lib/org.acme.sample.cto
)我延長SampleAsset
定義的任何添加稱爲DateTime
類型的timestamp
新的屬性:
asset SampleAsset identified by assetId {
o String assetId
--> SampleParticipant owner
o String value
o DateTime timestamp
}
在腳本文件(lib/logic.js
),onSampleTransaction
函數用當前事務的時間戳更新SampleAsset的timestamp
:
function onSampleTransaction(sampleTransaction) {
sampleTransaction.asset.value = sampleTransaction.newValue;
sampleTransaction.asset.timestamp = sampleTransaction.timestamp;
return getAssetRegistry('org.acme.sample.SampleAsset')
.then(function (assetRegistry) {
return assetRegistry.update(sampleTransaction.asset);
});
}
1
所有交易都有一個名爲timestamp
的系統屬性,因此您可以使用myTransaction.timestamp
。
0
我們不能從供應商文件夾使用proto ...
相關問題
- 1. 在hyperledger composer中查詢交易
- 2. Hyperledger Fabric/Hyperledger Composer
- 3. 獲取SCOPE_IDENTITY中間交易
- 4. Hyperledger交易類型:創建交易
- 5. '最便宜的'在Linux(C++)中獲取時間戳的方式
- 6. 獲取Unix時間戳(以秒爲單位)進行hg提交
- 7. 在Python中易於使用時間戳
- 8. 如何在Hyperledger Composer中查詢或獲取其他鏈式代碼數據?
- 9. 以編程方式添加時間戳
- 10. 獲取UTC格式的GWT時間戳
- 11. 確定時間戳數據
- 12. 交易完成不確定性
- 13. 在php中獲取時間戳
- 14. 在Lua中獲取UTC UNIX時間戳
- 15. Talend處理交易的正確方式
- 16. Elasticsearch正確的方式來指定時間戳
- 17. shopify交易API獲取所有交易
- 18. 獲取UNIX時間戳的正確時間
- 19. 獲取未來時間戳
- 20. Cumulocity API獲取時間戳
- 21. 獲取時間戳在特定月份的時間戳數組的元素
- 22. 在Hyperledger Composer中查詢資產
- 23. 在Hyperledger Composer中調用外部服務
- 24. 從MySQL時間戳獲取時間並以小時,分鐘等形式顯示?
- 25. 從時間戳獲取本地時間
- 26. Laravel:在diffForHumans格式(Carbon)中獲取兩個時間戳之間的時間
- 27. 在Java中,從時間戳中獲取一天的最佳方式
- 28. 如何在社交引擎上獲取發佈時間戳
- 29. 如何獲取負時間戳以保存在firebase中 - Javascript
- 30. 以編程方式處理「交易」
非常感謝響應,丹!以下是適用於基本樣本網絡的示例(假設資產「SampleAsset」具有名爲「timestamp」的屬性,我們要使用以下事務「SampleTransaction」更新):function onSampleTransaction(sampleTransaction){sample}。 asset.value = sampleTransaction.newValue; \t sampleTransaction.asset.timestamp = sampleTransaction.timestamp; (函數(assetRegistry){ return assetRegistry.update(sampleTransaction.asset); });返回getAssetRegistry('org.acme.sample.SampleAsset') 。 }' –
https://github.com/hyperledger-archives/fabric/issues/1832我們不能使用供應商文件夾中的proto ... –