Merge branch 'uptime-debug-command' into 'main'

Add "uptime" debug command

See merge request veilid/veilid!323
This commit is contained in:
Christien Rioux 2024-10-19 15:18:26 +00:00
commit 5e81379469
10 changed files with 379 additions and 85 deletions

View File

@ -246,3 +246,23 @@ of the build steps configured, consult the `Earthfile`, or you may use the
```shell
earthly ls
```
## Updating bindings
When changing Veilid API, bindings must be updated to reflect the changes.
For each language, perform the listed steps and commit changed files.
### Dart
1. Update sources in `veilid-flutter/lib`, ignoring `*.freezed.*` and `*.g.*`
2. Run `dart run build_runner build` inside `veilid-flutter`, allow to delete existing files if asked
### Python
1. Run `cargo build --bin=veilid-server`
2. Run `./veilid-python/update_schema.sh`
3. Update sources in `veilid-python/veilid`
### WASM
1. Update sources in `veilid-wasm/src`

View File

@ -8,6 +8,7 @@ struct AttachmentManagerInner {
last_attachment_state: AttachmentState,
last_routing_table_health: Option<RoutingTableHealth>,
maintain_peers: bool,
started_ts: Timestamp,
attach_ts: Option<Timestamp>,
update_callback: Option<UpdateCallback>,
attachment_maintainer_jh: Option<MustJoinHandle<()>>,
@ -49,6 +50,7 @@ impl AttachmentManager {
last_attachment_state: AttachmentState::Detached,
last_routing_table_health: None,
maintain_peers: false,
started_ts: Timestamp::now(),
attach_ts: None,
update_callback: None,
attachment_maintainer_jh: None,
@ -177,6 +179,9 @@ impl AttachmentManager {
}
fn update_attaching_detaching_state(&self, state: AttachmentState) {
let uptime;
let attached_uptime;
let update_callback = {
let mut inner = self.inner.lock();
@ -197,6 +202,10 @@ impl AttachmentManager {
unreachable!("don't use this for attached states, use update_attachment()");
}
let now = Timestamp::now();
uptime = now - inner.started_ts;
attached_uptime = inner.attach_ts.map(|ts| now - ts);
// Get callback
inner.update_callback.clone()
};
@ -207,6 +216,8 @@ impl AttachmentManager {
state,
public_internet_ready: false,
local_network_ready: false,
uptime,
attached_uptime,
})))
}
}
@ -355,6 +366,10 @@ impl AttachmentManager {
// }
fn get_veilid_state_inner(inner: &AttachmentManagerInner) -> Box<VeilidStateAttachment> {
let now = Timestamp::now();
let uptime = now - inner.started_ts;
let attached_uptime = inner.attach_ts.map(|ts| now - ts);
Box::new(VeilidStateAttachment {
state: inner.last_attachment_state,
public_internet_ready: inner
@ -367,6 +382,8 @@ impl AttachmentManager {
.as_ref()
.map(|x| x.local_network_ready)
.unwrap_or(false),
uptime,
attached_uptime,
})
}

View File

@ -7,6 +7,7 @@ use hashlink::LinkedHashMap;
use network_manager::*;
use once_cell::sync::Lazy;
use routing_table::*;
use std::fmt::Write;
#[derive(Default)]
pub(crate) struct DebugCache {
@ -2008,6 +2009,7 @@ impl VeilidAPI {
nodeinfo - display detailed information about this node
dialinfo - display the dialinfo in the routing domains of this node
peerinfo [routingdomain] [published|current] - display the full PeerInfo for a routing domain of this node
uptime - display node uptime
Routing:
buckets [dead|reliable] - Display the routing table bucket statistics (default is only non-dead nodes)
@ -2097,6 +2099,24 @@ TableDB Operations:
.to_owned())
}
/// Get node uptime info.
pub async fn debug_uptime(&self, _args: String) -> VeilidAPIResult<String> {
let mut result = String::new();
writeln!(result, "Uptime...").ok();
let state = self.get_state().await?;
let uptime = state.attachment.uptime;
writeln!(result, " since launch: {uptime}").ok();
if let Some(attached_uptime) = state.attachment.attached_uptime {
writeln!(result, " since attachment: {attached_uptime}").ok();
}
Ok(result)
}
/// Execute an 'internal debug command'.
pub async fn debug(&self, args: String) -> VeilidAPIResult<String> {
let res = {
@ -2160,6 +2180,8 @@ TableDB Operations:
self.debug_punish(rest).await
} else if arg == "table" {
self.debug_table(rest).await
} else if arg == "uptime" {
self.debug_uptime(rest).await
} else {
Err(VeilidAPIError::generic("Unknown debug command"))
}

View File

@ -213,6 +213,8 @@ pub async fn test_veilidstateattachment() {
state: AttachmentState::OverAttached,
public_internet_ready: true,
local_network_ready: false,
uptime: TimestampDuration::new_secs(10),
attached_uptime: Some(TimestampDuration::new_secs(10)),
};
let copy = deserialize_json(&serialize_json(&orig)).unwrap();
@ -277,6 +279,8 @@ pub async fn test_veilidstate() {
state: AttachmentState::OverAttached,
public_internet_ready: true,
local_network_ready: false,
uptime: TimestampDuration::new_secs(900),
attached_uptime: Some(TimestampDuration::new_secs(600)),
}),
network: Box::new(VeilidStateNetwork {
started: true,

View File

@ -73,11 +73,15 @@ impl TryFrom<String> for AttachmentState {
pub struct VeilidStateAttachment {
/// The overall quality of the routing table if attached, or the current state the attachment state machine.
pub state: AttachmentState,
/// If attached and there are enough eachable nodes in the routing table to perform all the actions of the PublicInternet RoutingDomain,
/// If attached and there are enough reachable nodes in the routing table to perform all the actions of the PublicInternet RoutingDomain,
/// including things like private/safety route allocation and DHT operations.
pub public_internet_ready: bool,
/// If attached and there are enough eachable nodes in the routing table to perform all the actions of the LocalNetwork RoutingDomain.
/// If attached and there are enough reachable nodes in the routing table to perform all the actions of the LocalNetwork RoutingDomain.
pub local_network_ready: bool,
/// Node uptime
pub uptime: TimestampDuration,
/// Uptime since last attach, empty if the node is currently detached
pub attached_uptime: Option<TimestampDuration>,
}
/// Describe a recently accessed peer

View File

@ -215,7 +215,9 @@ sealed class VeilidUpdate with _$VeilidUpdate {
const factory VeilidUpdate.attachment(
{required AttachmentState state,
required bool publicInternetReady,
required bool localNetworkReady}) = VeilidUpdateAttachment;
required bool localNetworkReady,
required TimestampDuration uptime,
required TimestampDuration? attachedUptime}) = VeilidUpdateAttachment;
const factory VeilidUpdate.network(
{required bool started,
required BigInt bpsDown,
@ -247,7 +249,9 @@ class VeilidStateAttachment with _$VeilidStateAttachment {
const factory VeilidStateAttachment(
{required AttachmentState state,
required bool publicInternetReady,
required bool localNetworkReady}) = _VeilidStateAttachment;
required bool localNetworkReady,
required TimestampDuration uptime,
required TimestampDuration? attachedUptime}) = _VeilidStateAttachment;
factory VeilidStateAttachment.fromJson(dynamic json) =>
_$VeilidStateAttachmentFromJson(json as Map<String, dynamic>);

View File

@ -2434,8 +2434,12 @@ mixin _$VeilidUpdate {
Typed<FixedEncodedString43>? sender,
String? routeId)
appCall,
required TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)
required TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)
attachment,
required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)
@ -2463,8 +2467,12 @@ mixin _$VeilidUpdate {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult? Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult? Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -2491,8 +2499,12 @@ mixin _$VeilidUpdate {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -2681,8 +2693,12 @@ class _$VeilidLogImpl implements VeilidLog {
Typed<FixedEncodedString43>? sender,
String? routeId)
appCall,
required TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)
required TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)
attachment,
required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)
@ -2713,8 +2729,12 @@ class _$VeilidLogImpl implements VeilidLog {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult? Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult? Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -2744,8 +2764,12 @@ class _$VeilidLogImpl implements VeilidLog {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -2957,8 +2981,12 @@ class _$VeilidAppMessageImpl implements VeilidAppMessage {
Typed<FixedEncodedString43>? sender,
String? routeId)
appCall,
required TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)
required TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)
attachment,
required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)
@ -2989,8 +3017,12 @@ class _$VeilidAppMessageImpl implements VeilidAppMessage {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult? Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult? Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -3020,8 +3052,12 @@ class _$VeilidAppMessageImpl implements VeilidAppMessage {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -3243,8 +3279,12 @@ class _$VeilidAppCallImpl implements VeilidAppCall {
Typed<FixedEncodedString43>? sender,
String? routeId)
appCall,
required TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)
required TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)
attachment,
required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)
@ -3275,8 +3315,12 @@ class _$VeilidAppCallImpl implements VeilidAppCall {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult? Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult? Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -3306,8 +3350,12 @@ class _$VeilidAppCallImpl implements VeilidAppCall {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -3416,7 +3464,9 @@ abstract class _$$VeilidUpdateAttachmentImplCopyWith<$Res> {
$Res call(
{AttachmentState state,
bool publicInternetReady,
bool localNetworkReady});
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime});
}
/// @nodoc
@ -3436,6 +3486,8 @@ class __$$VeilidUpdateAttachmentImplCopyWithImpl<$Res>
Object? state = null,
Object? publicInternetReady = null,
Object? localNetworkReady = null,
Object? uptime = null,
Object? attachedUptime = freezed,
}) {
return _then(_$VeilidUpdateAttachmentImpl(
state: null == state
@ -3450,6 +3502,14 @@ class __$$VeilidUpdateAttachmentImplCopyWithImpl<$Res>
? _value.localNetworkReady
: localNetworkReady // ignore: cast_nullable_to_non_nullable
as bool,
uptime: null == uptime
? _value.uptime
: uptime // ignore: cast_nullable_to_non_nullable
as TimestampDuration,
attachedUptime: freezed == attachedUptime
? _value.attachedUptime
: attachedUptime // ignore: cast_nullable_to_non_nullable
as TimestampDuration?,
));
}
}
@ -3461,6 +3521,8 @@ class _$VeilidUpdateAttachmentImpl implements VeilidUpdateAttachment {
{required this.state,
required this.publicInternetReady,
required this.localNetworkReady,
required this.uptime,
required this.attachedUptime,
final String? $type})
: $type = $type ?? 'Attachment';
@ -3473,13 +3535,17 @@ class _$VeilidUpdateAttachmentImpl implements VeilidUpdateAttachment {
final bool publicInternetReady;
@override
final bool localNetworkReady;
@override
final TimestampDuration uptime;
@override
final TimestampDuration? attachedUptime;
@JsonKey(name: 'kind')
final String $type;
@override
String toString() {
return 'VeilidUpdate.attachment(state: $state, publicInternetReady: $publicInternetReady, localNetworkReady: $localNetworkReady)';
return 'VeilidUpdate.attachment(state: $state, publicInternetReady: $publicInternetReady, localNetworkReady: $localNetworkReady, uptime: $uptime, attachedUptime: $attachedUptime)';
}
@override
@ -3491,13 +3557,16 @@ class _$VeilidUpdateAttachmentImpl implements VeilidUpdateAttachment {
(identical(other.publicInternetReady, publicInternetReady) ||
other.publicInternetReady == publicInternetReady) &&
(identical(other.localNetworkReady, localNetworkReady) ||
other.localNetworkReady == localNetworkReady));
other.localNetworkReady == localNetworkReady) &&
(identical(other.uptime, uptime) || other.uptime == uptime) &&
(identical(other.attachedUptime, attachedUptime) ||
other.attachedUptime == attachedUptime));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode =>
Object.hash(runtimeType, state, publicInternetReady, localNetworkReady);
int get hashCode => Object.hash(runtimeType, state, publicInternetReady,
localNetworkReady, uptime, attachedUptime);
/// Create a copy of VeilidUpdate
/// with the given fields replaced by the non-null parameter values.
@ -3525,8 +3594,12 @@ class _$VeilidUpdateAttachmentImpl implements VeilidUpdateAttachment {
Typed<FixedEncodedString43>? sender,
String? routeId)
appCall,
required TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)
required TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)
attachment,
required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)
@ -3539,7 +3612,8 @@ class _$VeilidUpdateAttachmentImpl implements VeilidUpdateAttachment {
List<ValueSubkeyRange> subkeys, int count, ValueData? value)
valueChange,
}) {
return attachment(state, publicInternetReady, localNetworkReady);
return attachment(
state, publicInternetReady, localNetworkReady, uptime, attachedUptime);
}
@override
@ -3557,8 +3631,12 @@ class _$VeilidUpdateAttachmentImpl implements VeilidUpdateAttachment {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult? Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult? Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -3570,7 +3648,8 @@ class _$VeilidUpdateAttachmentImpl implements VeilidUpdateAttachment {
List<ValueSubkeyRange> subkeys, int count, ValueData? value)?
valueChange,
}) {
return attachment?.call(state, publicInternetReady, localNetworkReady);
return attachment?.call(
state, publicInternetReady, localNetworkReady, uptime, attachedUptime);
}
@override
@ -3588,8 +3667,12 @@ class _$VeilidUpdateAttachmentImpl implements VeilidUpdateAttachment {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -3603,7 +3686,8 @@ class _$VeilidUpdateAttachmentImpl implements VeilidUpdateAttachment {
required TResult orElse(),
}) {
if (attachment != null) {
return attachment(state, publicInternetReady, localNetworkReady);
return attachment(state, publicInternetReady, localNetworkReady, uptime,
attachedUptime);
}
return orElse();
}
@ -3667,9 +3751,12 @@ class _$VeilidUpdateAttachmentImpl implements VeilidUpdateAttachment {
abstract class VeilidUpdateAttachment implements VeilidUpdate {
const factory VeilidUpdateAttachment(
{required final AttachmentState state,
required final bool publicInternetReady,
required final bool localNetworkReady}) = _$VeilidUpdateAttachmentImpl;
{required final AttachmentState state,
required final bool publicInternetReady,
required final bool localNetworkReady,
required final TimestampDuration uptime,
required final TimestampDuration? attachedUptime}) =
_$VeilidUpdateAttachmentImpl;
factory VeilidUpdateAttachment.fromJson(Map<String, dynamic> json) =
_$VeilidUpdateAttachmentImpl.fromJson;
@ -3677,6 +3764,8 @@ abstract class VeilidUpdateAttachment implements VeilidUpdate {
AttachmentState get state;
bool get publicInternetReady;
bool get localNetworkReady;
TimestampDuration get uptime;
TimestampDuration? get attachedUptime;
/// Create a copy of VeilidUpdate
/// with the given fields replaced by the non-null parameter values.
@ -3813,8 +3902,12 @@ class _$VeilidUpdateNetworkImpl implements VeilidUpdateNetwork {
Typed<FixedEncodedString43>? sender,
String? routeId)
appCall,
required TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)
required TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)
attachment,
required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)
@ -3845,8 +3938,12 @@ class _$VeilidUpdateNetworkImpl implements VeilidUpdateNetwork {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult? Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult? Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -3876,8 +3973,12 @@ class _$VeilidUpdateNetworkImpl implements VeilidUpdateNetwork {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -4078,8 +4179,12 @@ class _$VeilidUpdateConfigImpl implements VeilidUpdateConfig {
Typed<FixedEncodedString43>? sender,
String? routeId)
appCall,
required TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)
required TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)
attachment,
required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)
@ -4110,8 +4215,12 @@ class _$VeilidUpdateConfigImpl implements VeilidUpdateConfig {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult? Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult? Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -4141,8 +4250,12 @@ class _$VeilidUpdateConfigImpl implements VeilidUpdateConfig {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -4357,8 +4470,12 @@ class _$VeilidUpdateRouteChangeImpl implements VeilidUpdateRouteChange {
Typed<FixedEncodedString43>? sender,
String? routeId)
appCall,
required TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)
required TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)
attachment,
required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)
@ -4389,8 +4506,12 @@ class _$VeilidUpdateRouteChangeImpl implements VeilidUpdateRouteChange {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult? Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult? Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -4420,8 +4541,12 @@ class _$VeilidUpdateRouteChangeImpl implements VeilidUpdateRouteChange {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -4666,8 +4791,12 @@ class _$VeilidUpdateValueChangeImpl implements VeilidUpdateValueChange {
Typed<FixedEncodedString43>? sender,
String? routeId)
appCall,
required TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)
required TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)
attachment,
required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)
@ -4698,8 +4827,12 @@ class _$VeilidUpdateValueChangeImpl implements VeilidUpdateValueChange {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult? Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult? Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -4729,8 +4862,12 @@ class _$VeilidUpdateValueChangeImpl implements VeilidUpdateValueChange {
Typed<FixedEncodedString43>? sender,
String? routeId)?
appCall,
TResult Function(AttachmentState state, bool publicInternetReady,
bool localNetworkReady)?
TResult Function(
AttachmentState state,
bool publicInternetReady,
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime)?
attachment,
TResult Function(bool started, BigInt bpsDown, BigInt bpsUp,
List<PeerTableData> peers)?
@ -4838,6 +4975,8 @@ mixin _$VeilidStateAttachment {
AttachmentState get state => throw _privateConstructorUsedError;
bool get publicInternetReady => throw _privateConstructorUsedError;
bool get localNetworkReady => throw _privateConstructorUsedError;
TimestampDuration get uptime => throw _privateConstructorUsedError;
TimestampDuration? get attachedUptime => throw _privateConstructorUsedError;
/// Serializes this VeilidStateAttachment to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@ -4858,7 +4997,9 @@ abstract class $VeilidStateAttachmentCopyWith<$Res> {
$Res call(
{AttachmentState state,
bool publicInternetReady,
bool localNetworkReady});
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime});
}
/// @nodoc
@ -4880,6 +5021,8 @@ class _$VeilidStateAttachmentCopyWithImpl<$Res,
Object? state = null,
Object? publicInternetReady = null,
Object? localNetworkReady = null,
Object? uptime = null,
Object? attachedUptime = freezed,
}) {
return _then(_value.copyWith(
state: null == state
@ -4894,6 +5037,14 @@ class _$VeilidStateAttachmentCopyWithImpl<$Res,
? _value.localNetworkReady
: localNetworkReady // ignore: cast_nullable_to_non_nullable
as bool,
uptime: null == uptime
? _value.uptime
: uptime // ignore: cast_nullable_to_non_nullable
as TimestampDuration,
attachedUptime: freezed == attachedUptime
? _value.attachedUptime
: attachedUptime // ignore: cast_nullable_to_non_nullable
as TimestampDuration?,
) as $Val);
}
}
@ -4910,7 +5061,9 @@ abstract class _$$VeilidStateAttachmentImplCopyWith<$Res>
$Res call(
{AttachmentState state,
bool publicInternetReady,
bool localNetworkReady});
bool localNetworkReady,
TimestampDuration uptime,
TimestampDuration? attachedUptime});
}
/// @nodoc
@ -4930,6 +5083,8 @@ class __$$VeilidStateAttachmentImplCopyWithImpl<$Res>
Object? state = null,
Object? publicInternetReady = null,
Object? localNetworkReady = null,
Object? uptime = null,
Object? attachedUptime = freezed,
}) {
return _then(_$VeilidStateAttachmentImpl(
state: null == state
@ -4944,6 +5099,14 @@ class __$$VeilidStateAttachmentImplCopyWithImpl<$Res>
? _value.localNetworkReady
: localNetworkReady // ignore: cast_nullable_to_non_nullable
as bool,
uptime: null == uptime
? _value.uptime
: uptime // ignore: cast_nullable_to_non_nullable
as TimestampDuration,
attachedUptime: freezed == attachedUptime
? _value.attachedUptime
: attachedUptime // ignore: cast_nullable_to_non_nullable
as TimestampDuration?,
));
}
}
@ -4954,7 +5117,9 @@ class _$VeilidStateAttachmentImpl implements _VeilidStateAttachment {
const _$VeilidStateAttachmentImpl(
{required this.state,
required this.publicInternetReady,
required this.localNetworkReady});
required this.localNetworkReady,
required this.uptime,
required this.attachedUptime});
factory _$VeilidStateAttachmentImpl.fromJson(Map<String, dynamic> json) =>
_$$VeilidStateAttachmentImplFromJson(json);
@ -4965,10 +5130,14 @@ class _$VeilidStateAttachmentImpl implements _VeilidStateAttachment {
final bool publicInternetReady;
@override
final bool localNetworkReady;
@override
final TimestampDuration uptime;
@override
final TimestampDuration? attachedUptime;
@override
String toString() {
return 'VeilidStateAttachment(state: $state, publicInternetReady: $publicInternetReady, localNetworkReady: $localNetworkReady)';
return 'VeilidStateAttachment(state: $state, publicInternetReady: $publicInternetReady, localNetworkReady: $localNetworkReady, uptime: $uptime, attachedUptime: $attachedUptime)';
}
@override
@ -4980,13 +5149,16 @@ class _$VeilidStateAttachmentImpl implements _VeilidStateAttachment {
(identical(other.publicInternetReady, publicInternetReady) ||
other.publicInternetReady == publicInternetReady) &&
(identical(other.localNetworkReady, localNetworkReady) ||
other.localNetworkReady == localNetworkReady));
other.localNetworkReady == localNetworkReady) &&
(identical(other.uptime, uptime) || other.uptime == uptime) &&
(identical(other.attachedUptime, attachedUptime) ||
other.attachedUptime == attachedUptime));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode =>
Object.hash(runtimeType, state, publicInternetReady, localNetworkReady);
int get hashCode => Object.hash(runtimeType, state, publicInternetReady,
localNetworkReady, uptime, attachedUptime);
/// Create a copy of VeilidStateAttachment
/// with the given fields replaced by the non-null parameter values.
@ -5007,9 +5179,12 @@ class _$VeilidStateAttachmentImpl implements _VeilidStateAttachment {
abstract class _VeilidStateAttachment implements VeilidStateAttachment {
const factory _VeilidStateAttachment(
{required final AttachmentState state,
required final bool publicInternetReady,
required final bool localNetworkReady}) = _$VeilidStateAttachmentImpl;
{required final AttachmentState state,
required final bool publicInternetReady,
required final bool localNetworkReady,
required final TimestampDuration uptime,
required final TimestampDuration? attachedUptime}) =
_$VeilidStateAttachmentImpl;
factory _VeilidStateAttachment.fromJson(Map<String, dynamic> json) =
_$VeilidStateAttachmentImpl.fromJson;
@ -5020,6 +5195,10 @@ abstract class _VeilidStateAttachment implements VeilidStateAttachment {
bool get publicInternetReady;
@override
bool get localNetworkReady;
@override
TimestampDuration get uptime;
@override
TimestampDuration? get attachedUptime;
/// Create a copy of VeilidStateAttachment
/// with the given fields replaced by the non-null parameter values.

View File

@ -268,6 +268,10 @@ _$VeilidUpdateAttachmentImpl _$$VeilidUpdateAttachmentImplFromJson(
state: AttachmentState.fromJson(json['state']),
publicInternetReady: json['public_internet_ready'] as bool,
localNetworkReady: json['local_network_ready'] as bool,
uptime: TimestampDuration.fromJson(json['uptime']),
attachedUptime: json['attached_uptime'] == null
? null
: TimestampDuration.fromJson(json['attached_uptime']),
$type: json['kind'] as String?,
);
@ -277,6 +281,8 @@ Map<String, dynamic> _$$VeilidUpdateAttachmentImplToJson(
'state': instance.state.toJson(),
'public_internet_ready': instance.publicInternetReady,
'local_network_ready': instance.localNetworkReady,
'uptime': instance.uptime.toJson(),
'attached_uptime': instance.attachedUptime?.toJson(),
'kind': instance.$type,
};
@ -363,6 +369,10 @@ _$VeilidStateAttachmentImpl _$$VeilidStateAttachmentImplFromJson(
state: AttachmentState.fromJson(json['state']),
publicInternetReady: json['public_internet_ready'] as bool,
localNetworkReady: json['local_network_ready'] as bool,
uptime: TimestampDuration.fromJson(json['uptime']),
attachedUptime: json['attached_uptime'] == null
? null
: TimestampDuration.fromJson(json['attached_uptime']),
);
Map<String, dynamic> _$$VeilidStateAttachmentImplToJson(
@ -371,6 +381,8 @@ Map<String, dynamic> _$$VeilidStateAttachmentImplToJson(
'state': instance.state.toJson(),
'public_internet_ready': instance.publicInternetReady,
'local_network_ready': instance.localNetworkReady,
'uptime': instance.uptime.toJson(),
'attached_uptime': instance.attachedUptime?.toJson(),
};
_$VeilidStateNetworkImpl _$$VeilidStateNetworkImplFromJson(

View File

@ -2588,9 +2588,17 @@
"kind",
"local_network_ready",
"public_internet_ready",
"state"
"state",
"uptime"
],
"properties": {
"attached_uptime": {
"description": "Uptime since last attach, empty if the node is currently detached",
"type": [
"string",
"null"
]
},
"kind": {
"type": "string",
"enum": [
@ -2598,11 +2606,11 @@
]
},
"local_network_ready": {
"description": "If attached and there are enough eachable nodes in the routing table to perform all the actions of the LocalNetwork RoutingDomain.",
"description": "If attached and there are enough reachable nodes in the routing table to perform all the actions of the LocalNetwork RoutingDomain.",
"type": "boolean"
},
"public_internet_ready": {
"description": "If attached and there are enough eachable nodes in the routing table to perform all the actions of the PublicInternet RoutingDomain, including things like private/safety route allocation and DHT operations.",
"description": "If attached and there are enough reachable nodes in the routing table to perform all the actions of the PublicInternet RoutingDomain, including things like private/safety route allocation and DHT operations.",
"type": "boolean"
},
"state": {
@ -2612,6 +2620,10 @@
"$ref": "#/definitions/AttachmentState"
}
]
},
"uptime": {
"description": "Node uptime",
"type": "string"
}
}
},
@ -4618,15 +4630,23 @@
"required": [
"local_network_ready",
"public_internet_ready",
"state"
"state",
"uptime"
],
"properties": {
"attached_uptime": {
"description": "Uptime since last attach, empty if the node is currently detached",
"type": [
"string",
"null"
]
},
"local_network_ready": {
"description": "If attached and there are enough eachable nodes in the routing table to perform all the actions of the LocalNetwork RoutingDomain.",
"description": "If attached and there are enough reachable nodes in the routing table to perform all the actions of the LocalNetwork RoutingDomain.",
"type": "boolean"
},
"public_internet_ready": {
"description": "If attached and there are enough eachable nodes in the routing table to perform all the actions of the PublicInternet RoutingDomain, including things like private/safety route allocation and DHT operations.",
"description": "If attached and there are enough reachable nodes in the routing table to perform all the actions of the PublicInternet RoutingDomain, including things like private/safety route allocation and DHT operations.",
"type": "boolean"
},
"state": {
@ -4636,6 +4656,10 @@
"$ref": "#/definitions/AttachmentState"
}
]
},
"uptime": {
"description": "Node uptime",
"type": "string"
}
}
},

View File

@ -31,16 +31,22 @@ class VeilidStateAttachment:
state: AttachmentState
public_internet_ready: bool
local_network_ready: bool
uptime: TimestampDuration
attached_uptime: Optional[TimestampDuration]
def __init__(
self,
state: AttachmentState,
public_internet_ready: bool,
local_network_ready: bool,
uptime: TimestampDuration,
attached_uptime: Optional[TimestampDuration],
):
self.state = state
self.public_internet_ready = public_internet_ready
self.local_network_ready = local_network_ready
self.uptime = uptime
self.attached_uptime = attached_uptime
@classmethod
def from_json(cls, j: dict) -> Self:
@ -49,6 +55,8 @@ class VeilidStateAttachment:
AttachmentState(j["state"]),
j["public_internet_ready"],
j["local_network_ready"],
j["uptime"],
j["attached_uptime"],
)