Skip to content
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)});
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