pub struct ConfigGenApi {
state: Arc<Mutex<ConfigGenState>>,
db: Database,
config_generated_tx: Sender<ServerConfig>,
task_group: TaskGroup,
code_version_str: String,
api_secret: Option<String>,
p2p_bind_addr: SocketAddr,
bitcoin_status_cache: Arc<RwLock<Option<(Instant, BitcoinRpcConnectionStatus)>>>,
bitcoin_status_cache_duration: Duration,
}
Expand description
Serves the config gen API endpoints
Fields§
§state: Arc<Mutex<ConfigGenState>>
In-memory state machine
db: Database
DB not really used
config_generated_tx: Sender<ServerConfig>
Tracks when the config is generated
task_group: TaskGroup
Task group for running DKG
code_version_str: String
Code version str that will get encoded in consensus hash
api_secret: Option<String>
Api secret to use
p2p_bind_addr: SocketAddr
§bitcoin_status_cache: Arc<RwLock<Option<(Instant, BitcoinRpcConnectionStatus)>>>
§bitcoin_status_cache_duration: Duration
Implementations§
Source§impl ConfigGenApi
impl ConfigGenApi
pub fn new( p2p_bind_addr: SocketAddr, settings: ConfigGenSettings, db: Database, config_generated_tx: Sender<ServerConfig>, task_group: &TaskGroup, code_version_str: String, api_secret: Option<String>, ) -> Self
pub async fn set_password(&self, auth: ApiAuth) -> ApiResult<()>
async fn require_status( &self, status: ServerStatus, ) -> ApiResult<MutexGuard<'_, ConfigGenState>>
async fn require_any_status( &self, statuses: &[ServerStatus], ) -> ApiResult<MutexGuard<'_, ConfigGenState>>
Sourcepub async fn set_config_gen_connections(
&self,
request: ConfigGenConnectionsRequest,
) -> ApiResult<()>
pub async fn set_config_gen_connections( &self, request: ConfigGenConnectionsRequest, ) -> ApiResult<()>
Sets our connection info, possibly sending it to a leader
Sourceasync fn update_leader(&self) -> ApiResult<()>
async fn update_leader(&self) -> ApiResult<()>
Sends our updated peer info to the leader (if we have one)
Sourcepub async fn add_config_gen_peer(&self, peer: PeerServerParams) -> ApiResult<()>
pub async fn add_config_gen_peer(&self, peer: PeerServerParams) -> ApiResult<()>
Called from set_config_gen_connections
to add a peer’s connection info
to the leader
Sourcepub async fn config_gen_peers(&self) -> ApiResult<Vec<PeerServerParams>>
pub async fn config_gen_peers(&self) -> ApiResult<Vec<PeerServerParams>>
Returns the peers that have called add_config_gen_peer
on the leader
Sourcepub async fn default_config_gen_params(
&self,
) -> ApiResult<ConfigGenParamsRequest>
pub async fn default_config_gen_params( &self, ) -> ApiResult<ConfigGenParamsRequest>
Returns default config gen params that can be modified by the leader
Sourcepub async fn set_config_gen_params(
&self,
request: ConfigGenParamsRequest,
) -> ApiResult<()>
pub async fn set_config_gen_params( &self, request: ConfigGenParamsRequest, ) -> ApiResult<()>
Sets and validates the config gen params
The leader passes consensus params, everyone passes local params
async fn get_requested_params(&self) -> ApiResult<ConfigGenParamsRequest>
Sourcepub async fn consensus_config_gen_params(
&self,
request: &ConfigGenParamsRequest,
) -> ApiResult<ConfigGenParamsResponse>
pub async fn consensus_config_gen_params( &self, request: &ConfigGenParamsRequest, ) -> ApiResult<ConfigGenParamsResponse>
Gets the consensus config gen params
Sourcepub async fn run_dkg(&self) -> ApiResult<()>
pub async fn run_dkg(&self) -> ApiResult<()>
Once configs are generated, updates status to ReadyForConfigGen and spawns a task to coordinate DKG, then returns. Coordinating DKG in a separate thread allows clients to poll the server status instead of blocking until completion, which can be fragile due to timeouts, poor network connections, etc.
Calling a second time will return an error.
Sourcepub async fn verify_config_hash(&self) -> ApiResult<BTreeMap<PeerId, Hash>>
pub async fn verify_config_hash(&self) -> ApiResult<BTreeMap<PeerId, Hash>>
Returns tagged hashes of consensus config to be shared with other peers. The hashes are tagged with the peer id such that they are unique to each peer and their manual verification by the guardians via the UI is more robust.
Sourcepub async fn verified_configs(&self) -> ApiResult<()>
pub async fn verified_configs(&self) -> ApiResult<()>
We have verified all our peer configs
pub async fn start_consensus(&self) -> ApiResult<()>
Sourcepub async fn server_status(&self) -> ServerStatus
pub async fn server_status(&self) -> ServerStatus
Returns the server status
fn bad_request<T>(msg: &str) -> ApiResult<T>
pub async fn restart_federation_setup(&self) -> ApiResult<()>
async fn await_leader_restart(&self, client: &DynGlobalApi) -> ApiResult<()>
async fn await_peer_restart(&self)
pub async fn check_bitcoin_status( &self, ) -> ApiResult<BitcoinRpcConnectionStatus>
async fn check_esplora_status( &self, bitcoin_rpc_config: &BitcoinRpcConfig, ) -> ApiResult<BitcoinRpcConnectionStatus>
Trait Implementations§
Source§impl Clone for ConfigGenApi
impl Clone for ConfigGenApi
Source§fn clone(&self) -> ConfigGenApi
fn clone(&self) -> ConfigGenApi
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl HasApiContext<ConfigGenApi> for ConfigGenApi
impl HasApiContext<ConfigGenApi> for ConfigGenApi
fn context<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 ApiRequestErased,
id: Option<ModuleInstanceId>,
) -> Pin<Box<dyn Future<Output = (&ConfigGenApi, ApiEndpointContext<'_>)> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for ConfigGenApi
impl !RefUnwindSafe for ConfigGenApi
impl Send for ConfigGenApi
impl Sync for ConfigGenApi
impl Unpin for ConfigGenApi
impl !UnwindSafe for ConfigGenApi
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.