Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Neo.Runtime.GetTime and Neo.Runtime.GetCurrentBlock #122

Closed
wants to merge 5 commits into from

Conversation

localhuman
Copy link
Contributor

for issue #114

  • adds Neo.Runtime.GetTime
  • adds Neo.Runtime.GetCurrentBlock
  • adds property CurrentBlock to Blockchain. This retrieves the currently persisting block if a block is currently being persisted, otherwise it returns the highest block

If either of these API are called during TriggerType.Verification, the most recent blockchain on the block is returned. If it is called during TriggerType.Application, it will be the currently persisting block.

{
return persisting_block;
}
return GetBlock(Height);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in the else was good option set persisting_block=GetBlock (Height)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want persisting_block to be null unless execution is in the middle of LeveldbBlockchain.Persist

@erikzhang
Copy link
Member

I'm not going to accept Neo.Runtime.GetCurrentBlock because we're going to implement a pre-execution mechanism for applications.
In a pre-execution, the hash field and next_consensus field of the persisting_block are not determined. If we want to ensure that the result of the pre-execution is consistent with the result of normal execution, we can't provide an API for getting persisting_block.

@localhuman
Copy link
Contributor Author

Will remove GetCurrentBlock.
for GetTime, the issue says to get the current block and add 15s. Do we want to add that, given that the time may not be exact?

@erikzhang
Copy link
Member

For GetTime:

  1. If it's running under Application trigger, return the timestamp of the persisting_block.
  2. If it's running under Verification trigger, return the timestamp of latest block and add Blockchain.SecondsPerBlock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants