Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Add multi_index::require_find #4227

Closed
arhag opened this issue Jun 19, 2018 · 0 comments
Closed

Add multi_index::require_find #4227

arhag opened this issue Jun 19, 2018 · 0 comments
Assignees
Labels
dev experience enhancement WASM Bugs that can be fixed by updating WASM code and do not require a hard fork
Milestone

Comments

@arhag
Copy link
Contributor

arhag commented Jun 19, 2018

Since multi_index::get can easily be misused as documented in issue #4226, contract developers should have an alternative that is safer.

That alternative already exists. They can use multi_index::find to get a const_iterator and then pass that const_iterator into modify or erase.

But a common pattern is to check that the iterator actually points to a real object (meaning the table row was found) and throw an assertion error otherwise. In fact, get makes this very convenient by taking an optional string argument with the assertion message to throw if the table row cannot be found.

multi_index::require_find would behave similarly to get in the sense that it asserts that the requested table row was actually found and uses the optionally provided message string as the assertion failure message. However, it would return the safe const_iterator just like find does.

@arhag arhag added enhancement dev experience WASM Bugs that can be fixed by updating WASM code and do not require a hard fork labels Jun 19, 2018
@arhag arhag added this to the Version 1.1 milestone Jun 19, 2018
wanderingbort pushed a commit that referenced this issue Jul 10, 2018
Add require_find method to multi_index - Issue #4227
@zorba80 zorba80 closed this as completed Jul 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dev experience enhancement WASM Bugs that can be fixed by updating WASM code and do not require a hard fork
Projects
None yet
Development

No branches or pull requests

2 participants