-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Native: store ID->hash map in ContractManagement, add iterator #2807
Conversation
That probably is the lighest design possible, store and retrieve hashes only. But it can be expanded to return full contract state (getContractByID, for example) and probably even iterate over contract states. Fixes neo-project#2803.
4d0f0e6
to
743b8fa
Compare
/// <param name="id">Contract ID.</param> | ||
/// <returns>The deployed contract.</returns> | ||
[ContractMethod(CpuFee = 1 << 15, RequiredCallFlags = CallFlags.ReadStates)] | ||
public ContractState GetContractById(DataCache snapshot, int id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public ContractState GetContractById(DataCache snapshot, int id) | |
public ContractState GetContractById(DataCache snapshot, uint id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems this is only for non-native contracts, uint
is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's GetContractHashes
that is specifically for non-natives, but this one can return native contracts as well, it doesn't hurt. Otherwise we'll have to check for int overflows anyway.
Co-authored-by: Shargon <[email protected]>
Tested OK. Good to Merge. |
Follow neo-project/neo#2807. Notice that this data is not cached, our previous implementation wasn't too and it shouldn't be a problem (not on the hot path).
Follow neo-project/neo#2807. Notice that this data is not cached, our previous implementation wasn't too and it shouldn't be a problem (not on the hot path).
Follow neo-project/neo#2807. Notice that this data is not cached, our previous implementation wasn't too and it shouldn't be a problem (not on the hot path).
Follow neo-project/neo#2807. Notice that this data is not cached, our previous implementation wasn't too and it shouldn't be a problem (not on the hot path).
This is an omission of neo-project#2807, even though native hashes are well-known GetContractById better be symmetric for all contracts. Related to nspcc-dev/neo-go#2837.
This is an omission of neo-project#2807, even though native hashes are well-known GetContractById better be symmetric for all contracts. Related to nspcc-dev/neo-go#2837.
This is an omission of #2807, even though native hashes are well-known GetContractById better be symmetric for all contracts. Related to nspcc-dev/neo-go#2837. Co-authored-by: Shargon <[email protected]>
That probably is the lighest design possible, store and retrieve hashes
only. But it can be expanded to return full contract state (getContractByID,
for example) and probably even iterate over contract states.
Fixes #2803. Not tested.