Comments (12)
@evias what do you think? should this fall upon REST's hands? or SDK?
it is true that it'd be comfortable but the timestamp belongs to the block, when you fetch transactions from REST i believe you usually do it via block height, so i think it makes sense to keep it as it is
additionally, i'm unsure how "correct" it is to assign a timestamp to a transaction, i believe a transaction does not have a timestamp, it would still be the block's timestamp, wouldn't it?
from catapult-rest.
When using the method getAccountTransactionsById
, to list an account's transactions, the transactions are fetched from the account/publicKey endpoint.
The pagination parameter is the transaction Id
I understand the point of view of a transaction not having a timestamp as it belongs to a block.
However, on a front end development standpoint, a timestamp giving an indication of when a transaction has been included in a block is definitely needed.
Taking Etherescan's API as a reference (I am using it extensively), a timeStamp is provided in all the transactions or smart contract events objects.
Reference: https://etherscan.io/apis#accounts
from catapult-rest.
I still believe the timestamp does not strictly belong to a transaction, at the same time I see how it is obviously useful, but I think maybe there should be a more user-educative way to show the timestamp, via frontend (such as show block id, with block's timestamp next to it, not sure).
If this is true, even if timestamp was returned with the transaction, it should be returned under the field blockTimestamp
or similar - but again, I'm not sure if this strafes away from a RESTful server, where if you want a block property, you need to request the block data, though again: i understand that this would be comfortable ^^
Either way I'm not as fond on blockchain background as others in this matter, so maybe @Jaguar0625 or @dgarcia360 can give more input, I prefer to hear their side on this because I trust better their judgement on such decisions.
from catapult-rest.
I would actually agree that this is probably best fixed in SDK side as we probably don't want REST to "hide a request to get the block timestamp" ... and also I agree with @Vektrat that we shouldnt be speaking in Timestamp here but probably in block height.
Same as we did getEffectiveFee
- there can also be getConfirmationTimestamp
or something similar.
That will make it easy for you @decentraliser as you will be querying the timestamp easily, and in case we see that this is not enough we can still ask REST to implement it with some cache at some point.
from catapult-rest.
This is not a problem of difficulty for me, it is a problem of performance. I just adapted the code of the browser extension and it becomes significantly slower.
If you judge this need is a common use case, I think it would be worth to run some tests.
My understanding is that if it is done at the SDK level, it will not solve this performance issue, except if the piece of code I have written can be significantly optimized.
`
accountHttp
.transactions(publicAccount, new QueryParams(pageSize, currentId))
.pipe(
flatMap(x => x),
concatMap(x => blockchainHttp
.getBlockByHeight(x.transactionInfo.height.compact()).toPromise(),
(x, res) => (
{
...x,
timestamp: res.timestamp.compact() / 1000 + timestampNemesisBlock,
})),
map(formatTransactions),
`
from catapult-rest.
would adding shareReplay()
help?
from catapult-rest.
afaik shareReplay is useful when several elements consume the exact same data.
Here the issue is that there is one distinct call / blockNumber / tx
it would help for users that have many queries in the same block though, I'll add it
from catapult-rest.
@decentraliser how about this:
- for a list of transaction, take the first transaction and
hA = transactionInfo.height.compact();
- then take the last transaction and
hB = transactionInfo.height.compact();
read hA
and hB
from network to get timestamps of both tA, tB
. From there you can take a difference of blocks diffH = hB - hA
as the total blocks generated in between all the transactions of your list. Then also take the difference in timestamps diffT = tB - tA
and divide it by the number of blocks blockTime = diffT / diffH
.
Now you have the actual block time and for each transaction that you iterate you add blockTime x counter
to tA
.
That is not optimal, but will be more performant for cases where txList.length > 2
as it will reduce the HTTP calls for block data.
Unsure if this can be applied for legal data as time is actually "calculated / averaged" .. Glad to hear feedback on this.
from catapult-rest.
Hi there. I think the transaction timestamp is useful to represent the lifetime of a signed transaction, regardless of the timestamp of the block.
I have planned to make subscription service (on nem1) and timestamp parameter on a signed TX helps me to make it.
The idea of the subscription service on NEM is below.
- A buyer make a new addresss, called address A, and send XEMs to it.
- The buyer signes a bunch of TXs with future timestamp, e.g. on the 1st of the month for a year, with the private key of the address A.
- The buyer sends TXs, as text data, to the provider of a service.
- The provider releases a TX to the network, e.g. on the first of every month, to get paid from address A.
Does it make sense? This idea needs the transaction timestamp to prevent the provider from stealing the deposit.
from catapult-rest.
@tinytinboy probably you could solve this with secret locks / hash locks if you store timestamping data with block listener active.
@decentralizer i am thinking a bit more about it and what happens if SDK adds something like 'getTimestampedTransactions()' to potentially also query more than one block at a time. This would optimize quite a lot, dont think its rest issue, mind create a task in sdk with: "Add TransactionHttp.getTimedTransactions()" or something like that
from catapult-rest.
@evias I just saw your comment, I think it would be nice!
would you do it with a block extrapolation as you suggested before, or call the block endpoint for each transaction?
from catapult-rest.
closing this since it was already discussed that adding a hard reference to a "timestamp" is not "possible" any other discussion on how to emulate this behaviour is not REST-specific and it's been a while since this was dropped ^^
from catapult-rest.
Related Issues (20)
- Refactor network currency supply endpoints
- Add limit long single mongo query can take to identify issues early
- Median fee multipler should not be 0
- Add native HTTPS support HOT 9
- Allow Integer filtering by block height HOT 2
- Suggest add new field on transaction record.
- Add API method for address translation between public key, base32 address, and hex address HOT 6
- Update reservedNamespacesNames to include the name Symbol
- please include block timestamp in receipt data returned by `statements/transaction`
- please include block timestamp and feeMultiplier in transaction returned by transactions/confirmed HOT 5
- transactions/confirmed embedded option does not seem to do anything HOT 6
- Only return address rather than alias.
- Revist eslint-config-airbnb lint rules
- Unlock zeromq version and fix the missing dependency issue in the node alpine image HOT 4
- Lock transaction endpoint timeout with ordering HOT 1
- Consider adding `0x` to unit64 fields
- Correction to circulatingSupply after Cyprus Hardfork HOT 1
- Replace yarn with npm
- Unable filter mosaic supply revocation tx type in transaction endpoint.
- Suggest add new field on node/storage endpoint.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from catapult-rest.