Ledger API Nodejs SDK : getTime() not implemented
See original GitHub issueLedger API Node JS sdk version : 0.8.3 NodeJS Version : 10.19.8
Issue: Code fails when trying to access ledger time using NodeJS SDK. Ledger is running in wallclock mode.
Example Code
const ledger = require('@digitalasset/daml-ledger');
getTime = () => {
ledger.DamlLedgerClient.connect({ host: 'localhost', port: 8080 }, (err, client) => {
let ledgerTime = client.timeClient.getTime()
ledgerTime.on('data', response => {
console.log(response)
})
});
}
getTime();
Exception
events.js:174
throw er; // Unhandled 'error' event
^
Error: 12 UNIMPLEMENTED: Method not found: com.digitalasset
.ledger.api.v1.testing.TimeService/GetTime
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Working with apis that return iterators - Hyperledger
These api's are a request to return a set of data for which you need to iterate over using the provided iterator. Some...
Read more >LedgerHQ/ledgerjs: ⛔️ MOVED to monorepo "ledger-live"
To communicate with a Ledger device, you first need to identify which transport(s) to use. The hw-transport libraries implement communication protocol for our ......
Read more >Release notes — DAML SDK 1.4.0 documentation
This involves changes in the Ledger API in corner cases, but unless you are dealing with application failover, you are unlikely to be...
Read more >Date.prototype.getTime() - JavaScript - MDN Web Docs - Mozilla
The getTime() method returns the number of milliseconds since the epoch, which is defined as the midnight at the beginning of January 1,...
Read more >Buy and sell bitcoin, it's that simple. - API - Bitso
Documentation inconsistency between REST Api service and implementation was fixed: in user_trades service documentation, now 'book' is not required.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ashfaq-shaik , I think you are spot on in saying that the Ledger should give a single useful notion of time. As @SamirTalwar-DA is saying, it’s actually far from trivial to do so, though, which is why having a sound notion of LedgerTime is pretty unique to DAML - I’m not aware any other DLT has something comparable.
It being difficult, there are trade-offs. System clocks on different components of the distributed network will diverge and have skews, there will be network latencies, and processing large batch transactions will take time. Time being a distributed concern also means that it is not as observable as one may think. DAML’s value prop is that applications that run on the Sandbox run on highly distributed networks, too, so we consciously don’t expose more via the API than we can offer in the most general case. Every transaction can be assigned a time stamp that makes sense, but there is no clock you can poll via a service to find out the current ledger time precisely.
The DAML Time model is pretty simple at the core:
The skew parameters give you the degree of “fuzziness” in Ledger time. I believe in the sandbox they are 1s, but I’d need to double check. That means you can backdate your transaction by up to one second, but only if it doesn’t have any contracts created within the last second as input. The bigger the skew parameters, the fuzzier Ledger Time becomes, but the smaller the skew parameters are, the harder it becomes to set LETs that satisfy the constraints. So setting those skew parameters is a trade-off in practice.
That means Ledger Time for Sandbox ledgers is Sandbox host system time ± 1s. There is no service to poll this as that service would be nearly impossible for more distributed ledgers. The JSON API assumes that Ledger time is it’s own system time right now, which means it’s best run on the same machine as the Sandbox. It should then work seamlessly without adjustment.
There are some cases currently where running components on different machines with clock skews can lead to bouncing transactions. We are therefore working on moving the determination of ledger time (LET) even closer to the ledger, which should make it work seamlessly in almost all cases. However, it still won’t be queryable, but only observable by previous transactions and based on the assumption that system clocks are reasonably in sync.
My general recommendation, which should work in the most general case, would be to
Thanks for the explanation @bame-da . This helps.