check plugin name on plugin_reload rpc call (#33582)

* check plugin name on plugin_reload rpc call

* add name to error message
This commit is contained in:
Kirill Fomichev 2023-11-02 01:21:53 +06:00 committed by GitHub
parent 25a29c9b7f
commit 808f67aead
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -177,6 +177,22 @@ impl GeyserPluginManager {
data: None,
})?;
// Then see if a plugin with this name already exists. If so, abort
if self
.plugins
.iter()
.any(|plugin| plugin.name().eq(new_plugin.name()))
{
return Err(jsonrpc_core::Error {
code: ErrorCode::InvalidRequest,
message: format!(
"There already exists a plugin named {} loaded, while reloading {name}. Did not load requested plugin",
new_plugin.name()
),
data: None,
});
}
// Attempt to on_load with new plugin
match new_plugin.on_load(new_parsed_config_file) {
// On success, push plugin and library