FederatedSidechains
FederatedSidechains copied to clipboard
API methods to get height closest to timestamp
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
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?
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.
yeah but here it's such a lot of work to retrieve a value we already know.
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.