-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
326c848
commit 1962ddd
Showing
15 changed files
with
1,008 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "solana-runtime-plugin" | ||
version = "1.18.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
crossbeam-channel = { workspace = true } | ||
json5 = { workspace = true } | ||
jsonrpc-core = { workspace = true } | ||
jsonrpc-core-client = { workspace = true, features = ["ipc"] } | ||
jsonrpc-derive = { workspace = true } | ||
jsonrpc-ipc-server = { workspace = true } | ||
jsonrpc-server-utils = { workspace = true } | ||
libloading = { workspace = true } | ||
log = { workspace = true } | ||
solana-runtime = { workspace = true } | ||
solana-sdk = { workspace = true } | ||
thiserror = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pub mod runtime_plugin; | ||
pub mod runtime_plugin_admin_rpc_service; | ||
pub mod runtime_plugin_manager; | ||
pub mod runtime_plugin_service; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use { | ||
solana_runtime::{bank_forks::BankForks, commitment::BlockCommitmentCache}, | ||
std::{ | ||
any::Any, | ||
error, | ||
fmt::Debug, | ||
io, | ||
sync::{atomic::AtomicBool, Arc, RwLock}, | ||
}, | ||
thiserror::Error, | ||
}; | ||
|
||
pub type Result<T> = std::result::Result<T, RuntimePluginError>; | ||
|
||
/// Errors returned by plugin calls | ||
#[derive(Error, Debug)] | ||
pub enum RuntimePluginError { | ||
/// Error opening the configuration file; for example, when the file | ||
/// is not found or when the validator process has no permission to read it. | ||
#[error("Error opening config file. Error detail: ({0}).")] | ||
ConfigFileOpenError(#[from] io::Error), | ||
|
||
/// Any custom error defined by the plugin. | ||
#[error("Plugin-defined custom error. Error message: ({0})")] | ||
Custom(Box<dyn error::Error + Send + Sync>), | ||
|
||
#[error("Failed to load a runtime plugin")] | ||
FailedToLoadPlugin(#[from] Box<dyn std::error::Error>), | ||
} | ||
|
||
pub struct PluginDependencies { | ||
pub bank_forks: Arc<RwLock<BankForks>>, | ||
pub block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>, | ||
pub exit: Arc<AtomicBool>, | ||
} | ||
|
||
pub trait RuntimePlugin: Any + Debug + Send + Sync { | ||
fn name(&self) -> &'static str; | ||
fn on_load(&mut self, config_file: &str, dependencies: PluginDependencies) -> Result<()>; | ||
fn on_unload(&mut self); | ||
} |
Oops, something went wrong.