mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-08-01 03:06:06 -04:00
add watchvalue test and some more routing context convenience functions
This commit is contained in:
parent
30cc4a814b
commit
b51c660b9c
7 changed files with 174 additions and 19 deletions
|
@ -63,6 +63,7 @@ class VeilidVersion extends Equatable {
|
|||
@immutable
|
||||
class Timestamp extends Equatable implements Comparable<Timestamp> {
|
||||
const Timestamp({required this.value});
|
||||
factory Timestamp.zero() => Timestamp(value: BigInt.zero);
|
||||
factory Timestamp.fromInt64(Int64 i64) => Timestamp(
|
||||
value: (BigInt.from((i64 >> 32).toUnsigned(32).toInt()) << 32) |
|
||||
BigInt.from(i64.toUnsigned(32).toInt()));
|
||||
|
@ -144,6 +145,21 @@ abstract class Veilid {
|
|||
|
||||
// Routing context
|
||||
Future<VeilidRoutingContext> routingContext();
|
||||
Future<VeilidRoutingContext> safeRoutingContext(
|
||||
{Stability stability = Stability.lowLatency,
|
||||
Sequencing sequencing = Sequencing.preferOrdered}) async {
|
||||
final rc = await routingContext();
|
||||
final originalSafety = await rc.safety() as SafetySelectionSafe;
|
||||
final safetySpec = originalSafety.safetySpec
|
||||
.copyWith(stability: stability, sequencing: sequencing);
|
||||
return rc.withSafety(SafetySelectionSafe(safetySpec: safetySpec),
|
||||
closeSelf: true);
|
||||
}
|
||||
|
||||
Future<VeilidRoutingContext> unsafeRoutingContext(
|
||||
{Sequencing sequencing = Sequencing.preferOrdered}) async =>
|
||||
(await routingContext())
|
||||
.withSafety(SafetySelectionUnsafe(sequencing: sequencing));
|
||||
|
||||
// Private route allocation
|
||||
Future<RouteBlob> newPrivateRoute();
|
||||
|
|
|
@ -702,7 +702,7 @@ class VeilidRoutingContextFFI extends VeilidRoutingContext {
|
|||
Timestamp? expiration,
|
||||
int? count}) async {
|
||||
subkeys ??= [];
|
||||
expiration ??= Timestamp(value: BigInt.zero);
|
||||
expiration ??= Timestamp.zero();
|
||||
count ??= 0xFFFFFFFF;
|
||||
|
||||
_ctx.ensureValid();
|
||||
|
|
|
@ -207,7 +207,7 @@ class VeilidRoutingContextJS extends VeilidRoutingContext {
|
|||
Timestamp? expiration,
|
||||
int? count}) async {
|
||||
subkeys ??= [];
|
||||
expiration ??= Timestamp(value: BigInt.zero);
|
||||
expiration ??= Timestamp.zero();
|
||||
count ??= 0xFFFFFFFF;
|
||||
|
||||
final id = _ctx.requireId();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue