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

erase old version abi before insert new version abi when set abi #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/abieos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ extern "C" abieos_bool abieos_set_abi(abieos_context* context, uint64_t contract
return set_error(context, std::move(error));
abieos::abi c;
convert(def, c);
context->contracts.insert({name{contract}, std::move(c)});
const name key {contract};
context->contracts.erase(key);
context->contracts.insert({key, std::move(c)});
gzliudan marked this conversation as resolved.
Show resolved Hide resolved
return true;
});
}
Expand All @@ -132,7 +134,9 @@ extern "C" abieos_bool abieos_set_abi_bin(abieos_context* context, uint64_t cont
from_bin(def, stream);
abieos::abi c;
convert(def, c);
context->contracts.insert({name{contract}, std::move(c)});
const name key {contract};
context->contracts.erase(key);
context->contracts.insert({key, std::move(c)});
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be able to use: context->contracts.insert_or_assign(name{contract}, std::move(c));

Copy link
Author

Choose a reason for hiding this comment

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

Yes, insert_or_assign is better.

return true;
});
}
Expand Down