FederatedSidechains icon indicating copy to clipboard operation
FederatedSidechains copied to clipboard

API methods to get height closest to timestamp

Open noescape00 opened this issue 6 years ago • 4 comments

Added API methods to controller and client to request block height that is closed to given timestamp.

This is later will be needed to initialize NextMatureDepositHeight in CrossChainTransferStore so the store syncs not from the 1st block but from a block generated at the same time when genesis block of current chain was created.

It is not possible to do it now because CrossChainTransferStore requires refactoring in order to allow initialization that requires API call to another node.

related to https://github.com/stratisproject/FederatedSidechains/issues/268

noescape00 avatar Dec 20 '18 15:12 noescape00

There is already an extension method that calculates the height of the block at a certain time: this.chain.GetHeightAtTime(date);

Also, can this not just be a constant value on the federation gateway mainchain?

bokobza avatar Dec 20 '18 15:12 bokobza

Also, can this not just be a constant value on the federation gateway mainchain?

It can be. But it will make setup a bit more difficult because you will need to provide it in the arguments.

If we do it like that then we don't need this PR and API calls at all, just initialize height at that value and that's it.

But imho it's not user friendly. Right now it's not trivial to configure fed gateway already.

noescape00 avatar Dec 20 '18 15:12 noescape00

yeah but here it's such a lot of work to retrieve a value we already know.

bokobza avatar Dec 20 '18 15:12 bokobza

yeah but here it's such a lot of work to retrieve a value we already know.

Your decision. A lot of work for us or a bit of work during setting it up.

I don't mind either way.

If you prefer to have it in the setup config then close this PR and I'll do it that way.

ps I'd keep changes in the rest client- there are methods for get requests. Rest of the PR is up to you.

noescape00 avatar Dec 20 '18 15:12 noescape00