Spark-563 return an error if user requests to create a security which already exists.
This commit is contained in:
1 parent
06aed6e411
commit
705bf5b167
2 files changed
+11
-4
No files matched your search
@@ -15,6 +15,7 @@ message CreateResult {
|
||||
ERROR_BAD_VENUE = 3;
|
||||
ERROR_BAD_NAME = 4;
|
||||
ERROR_BAD_SYMBOL = 5;
|
||||
ERROR_SECURITY_ALREADY_EXISTS = 6;
|
||||
}
|
||||
uint32 key = 1;
|
||||
Error error = 2;
|
||||
|
||||
@@ -117,10 +117,16 @@ void SyntheticSecurityService::create_synthetic(
|
||||
// Assign security key
|
||||
_me->recorder.assign_key(security, [this, reply](const api::Security& security) {
|
||||
// Notify listeners that a new security is added
|
||||
_me->synthetics.insert(std::make_pair(security.id(), security));
|
||||
_me->on_security.publish(security);
|
||||
// signal success
|
||||
send_reply(reply, CreateResult::ERROR_OK, security.id());
|
||||
auto iter = _me->synthetics.find(SecurityKey(security.id()));
|
||||
if (iter != _me->synthetics.end()) {
|
||||
send_reply(reply, CreateResult::ERROR_SECURITY_ALREADY_EXISTS, security.id());
|
||||
}
|
||||
else {
|
||||
_me->synthetics.insert(std::make_pair(security.id(), security));
|
||||
_me->on_security.publish(security);
|
||||
// signal success
|
||||
send_reply(reply, CreateResult::ERROR_OK, security.id());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user