mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-08-02 03:06:06 -04:00
debugging work
This commit is contained in:
parent
739df7c427
commit
d6b1c20906
71 changed files with 4155 additions and 3616 deletions
|
@ -1,5 +1,6 @@
|
|||
import '../../proto/dht.pb.dart' as dhtproto;
|
||||
import '../../proto/proto.dart' as veilidproto;
|
||||
import '../../src/dynamic_debug.dart';
|
||||
import '../dht_support.dart';
|
||||
|
||||
export '../../proto/dht.pb.dart';
|
||||
|
@ -23,3 +24,44 @@ extension ProtoOwnedDHTRecordPointer on dhtproto.OwnedDHTRecordPointer {
|
|||
OwnedDHTRecordPointer toVeilid() => OwnedDHTRecordPointer(
|
||||
recordKey: recordKey.toVeilid(), owner: owner.toVeilid());
|
||||
}
|
||||
|
||||
void registerVeilidDHTProtoToDebug() {
|
||||
dynamic toDebug(dynamic obj) {
|
||||
if (obj is dhtproto.OwnedDHTRecordPointer) {
|
||||
return {
|
||||
r'$runtimeType': obj.runtimeType,
|
||||
'recordKey': obj.recordKey,
|
||||
'owner': obj.owner,
|
||||
};
|
||||
}
|
||||
if (obj is dhtproto.DHTData) {
|
||||
return {
|
||||
r'$runtimeType': obj.runtimeType,
|
||||
'keys': obj.keys,
|
||||
'hash': obj.hash,
|
||||
'chunk': obj.chunk,
|
||||
'size': obj.size
|
||||
};
|
||||
}
|
||||
if (obj is dhtproto.DHTLog) {
|
||||
return {
|
||||
r'$runtimeType': obj.runtimeType,
|
||||
'head': obj.head,
|
||||
'tail': obj.tail,
|
||||
'stride': obj.stride,
|
||||
};
|
||||
}
|
||||
if (obj is dhtproto.DHTShortArray) {
|
||||
return {
|
||||
r'$runtimeType': obj.runtimeType,
|
||||
'keys': obj.keys,
|
||||
'index': obj.index,
|
||||
'seqs': obj.seqs,
|
||||
};
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
DynamicDebug.registerToDebug(toDebug);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,14 @@ class DHTLogStateData<T> extends Equatable {
|
|||
|
||||
@override
|
||||
List<Object?> get props => [length, window, windowTail, windowSize, follow];
|
||||
|
||||
@override
|
||||
String toString() => 'DHTLogStateData('
|
||||
'length: $length, '
|
||||
'windowTail: $windowTail, '
|
||||
'windowSize: $windowSize, '
|
||||
'follow: $follow, '
|
||||
'window: ${DynamicDebug.toDebug(window)})';
|
||||
}
|
||||
|
||||
typedef DHTLogState<T> = AsyncValue<DHTLogStateData<T>>;
|
||||
|
|
|
@ -126,10 +126,7 @@ class _DHTLogSpine {
|
|||
Future<bool> delete() async => _spineMutex.protect(_spineRecord.delete);
|
||||
|
||||
Future<T> operate<T>(Future<T> Function(_DHTLogSpine) closure) async =>
|
||||
// ignore: prefer_expression_function_bodies
|
||||
_spineMutex.protect(() async {
|
||||
return closure(this);
|
||||
});
|
||||
_spineMutex.protect(() async => closure(this));
|
||||
|
||||
Future<T> operateAppend<T>(Future<T> Function(_DHTLogSpine) closure) async =>
|
||||
_spineMutex.protect(() async {
|
||||
|
|
|
@ -511,7 +511,7 @@ class DHTRecord implements DHTDeleteable<DHTRecord> {
|
|||
key,
|
||||
subkeys: [ValueSubkeyRange.single(subkey)],
|
||||
);
|
||||
return rr.localSeqs.firstOrNull ?? 0xFFFFFFFF;
|
||||
return rr.localSeqs.firstOrNull ?? emptySeq;
|
||||
}
|
||||
|
||||
void _addValueChange(
|
||||
|
@ -566,4 +566,6 @@ class DHTRecord implements DHTDeleteable<DHTRecord> {
|
|||
int _openCount;
|
||||
StreamController<DHTRecordWatchChange>? _watchController;
|
||||
_WatchState? _watchState;
|
||||
|
||||
static const int emptySeq = 0xFFFFFFFF;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
|||
import 'package:protobuf/protobuf.dart';
|
||||
|
||||
import '../../../../veilid_support.dart';
|
||||
import 'extensions.dart';
|
||||
|
||||
export 'package:fast_immutable_collections/fast_immutable_collections.dart'
|
||||
show Output;
|
||||
|
@ -32,7 +33,7 @@ typedef DHTRecordPoolLogger = void Function(String message);
|
|||
/// Record pool that managed DHTRecords and allows for tagged deletion
|
||||
/// String versions of keys due to IMap<> json unsupported in key
|
||||
@freezed
|
||||
class DHTRecordPoolAllocations with _$DHTRecordPoolAllocations {
|
||||
sealed class DHTRecordPoolAllocations with _$DHTRecordPoolAllocations {
|
||||
const factory DHTRecordPoolAllocations({
|
||||
@Default(IMapConst<String, ISet<TypedKey>>({}))
|
||||
IMap<String, ISet<TypedKey>> childrenByParent,
|
||||
|
@ -49,7 +50,7 @@ class DHTRecordPoolAllocations with _$DHTRecordPoolAllocations {
|
|||
/// Pointer to an owned record, with key, owner key and owner secret
|
||||
/// Ensure that these are only serialized encrypted
|
||||
@freezed
|
||||
class OwnedDHTRecordPointer with _$OwnedDHTRecordPointer {
|
||||
sealed class OwnedDHTRecordPointer with _$OwnedDHTRecordPointer {
|
||||
const factory OwnedDHTRecordPointer({
|
||||
required TypedKey recordKey,
|
||||
required KeyPair owner,
|
||||
|
@ -843,8 +844,12 @@ class DHTRecordPool with TableDBBackedJson<DHTRecordPoolAllocations> {
|
|||
log('Timeout in watch cancel for key=$openedRecordKey');
|
||||
} on VeilidAPIException catch (e) {
|
||||
// Failed to cancel DHT watch, try again next tick
|
||||
log('Exception in watch cancel for key=$openedRecordKey: $e');
|
||||
log('VeilidAPIException in watch cancel for key=$openedRecordKey: $e');
|
||||
} catch (e) {
|
||||
log('Unhandled exception in watch cancel for key=$openedRecordKey: $e');
|
||||
rethrow;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -887,7 +892,10 @@ class DHTRecordPool with TableDBBackedJson<DHTRecordPoolAllocations> {
|
|||
log('Timeout in watch update for key=$openedRecordKey');
|
||||
} on VeilidAPIException catch (e) {
|
||||
// Failed to update DHT watch, try again next tick
|
||||
log('Exception in watch update for key=$openedRecordKey: $e');
|
||||
log('VeilidAPIException in watch update for key=$openedRecordKey: $e');
|
||||
} catch (e) {
|
||||
log('Unhandled exception in watch update for key=$openedRecordKey: $e');
|
||||
rethrow;
|
||||
}
|
||||
|
||||
// If we still need a state update after this then do a poll instead
|
||||
|
@ -904,28 +912,29 @@ class DHTRecordPool with TableDBBackedJson<DHTRecordPoolAllocations> {
|
|||
singleFuture((this, _sfPollWatch, openedRecordKey), () async {
|
||||
final dhtctx = openedRecordInfo.shared.defaultRoutingContext;
|
||||
|
||||
// Get single subkey to poll
|
||||
// XXX: veilid api limits this for now until everyone supports
|
||||
// inspectDHTRecord
|
||||
final pollSubkey = unionWatchState.subkeys?.firstSubkey;
|
||||
if (pollSubkey == null) {
|
||||
return;
|
||||
final currentReport = await dhtctx.inspectDHTRecord(openedRecordKey,
|
||||
subkeys: unionWatchState.subkeys, scope: DHTReportScope.syncGet);
|
||||
|
||||
final fsc = currentReport.firstSeqChange;
|
||||
if (fsc == null) {
|
||||
return null;
|
||||
}
|
||||
final pollSubkeys = [ValueSubkeyRange.single(pollSubkey)];
|
||||
final newerSubkeys = currentReport.newerSubkeys;
|
||||
|
||||
final currentReport =
|
||||
await dhtctx.inspectDHTRecord(openedRecordKey, subkeys: pollSubkeys);
|
||||
final currentSeq = currentReport.localSeqs.firstOrNull ?? -1;
|
||||
|
||||
final valueData = await dhtctx.getDHTValue(openedRecordKey, pollSubkey,
|
||||
final valueData = await dhtctx.getDHTValue(openedRecordKey, fsc.subkey,
|
||||
forceRefresh: true);
|
||||
if (valueData == null) {
|
||||
return;
|
||||
}
|
||||
if (valueData.seq > currentSeq) {
|
||||
|
||||
if (valueData.seq < fsc.newSeq) {
|
||||
log('inspect returned a newer seq than get: ${valueData.seq} < $fsc');
|
||||
}
|
||||
|
||||
if (valueData.seq > fsc.oldSeq && valueData.seq != DHTRecord.emptySeq) {
|
||||
processRemoteValueChange(VeilidUpdateValueChange(
|
||||
key: openedRecordKey,
|
||||
subkeys: pollSubkeys,
|
||||
subkeys: newerSubkeys,
|
||||
count: 0xFFFFFFFF,
|
||||
value: valueData));
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// dart format width=80
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
|
@ -9,183 +10,32 @@ part of 'dht_record_pool.dart';
|
|||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
DHTRecordPoolAllocations _$DHTRecordPoolAllocationsFromJson(
|
||||
Map<String, dynamic> json) {
|
||||
return _DHTRecordPoolAllocations.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$DHTRecordPoolAllocations {
|
||||
IMap<String, ISet<Typed<FixedEncodedString43>>> get childrenByParent =>
|
||||
throw _privateConstructorUsedError;
|
||||
IMap<String, Typed<FixedEncodedString43>> get parentByChild =>
|
||||
throw _privateConstructorUsedError;
|
||||
ISet<Typed<FixedEncodedString43>> get rootRecords =>
|
||||
throw _privateConstructorUsedError;
|
||||
IMap<String, String> get debugNames => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this DHTRecordPoolAllocations to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
IMap<String, ISet<TypedKey>> get childrenByParent;
|
||||
IMap<String, TypedKey> get parentByChild;
|
||||
ISet<TypedKey> get rootRecords;
|
||||
IMap<String, String> get debugNames;
|
||||
|
||||
/// Create a copy of DHTRecordPoolAllocations
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$DHTRecordPoolAllocationsCopyWith<DHTRecordPoolAllocations> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
_$DHTRecordPoolAllocationsCopyWithImpl<DHTRecordPoolAllocations>(
|
||||
this as DHTRecordPoolAllocations, _$identity);
|
||||
|
||||
/// @nodoc
|
||||
abstract class $DHTRecordPoolAllocationsCopyWith<$Res> {
|
||||
factory $DHTRecordPoolAllocationsCopyWith(DHTRecordPoolAllocations value,
|
||||
$Res Function(DHTRecordPoolAllocations) then) =
|
||||
_$DHTRecordPoolAllocationsCopyWithImpl<$Res, DHTRecordPoolAllocations>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{IMap<String, ISet<Typed<FixedEncodedString43>>> childrenByParent,
|
||||
IMap<String, Typed<FixedEncodedString43>> parentByChild,
|
||||
ISet<Typed<FixedEncodedString43>> rootRecords,
|
||||
IMap<String, String> debugNames});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$DHTRecordPoolAllocationsCopyWithImpl<$Res,
|
||||
$Val extends DHTRecordPoolAllocations>
|
||||
implements $DHTRecordPoolAllocationsCopyWith<$Res> {
|
||||
_$DHTRecordPoolAllocationsCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of DHTRecordPoolAllocations
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? childrenByParent = null,
|
||||
Object? parentByChild = null,
|
||||
Object? rootRecords = null,
|
||||
Object? debugNames = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
childrenByParent: null == childrenByParent
|
||||
? _value.childrenByParent
|
||||
: childrenByParent // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, ISet<Typed<FixedEncodedString43>>>,
|
||||
parentByChild: null == parentByChild
|
||||
? _value.parentByChild
|
||||
: parentByChild // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, Typed<FixedEncodedString43>>,
|
||||
rootRecords: null == rootRecords
|
||||
? _value.rootRecords
|
||||
: rootRecords // ignore: cast_nullable_to_non_nullable
|
||||
as ISet<Typed<FixedEncodedString43>>,
|
||||
debugNames: null == debugNames
|
||||
? _value.debugNames
|
||||
: debugNames // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, String>,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$DHTRecordPoolAllocationsImplCopyWith<$Res>
|
||||
implements $DHTRecordPoolAllocationsCopyWith<$Res> {
|
||||
factory _$$DHTRecordPoolAllocationsImplCopyWith(
|
||||
_$DHTRecordPoolAllocationsImpl value,
|
||||
$Res Function(_$DHTRecordPoolAllocationsImpl) then) =
|
||||
__$$DHTRecordPoolAllocationsImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{IMap<String, ISet<Typed<FixedEncodedString43>>> childrenByParent,
|
||||
IMap<String, Typed<FixedEncodedString43>> parentByChild,
|
||||
ISet<Typed<FixedEncodedString43>> rootRecords,
|
||||
IMap<String, String> debugNames});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$DHTRecordPoolAllocationsImplCopyWithImpl<$Res>
|
||||
extends _$DHTRecordPoolAllocationsCopyWithImpl<$Res,
|
||||
_$DHTRecordPoolAllocationsImpl>
|
||||
implements _$$DHTRecordPoolAllocationsImplCopyWith<$Res> {
|
||||
__$$DHTRecordPoolAllocationsImplCopyWithImpl(
|
||||
_$DHTRecordPoolAllocationsImpl _value,
|
||||
$Res Function(_$DHTRecordPoolAllocationsImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of DHTRecordPoolAllocations
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? childrenByParent = null,
|
||||
Object? parentByChild = null,
|
||||
Object? rootRecords = null,
|
||||
Object? debugNames = null,
|
||||
}) {
|
||||
return _then(_$DHTRecordPoolAllocationsImpl(
|
||||
childrenByParent: null == childrenByParent
|
||||
? _value.childrenByParent
|
||||
: childrenByParent // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, ISet<Typed<FixedEncodedString43>>>,
|
||||
parentByChild: null == parentByChild
|
||||
? _value.parentByChild
|
||||
: parentByChild // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, Typed<FixedEncodedString43>>,
|
||||
rootRecords: null == rootRecords
|
||||
? _value.rootRecords
|
||||
: rootRecords // ignore: cast_nullable_to_non_nullable
|
||||
as ISet<Typed<FixedEncodedString43>>,
|
||||
debugNames: null == debugNames
|
||||
? _value.debugNames
|
||||
: debugNames // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, String>,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$DHTRecordPoolAllocationsImpl implements _DHTRecordPoolAllocations {
|
||||
const _$DHTRecordPoolAllocationsImpl(
|
||||
{this.childrenByParent = const IMapConst<String, ISet<TypedKey>>({}),
|
||||
this.parentByChild = const IMapConst<String, TypedKey>({}),
|
||||
this.rootRecords = const ISetConst<TypedKey>({}),
|
||||
this.debugNames = const IMapConst<String, String>({})});
|
||||
|
||||
factory _$DHTRecordPoolAllocationsImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$DHTRecordPoolAllocationsImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final IMap<String, ISet<Typed<FixedEncodedString43>>> childrenByParent;
|
||||
@override
|
||||
@JsonKey()
|
||||
final IMap<String, Typed<FixedEncodedString43>> parentByChild;
|
||||
@override
|
||||
@JsonKey()
|
||||
final ISet<Typed<FixedEncodedString43>> rootRecords;
|
||||
@override
|
||||
@JsonKey()
|
||||
final IMap<String, String> debugNames;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DHTRecordPoolAllocations(childrenByParent: $childrenByParent, parentByChild: $parentByChild, rootRecords: $rootRecords, debugNames: $debugNames)';
|
||||
}
|
||||
/// Serializes this DHTRecordPoolAllocations to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$DHTRecordPoolAllocationsImpl &&
|
||||
other is DHTRecordPoolAllocations &&
|
||||
(identical(other.childrenByParent, childrenByParent) ||
|
||||
other.childrenByParent == childrenByParent) &&
|
||||
(identical(other.parentByChild, parentByChild) ||
|
||||
|
@ -201,178 +51,205 @@ class _$DHTRecordPoolAllocationsImpl implements _DHTRecordPoolAllocations {
|
|||
int get hashCode => Object.hash(runtimeType, childrenByParent, parentByChild,
|
||||
const DeepCollectionEquality().hash(rootRecords), debugNames);
|
||||
|
||||
/// Create a copy of DHTRecordPoolAllocations
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$DHTRecordPoolAllocationsImplCopyWith<_$DHTRecordPoolAllocationsImpl>
|
||||
get copyWith => __$$DHTRecordPoolAllocationsImplCopyWithImpl<
|
||||
_$DHTRecordPoolAllocationsImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$DHTRecordPoolAllocationsImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _DHTRecordPoolAllocations implements DHTRecordPoolAllocations {
|
||||
const factory _DHTRecordPoolAllocations(
|
||||
{final IMap<String, ISet<Typed<FixedEncodedString43>>> childrenByParent,
|
||||
final IMap<String, Typed<FixedEncodedString43>> parentByChild,
|
||||
final ISet<Typed<FixedEncodedString43>> rootRecords,
|
||||
final IMap<String, String> debugNames}) = _$DHTRecordPoolAllocationsImpl;
|
||||
|
||||
factory _DHTRecordPoolAllocations.fromJson(Map<String, dynamic> json) =
|
||||
_$DHTRecordPoolAllocationsImpl.fromJson;
|
||||
|
||||
@override
|
||||
IMap<String, ISet<Typed<FixedEncodedString43>>> get childrenByParent;
|
||||
@override
|
||||
IMap<String, Typed<FixedEncodedString43>> get parentByChild;
|
||||
@override
|
||||
ISet<Typed<FixedEncodedString43>> get rootRecords;
|
||||
@override
|
||||
IMap<String, String> get debugNames;
|
||||
|
||||
/// Create a copy of DHTRecordPoolAllocations
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$DHTRecordPoolAllocationsImplCopyWith<_$DHTRecordPoolAllocationsImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
OwnedDHTRecordPointer _$OwnedDHTRecordPointerFromJson(
|
||||
Map<String, dynamic> json) {
|
||||
return _OwnedDHTRecordPointer.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$OwnedDHTRecordPointer {
|
||||
Typed<FixedEncodedString43> get recordKey =>
|
||||
throw _privateConstructorUsedError;
|
||||
KeyPair get owner => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this OwnedDHTRecordPointer to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of OwnedDHTRecordPointer
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$OwnedDHTRecordPointerCopyWith<OwnedDHTRecordPointer> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $OwnedDHTRecordPointerCopyWith<$Res> {
|
||||
factory $OwnedDHTRecordPointerCopyWith(OwnedDHTRecordPointer value,
|
||||
$Res Function(OwnedDHTRecordPointer) then) =
|
||||
_$OwnedDHTRecordPointerCopyWithImpl<$Res, OwnedDHTRecordPointer>;
|
||||
@useResult
|
||||
$Res call({Typed<FixedEncodedString43> recordKey, KeyPair owner});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$OwnedDHTRecordPointerCopyWithImpl<$Res,
|
||||
$Val extends OwnedDHTRecordPointer>
|
||||
implements $OwnedDHTRecordPointerCopyWith<$Res> {
|
||||
_$OwnedDHTRecordPointerCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of OwnedDHTRecordPointer
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? recordKey = null,
|
||||
Object? owner = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
recordKey: null == recordKey
|
||||
? _value.recordKey
|
||||
: recordKey // ignore: cast_nullable_to_non_nullable
|
||||
as Typed<FixedEncodedString43>,
|
||||
owner: null == owner
|
||||
? _value.owner
|
||||
: owner // ignore: cast_nullable_to_non_nullable
|
||||
as KeyPair,
|
||||
) as $Val);
|
||||
String toString() {
|
||||
return 'DHTRecordPoolAllocations(childrenByParent: $childrenByParent, parentByChild: $parentByChild, rootRecords: $rootRecords, debugNames: $debugNames)';
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$OwnedDHTRecordPointerImplCopyWith<$Res>
|
||||
implements $OwnedDHTRecordPointerCopyWith<$Res> {
|
||||
factory _$$OwnedDHTRecordPointerImplCopyWith(
|
||||
_$OwnedDHTRecordPointerImpl value,
|
||||
$Res Function(_$OwnedDHTRecordPointerImpl) then) =
|
||||
__$$OwnedDHTRecordPointerImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
abstract mixin class $DHTRecordPoolAllocationsCopyWith<$Res> {
|
||||
factory $DHTRecordPoolAllocationsCopyWith(DHTRecordPoolAllocations value,
|
||||
$Res Function(DHTRecordPoolAllocations) _then) =
|
||||
_$DHTRecordPoolAllocationsCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({Typed<FixedEncodedString43> recordKey, KeyPair owner});
|
||||
$Res call(
|
||||
{IMap<String, ISet<Typed<FixedEncodedString43>>> childrenByParent,
|
||||
IMap<String, Typed<FixedEncodedString43>> parentByChild,
|
||||
ISet<Typed<FixedEncodedString43>> rootRecords,
|
||||
IMap<String, String> debugNames});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$OwnedDHTRecordPointerImplCopyWithImpl<$Res>
|
||||
extends _$OwnedDHTRecordPointerCopyWithImpl<$Res,
|
||||
_$OwnedDHTRecordPointerImpl>
|
||||
implements _$$OwnedDHTRecordPointerImplCopyWith<$Res> {
|
||||
__$$OwnedDHTRecordPointerImplCopyWithImpl(_$OwnedDHTRecordPointerImpl _value,
|
||||
$Res Function(_$OwnedDHTRecordPointerImpl) _then)
|
||||
: super(_value, _then);
|
||||
class _$DHTRecordPoolAllocationsCopyWithImpl<$Res>
|
||||
implements $DHTRecordPoolAllocationsCopyWith<$Res> {
|
||||
_$DHTRecordPoolAllocationsCopyWithImpl(this._self, this._then);
|
||||
|
||||
/// Create a copy of OwnedDHTRecordPointer
|
||||
final DHTRecordPoolAllocations _self;
|
||||
final $Res Function(DHTRecordPoolAllocations) _then;
|
||||
|
||||
/// Create a copy of DHTRecordPoolAllocations
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? recordKey = null,
|
||||
Object? owner = null,
|
||||
Object? childrenByParent = null,
|
||||
Object? parentByChild = null,
|
||||
Object? rootRecords = null,
|
||||
Object? debugNames = null,
|
||||
}) {
|
||||
return _then(_$OwnedDHTRecordPointerImpl(
|
||||
recordKey: null == recordKey
|
||||
? _value.recordKey
|
||||
: recordKey // ignore: cast_nullable_to_non_nullable
|
||||
as Typed<FixedEncodedString43>,
|
||||
owner: null == owner
|
||||
? _value.owner
|
||||
: owner // ignore: cast_nullable_to_non_nullable
|
||||
as KeyPair,
|
||||
return _then(_self.copyWith(
|
||||
childrenByParent: null == childrenByParent
|
||||
? _self.childrenByParent!
|
||||
: childrenByParent // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, ISet<Typed<FixedEncodedString43>>>,
|
||||
parentByChild: null == parentByChild
|
||||
? _self.parentByChild!
|
||||
: parentByChild // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, Typed<FixedEncodedString43>>,
|
||||
rootRecords: null == rootRecords
|
||||
? _self.rootRecords!
|
||||
: rootRecords // ignore: cast_nullable_to_non_nullable
|
||||
as ISet<Typed<FixedEncodedString43>>,
|
||||
debugNames: null == debugNames
|
||||
? _self.debugNames
|
||||
: debugNames // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, String>,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$OwnedDHTRecordPointerImpl implements _OwnedDHTRecordPointer {
|
||||
const _$OwnedDHTRecordPointerImpl(
|
||||
{required this.recordKey, required this.owner});
|
||||
|
||||
factory _$OwnedDHTRecordPointerImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$OwnedDHTRecordPointerImplFromJson(json);
|
||||
class _DHTRecordPoolAllocations implements DHTRecordPoolAllocations {
|
||||
const _DHTRecordPoolAllocations(
|
||||
{this.childrenByParent = const IMapConst<String, ISet<TypedKey>>({}),
|
||||
this.parentByChild = const IMapConst<String, TypedKey>({}),
|
||||
this.rootRecords = const ISetConst<TypedKey>({}),
|
||||
this.debugNames = const IMapConst<String, String>({})});
|
||||
factory _DHTRecordPoolAllocations.fromJson(Map<String, dynamic> json) =>
|
||||
_$DHTRecordPoolAllocationsFromJson(json);
|
||||
|
||||
@override
|
||||
final Typed<FixedEncodedString43> recordKey;
|
||||
@JsonKey()
|
||||
final IMap<String, ISet<Typed<FixedEncodedString43>>> childrenByParent;
|
||||
@override
|
||||
final KeyPair owner;
|
||||
@JsonKey()
|
||||
final IMap<String, Typed<FixedEncodedString43>> parentByChild;
|
||||
@override
|
||||
@JsonKey()
|
||||
final ISet<Typed<FixedEncodedString43>> rootRecords;
|
||||
@override
|
||||
@JsonKey()
|
||||
final IMap<String, String> debugNames;
|
||||
|
||||
/// Create a copy of DHTRecordPoolAllocations
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$DHTRecordPoolAllocationsCopyWith<_DHTRecordPoolAllocations> get copyWith =>
|
||||
__$DHTRecordPoolAllocationsCopyWithImpl<_DHTRecordPoolAllocations>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OwnedDHTRecordPointer(recordKey: $recordKey, owner: $owner)';
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$DHTRecordPoolAllocationsToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$OwnedDHTRecordPointerImpl &&
|
||||
other is _DHTRecordPoolAllocations &&
|
||||
(identical(other.childrenByParent, childrenByParent) ||
|
||||
other.childrenByParent == childrenByParent) &&
|
||||
(identical(other.parentByChild, parentByChild) ||
|
||||
other.parentByChild == parentByChild) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other.rootRecords, rootRecords) &&
|
||||
(identical(other.debugNames, debugNames) ||
|
||||
other.debugNames == debugNames));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, childrenByParent, parentByChild,
|
||||
const DeepCollectionEquality().hash(rootRecords), debugNames);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DHTRecordPoolAllocations(childrenByParent: $childrenByParent, parentByChild: $parentByChild, rootRecords: $rootRecords, debugNames: $debugNames)';
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$DHTRecordPoolAllocationsCopyWith<$Res>
|
||||
implements $DHTRecordPoolAllocationsCopyWith<$Res> {
|
||||
factory _$DHTRecordPoolAllocationsCopyWith(_DHTRecordPoolAllocations value,
|
||||
$Res Function(_DHTRecordPoolAllocations) _then) =
|
||||
__$DHTRecordPoolAllocationsCopyWithImpl;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{IMap<String, ISet<Typed<FixedEncodedString43>>> childrenByParent,
|
||||
IMap<String, Typed<FixedEncodedString43>> parentByChild,
|
||||
ISet<Typed<FixedEncodedString43>> rootRecords,
|
||||
IMap<String, String> debugNames});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$DHTRecordPoolAllocationsCopyWithImpl<$Res>
|
||||
implements _$DHTRecordPoolAllocationsCopyWith<$Res> {
|
||||
__$DHTRecordPoolAllocationsCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _DHTRecordPoolAllocations _self;
|
||||
final $Res Function(_DHTRecordPoolAllocations) _then;
|
||||
|
||||
/// Create a copy of DHTRecordPoolAllocations
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$Res call({
|
||||
Object? childrenByParent = null,
|
||||
Object? parentByChild = null,
|
||||
Object? rootRecords = null,
|
||||
Object? debugNames = null,
|
||||
}) {
|
||||
return _then(_DHTRecordPoolAllocations(
|
||||
childrenByParent: null == childrenByParent
|
||||
? _self.childrenByParent
|
||||
: childrenByParent // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, ISet<Typed<FixedEncodedString43>>>,
|
||||
parentByChild: null == parentByChild
|
||||
? _self.parentByChild
|
||||
: parentByChild // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, Typed<FixedEncodedString43>>,
|
||||
rootRecords: null == rootRecords
|
||||
? _self.rootRecords
|
||||
: rootRecords // ignore: cast_nullable_to_non_nullable
|
||||
as ISet<Typed<FixedEncodedString43>>,
|
||||
debugNames: null == debugNames
|
||||
? _self.debugNames
|
||||
: debugNames // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, String>,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$OwnedDHTRecordPointer {
|
||||
TypedKey get recordKey;
|
||||
KeyPair get owner;
|
||||
|
||||
/// Create a copy of OwnedDHTRecordPointer
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$OwnedDHTRecordPointerCopyWith<OwnedDHTRecordPointer> get copyWith =>
|
||||
_$OwnedDHTRecordPointerCopyWithImpl<OwnedDHTRecordPointer>(
|
||||
this as OwnedDHTRecordPointer, _$identity);
|
||||
|
||||
/// Serializes this OwnedDHTRecordPointer to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is OwnedDHTRecordPointer &&
|
||||
(identical(other.recordKey, recordKey) ||
|
||||
other.recordKey == recordKey) &&
|
||||
(identical(other.owner, owner) || other.owner == owner));
|
||||
|
@ -382,40 +259,136 @@ class _$OwnedDHTRecordPointerImpl implements _OwnedDHTRecordPointer {
|
|||
@override
|
||||
int get hashCode => Object.hash(runtimeType, recordKey, owner);
|
||||
|
||||
/// Create a copy of OwnedDHTRecordPointer
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$OwnedDHTRecordPointerImplCopyWith<_$OwnedDHTRecordPointerImpl>
|
||||
get copyWith => __$$OwnedDHTRecordPointerImplCopyWithImpl<
|
||||
_$OwnedDHTRecordPointerImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$OwnedDHTRecordPointerImplToJson(
|
||||
this,
|
||||
);
|
||||
String toString() {
|
||||
return 'OwnedDHTRecordPointer(recordKey: $recordKey, owner: $owner)';
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _OwnedDHTRecordPointer implements OwnedDHTRecordPointer {
|
||||
const factory _OwnedDHTRecordPointer(
|
||||
{required final Typed<FixedEncodedString43> recordKey,
|
||||
required final KeyPair owner}) = _$OwnedDHTRecordPointerImpl;
|
||||
/// @nodoc
|
||||
abstract mixin class $OwnedDHTRecordPointerCopyWith<$Res> {
|
||||
factory $OwnedDHTRecordPointerCopyWith(OwnedDHTRecordPointer value,
|
||||
$Res Function(OwnedDHTRecordPointer) _then) =
|
||||
_$OwnedDHTRecordPointerCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({Typed<FixedEncodedString43> recordKey, KeyPair owner});
|
||||
}
|
||||
|
||||
factory _OwnedDHTRecordPointer.fromJson(Map<String, dynamic> json) =
|
||||
_$OwnedDHTRecordPointerImpl.fromJson;
|
||||
/// @nodoc
|
||||
class _$OwnedDHTRecordPointerCopyWithImpl<$Res>
|
||||
implements $OwnedDHTRecordPointerCopyWith<$Res> {
|
||||
_$OwnedDHTRecordPointerCopyWithImpl(this._self, this._then);
|
||||
|
||||
final OwnedDHTRecordPointer _self;
|
||||
final $Res Function(OwnedDHTRecordPointer) _then;
|
||||
|
||||
/// Create a copy of OwnedDHTRecordPointer
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? recordKey = null,
|
||||
Object? owner = null,
|
||||
}) {
|
||||
return _then(_self.copyWith(
|
||||
recordKey: null == recordKey
|
||||
? _self.recordKey!
|
||||
: recordKey // ignore: cast_nullable_to_non_nullable
|
||||
as Typed<FixedEncodedString43>,
|
||||
owner: null == owner
|
||||
? _self.owner
|
||||
: owner // ignore: cast_nullable_to_non_nullable
|
||||
as KeyPair,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _OwnedDHTRecordPointer implements OwnedDHTRecordPointer {
|
||||
const _OwnedDHTRecordPointer({required this.recordKey, required this.owner});
|
||||
factory _OwnedDHTRecordPointer.fromJson(Map<String, dynamic> json) =>
|
||||
_$OwnedDHTRecordPointerFromJson(json);
|
||||
|
||||
@override
|
||||
Typed<FixedEncodedString43> get recordKey;
|
||||
final Typed<FixedEncodedString43> recordKey;
|
||||
@override
|
||||
KeyPair get owner;
|
||||
final KeyPair owner;
|
||||
|
||||
/// Create a copy of OwnedDHTRecordPointer
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$OwnedDHTRecordPointerImplCopyWith<_$OwnedDHTRecordPointerImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
@pragma('vm:prefer-inline')
|
||||
_$OwnedDHTRecordPointerCopyWith<_OwnedDHTRecordPointer> get copyWith =>
|
||||
__$OwnedDHTRecordPointerCopyWithImpl<_OwnedDHTRecordPointer>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$OwnedDHTRecordPointerToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _OwnedDHTRecordPointer &&
|
||||
(identical(other.recordKey, recordKey) ||
|
||||
other.recordKey == recordKey) &&
|
||||
(identical(other.owner, owner) || other.owner == owner));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, recordKey, owner);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OwnedDHTRecordPointer(recordKey: $recordKey, owner: $owner)';
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$OwnedDHTRecordPointerCopyWith<$Res>
|
||||
implements $OwnedDHTRecordPointerCopyWith<$Res> {
|
||||
factory _$OwnedDHTRecordPointerCopyWith(_OwnedDHTRecordPointer value,
|
||||
$Res Function(_OwnedDHTRecordPointer) _then) =
|
||||
__$OwnedDHTRecordPointerCopyWithImpl;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({Typed<FixedEncodedString43> recordKey, KeyPair owner});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$OwnedDHTRecordPointerCopyWithImpl<$Res>
|
||||
implements _$OwnedDHTRecordPointerCopyWith<$Res> {
|
||||
__$OwnedDHTRecordPointerCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _OwnedDHTRecordPointer _self;
|
||||
final $Res Function(_OwnedDHTRecordPointer) _then;
|
||||
|
||||
/// Create a copy of OwnedDHTRecordPointer
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$Res call({
|
||||
Object? recordKey = null,
|
||||
Object? owner = null,
|
||||
}) {
|
||||
return _then(_OwnedDHTRecordPointer(
|
||||
recordKey: null == recordKey
|
||||
? _self.recordKey
|
||||
: recordKey // ignore: cast_nullable_to_non_nullable
|
||||
as Typed<FixedEncodedString43>,
|
||||
owner: null == owner
|
||||
? _self.owner
|
||||
: owner // ignore: cast_nullable_to_non_nullable
|
||||
as KeyPair,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
|
|
|
@ -6,9 +6,9 @@ part of 'dht_record_pool.dart';
|
|||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$DHTRecordPoolAllocationsImpl _$$DHTRecordPoolAllocationsImplFromJson(
|
||||
_DHTRecordPoolAllocations _$DHTRecordPoolAllocationsFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$DHTRecordPoolAllocationsImpl(
|
||||
_DHTRecordPoolAllocations(
|
||||
childrenByParent: json['children_by_parent'] == null
|
||||
? const IMapConst<String, ISet<TypedKey>>({})
|
||||
: IMap<String, ISet<Typed<FixedEncodedString43>>>.fromJson(
|
||||
|
@ -34,8 +34,8 @@ _$DHTRecordPoolAllocationsImpl _$$DHTRecordPoolAllocationsImplFromJson(
|
|||
(value) => value as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$DHTRecordPoolAllocationsImplToJson(
|
||||
_$DHTRecordPoolAllocationsImpl instance) =>
|
||||
Map<String, dynamic> _$DHTRecordPoolAllocationsToJson(
|
||||
_DHTRecordPoolAllocations instance) =>
|
||||
<String, dynamic>{
|
||||
'children_by_parent': instance.childrenByParent.toJson(
|
||||
(value) => value,
|
||||
|
@ -56,15 +56,15 @@ Map<String, dynamic> _$$DHTRecordPoolAllocationsImplToJson(
|
|||
),
|
||||
};
|
||||
|
||||
_$OwnedDHTRecordPointerImpl _$$OwnedDHTRecordPointerImplFromJson(
|
||||
_OwnedDHTRecordPointer _$OwnedDHTRecordPointerFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$OwnedDHTRecordPointerImpl(
|
||||
_OwnedDHTRecordPointer(
|
||||
recordKey: Typed<FixedEncodedString43>.fromJson(json['record_key']),
|
||||
owner: KeyPair.fromJson(json['owner']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$OwnedDHTRecordPointerImplToJson(
|
||||
_$OwnedDHTRecordPointerImpl instance) =>
|
||||
Map<String, dynamic> _$OwnedDHTRecordPointerToJson(
|
||||
_OwnedDHTRecordPointer instance) =>
|
||||
<String, dynamic>{
|
||||
'record_key': instance.recordKey.toJson(),
|
||||
'owner': instance.owner.toJson(),
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
import 'package:veilid/veilid.dart';
|
||||
import 'dht_record_pool.dart';
|
||||
|
||||
class DHTSeqChange {
|
||||
const DHTSeqChange(this.subkey, this.oldSeq, this.newSeq);
|
||||
final int subkey;
|
||||
final int oldSeq;
|
||||
final int newSeq;
|
||||
}
|
||||
|
||||
extension DHTReportReportExt on DHTRecordReport {
|
||||
List<ValueSubkeyRange> get newerSubkeys {
|
||||
if (networkSeqs.isEmpty || localSeqs.isEmpty || subkeys.isEmpty) {
|
||||
return [];
|
||||
}
|
||||
|
||||
final currentSubkeys = <ValueSubkeyRange>[];
|
||||
|
||||
var i = 0;
|
||||
for (final skr in subkeys) {
|
||||
for (var sk = skr.low; sk <= skr.high; sk++) {
|
||||
if (networkSeqs[i] > localSeqs[i] &&
|
||||
networkSeqs[i] != DHTRecord.emptySeq) {
|
||||
if (currentSubkeys.isNotEmpty &&
|
||||
currentSubkeys.last.high == (sk - 1)) {
|
||||
currentSubkeys.add(ValueSubkeyRange(
|
||||
low: currentSubkeys.removeLast().low, high: sk));
|
||||
} else {
|
||||
currentSubkeys.add(ValueSubkeyRange.single(sk));
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return currentSubkeys;
|
||||
}
|
||||
|
||||
DHTSeqChange? get firstSeqChange {
|
||||
if (networkSeqs.isEmpty || localSeqs.isEmpty || subkeys.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
for (final skr in subkeys) {
|
||||
for (var sk = skr.low; sk <= skr.high; sk++) {
|
||||
if (networkSeqs[i] > localSeqs[i] &&
|
||||
networkSeqs[i] != DHTRecord.emptySeq) {
|
||||
return DHTSeqChange(sk, localSeqs[i], networkSeqs[i]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -3,27 +3,14 @@ import 'dart:async';
|
|||
import 'package:async_tools/async_tools.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:bloc_advanced_tools/bloc_advanced_tools.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../../../veilid_support.dart';
|
||||
|
||||
@immutable
|
||||
class DHTShortArrayElementState<T> extends Equatable {
|
||||
const DHTShortArrayElementState(
|
||||
{required this.value, required this.isOffline});
|
||||
final T value;
|
||||
final bool isOffline;
|
||||
typedef DHTShortArrayState<T> = AsyncValue<IList<OnlineElementState<T>>>;
|
||||
typedef DHTShortArrayCubitState<T> = BlocBusyState<DHTShortArrayState<T>>;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [value, isOffline];
|
||||
}
|
||||
|
||||
typedef DHTShortArrayState<T> = AsyncValue<IList<DHTShortArrayElementState<T>>>;
|
||||
typedef DHTShortArrayBusyState<T> = BlocBusyState<DHTShortArrayState<T>>;
|
||||
|
||||
class DHTShortArrayCubit<T> extends Cubit<DHTShortArrayBusyState<T>>
|
||||
class DHTShortArrayCubit<T> extends Cubit<DHTShortArrayCubitState<T>>
|
||||
with BlocBusyWrapper<DHTShortArrayState<T>>, RefreshableCubit {
|
||||
DHTShortArrayCubit({
|
||||
required Future<DHTShortArray> Function() open,
|
||||
|
@ -46,7 +33,7 @@ class DHTShortArrayCubit<T> extends Cubit<DHTShortArrayBusyState<T>>
|
|||
}
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(DHTShortArrayBusyState<T>(AsyncValue.error(e, st)));
|
||||
emit(DHTShortArrayCubitState<T>(AsyncValue.error(e, st)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,7 +70,7 @@ class DHTShortArrayCubit<T> extends Cubit<DHTShortArrayBusyState<T>>
|
|||
// Get the items
|
||||
final allItems = (await reader.getRange(0, forceRefresh: forceRefresh))
|
||||
?.indexed
|
||||
.map((x) => DHTShortArrayElementState(
|
||||
.map((x) => OnlineElementState(
|
||||
value: _decodeElement(x.$2),
|
||||
isOffline: offlinePositions?.contains(x.$1) ?? false))
|
||||
.toIList();
|
||||
|
|
|
@ -333,7 +333,7 @@ class _DHTShortArrayHead {
|
|||
}
|
||||
|
||||
Future<DHTShortArrayHeadLookup> lookupIndex(int idx, bool allowCreate) async {
|
||||
final seq = idx < _seqs.length ? _seqs[idx] : 0xFFFFFFFF;
|
||||
final seq = idx < _seqs.length ? _seqs[idx] : DHTRecord.emptySeq;
|
||||
final recordNumber = idx ~/ _stride;
|
||||
final record = await _getOrCreateLinkedRecord(recordNumber, allowCreate);
|
||||
final recordSubkey = (idx % _stride) + ((recordNumber == 0) ? 1 : 0);
|
||||
|
@ -427,14 +427,14 @@ class _DHTShortArrayHead {
|
|||
|
||||
// If our local sequence number is unknown or hasnt been written yet
|
||||
// then a normal DHT operation is going to pull from the network anyway
|
||||
if (_localSeqs.length < idx || _localSeqs[idx] == 0xFFFFFFFF) {
|
||||
if (_localSeqs.length < idx || _localSeqs[idx] == DHTRecord.emptySeq) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the remote sequence number record is unknown or hasnt been written
|
||||
// at this index yet, then we also do not refresh at this time as it
|
||||
// is the first time the index is being written to
|
||||
if (_seqs.length < idx || _seqs[idx] == 0xFFFFFFFF) {
|
||||
if (_seqs.length < idx || _seqs[idx] == DHTRecord.emptySeq) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -448,12 +448,12 @@ class _DHTShortArrayHead {
|
|||
final idx = _index[pos];
|
||||
|
||||
while (_localSeqs.length <= idx) {
|
||||
_localSeqs.add(0xFFFFFFFF);
|
||||
_localSeqs.add(DHTRecord.emptySeq);
|
||||
}
|
||||
_localSeqs[idx] = newSeq;
|
||||
if (write) {
|
||||
while (_seqs.length <= idx) {
|
||||
_seqs.add(0xFFFFFFFF);
|
||||
_seqs.add(DHTRecord.emptySeq);
|
||||
}
|
||||
_seqs[idx] = newSeq;
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ class _DHTShortArrayWrite extends _DHTShortArrayRead
|
|||
|
||||
final outSeqNum = Output<int>();
|
||||
|
||||
final result = lookup.seq == 0xFFFFFFFF
|
||||
final result = lookup.seq == DHTRecord.emptySeq
|
||||
? null
|
||||
: await lookup.record.get(subkey: lookup.recordSubkey);
|
||||
|
||||
|
@ -151,7 +151,7 @@ class _DHTShortArrayWrite extends _DHTShortArrayRead
|
|||
final lookup = await _head.lookupPosition(pos, true);
|
||||
|
||||
final outSeqNumRead = Output<int>();
|
||||
final oldValue = lookup.seq == 0xFFFFFFFF
|
||||
final oldValue = lookup.seq == DHTRecord.emptySeq
|
||||
? null
|
||||
: await lookup.record
|
||||
.get(subkey: lookup.recordSubkey, outSeqNum: outSeqNumRead);
|
||||
|
|
|
@ -8,7 +8,7 @@ part 'account_record_info.g.dart';
|
|||
/// AccountRecordInfo is the key and owner info for the account dht record that
|
||||
/// is stored in the identity instance record
|
||||
@freezed
|
||||
class AccountRecordInfo with _$AccountRecordInfo {
|
||||
sealed class AccountRecordInfo with _$AccountRecordInfo {
|
||||
const factory AccountRecordInfo({
|
||||
// Top level account keys and secrets
|
||||
required OwnedDHTRecordPointer accountRecord,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// dart format width=80
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
|
@ -9,137 +10,30 @@ part of 'account_record_info.dart';
|
|||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
AccountRecordInfo _$AccountRecordInfoFromJson(Map<String, dynamic> json) {
|
||||
return _AccountRecordInfo.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AccountRecordInfo {
|
||||
// Top level account keys and secrets
|
||||
OwnedDHTRecordPointer get accountRecord => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this AccountRecordInfo to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
OwnedDHTRecordPointer get accountRecord;
|
||||
|
||||
/// Create a copy of AccountRecordInfo
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$AccountRecordInfoCopyWith<AccountRecordInfo> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
_$AccountRecordInfoCopyWithImpl<AccountRecordInfo>(
|
||||
this as AccountRecordInfo, _$identity);
|
||||
|
||||
/// @nodoc
|
||||
abstract class $AccountRecordInfoCopyWith<$Res> {
|
||||
factory $AccountRecordInfoCopyWith(
|
||||
AccountRecordInfo value, $Res Function(AccountRecordInfo) then) =
|
||||
_$AccountRecordInfoCopyWithImpl<$Res, AccountRecordInfo>;
|
||||
@useResult
|
||||
$Res call({OwnedDHTRecordPointer accountRecord});
|
||||
|
||||
$OwnedDHTRecordPointerCopyWith<$Res> get accountRecord;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AccountRecordInfoCopyWithImpl<$Res, $Val extends AccountRecordInfo>
|
||||
implements $AccountRecordInfoCopyWith<$Res> {
|
||||
_$AccountRecordInfoCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of AccountRecordInfo
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? accountRecord = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
accountRecord: null == accountRecord
|
||||
? _value.accountRecord
|
||||
: accountRecord // ignore: cast_nullable_to_non_nullable
|
||||
as OwnedDHTRecordPointer,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
/// Create a copy of AccountRecordInfo
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$OwnedDHTRecordPointerCopyWith<$Res> get accountRecord {
|
||||
return $OwnedDHTRecordPointerCopyWith<$Res>(_value.accountRecord, (value) {
|
||||
return _then(_value.copyWith(accountRecord: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AccountRecordInfoImplCopyWith<$Res>
|
||||
implements $AccountRecordInfoCopyWith<$Res> {
|
||||
factory _$$AccountRecordInfoImplCopyWith(_$AccountRecordInfoImpl value,
|
||||
$Res Function(_$AccountRecordInfoImpl) then) =
|
||||
__$$AccountRecordInfoImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({OwnedDHTRecordPointer accountRecord});
|
||||
|
||||
@override
|
||||
$OwnedDHTRecordPointerCopyWith<$Res> get accountRecord;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AccountRecordInfoImplCopyWithImpl<$Res>
|
||||
extends _$AccountRecordInfoCopyWithImpl<$Res, _$AccountRecordInfoImpl>
|
||||
implements _$$AccountRecordInfoImplCopyWith<$Res> {
|
||||
__$$AccountRecordInfoImplCopyWithImpl(_$AccountRecordInfoImpl _value,
|
||||
$Res Function(_$AccountRecordInfoImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of AccountRecordInfo
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? accountRecord = null,
|
||||
}) {
|
||||
return _then(_$AccountRecordInfoImpl(
|
||||
accountRecord: null == accountRecord
|
||||
? _value.accountRecord
|
||||
: accountRecord // ignore: cast_nullable_to_non_nullable
|
||||
as OwnedDHTRecordPointer,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$AccountRecordInfoImpl implements _AccountRecordInfo {
|
||||
const _$AccountRecordInfoImpl({required this.accountRecord});
|
||||
|
||||
factory _$AccountRecordInfoImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$AccountRecordInfoImplFromJson(json);
|
||||
|
||||
// Top level account keys and secrets
|
||||
@override
|
||||
final OwnedDHTRecordPointer accountRecord;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AccountRecordInfo(accountRecord: $accountRecord)';
|
||||
}
|
||||
/// Serializes this AccountRecordInfo to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AccountRecordInfoImpl &&
|
||||
other is AccountRecordInfo &&
|
||||
(identical(other.accountRecord, accountRecord) ||
|
||||
other.accountRecord == accountRecord));
|
||||
}
|
||||
|
@ -148,39 +42,148 @@ class _$AccountRecordInfoImpl implements _AccountRecordInfo {
|
|||
@override
|
||||
int get hashCode => Object.hash(runtimeType, accountRecord);
|
||||
|
||||
/// Create a copy of AccountRecordInfo
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AccountRecordInfoImplCopyWith<_$AccountRecordInfoImpl> get copyWith =>
|
||||
__$$AccountRecordInfoImplCopyWithImpl<_$AccountRecordInfoImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$AccountRecordInfoImplToJson(
|
||||
this,
|
||||
);
|
||||
String toString() {
|
||||
return 'AccountRecordInfo(accountRecord: $accountRecord)';
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _AccountRecordInfo implements AccountRecordInfo {
|
||||
const factory _AccountRecordInfo(
|
||||
{required final OwnedDHTRecordPointer accountRecord}) =
|
||||
_$AccountRecordInfoImpl;
|
||||
/// @nodoc
|
||||
abstract mixin class $AccountRecordInfoCopyWith<$Res> {
|
||||
factory $AccountRecordInfoCopyWith(
|
||||
AccountRecordInfo value, $Res Function(AccountRecordInfo) _then) =
|
||||
_$AccountRecordInfoCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({OwnedDHTRecordPointer accountRecord});
|
||||
|
||||
factory _AccountRecordInfo.fromJson(Map<String, dynamic> json) =
|
||||
_$AccountRecordInfoImpl.fromJson;
|
||||
$OwnedDHTRecordPointerCopyWith<$Res> get accountRecord;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AccountRecordInfoCopyWithImpl<$Res>
|
||||
implements $AccountRecordInfoCopyWith<$Res> {
|
||||
_$AccountRecordInfoCopyWithImpl(this._self, this._then);
|
||||
|
||||
final AccountRecordInfo _self;
|
||||
final $Res Function(AccountRecordInfo) _then;
|
||||
|
||||
/// Create a copy of AccountRecordInfo
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? accountRecord = null,
|
||||
}) {
|
||||
return _then(_self.copyWith(
|
||||
accountRecord: null == accountRecord
|
||||
? _self.accountRecord
|
||||
: accountRecord // ignore: cast_nullable_to_non_nullable
|
||||
as OwnedDHTRecordPointer,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of AccountRecordInfo
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$OwnedDHTRecordPointerCopyWith<$Res> get accountRecord {
|
||||
return $OwnedDHTRecordPointerCopyWith<$Res>(_self.accountRecord, (value) {
|
||||
return _then(_self.copyWith(accountRecord: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _AccountRecordInfo implements AccountRecordInfo {
|
||||
const _AccountRecordInfo({required this.accountRecord});
|
||||
factory _AccountRecordInfo.fromJson(Map<String, dynamic> json) =>
|
||||
_$AccountRecordInfoFromJson(json);
|
||||
|
||||
// Top level account keys and secrets
|
||||
@override
|
||||
OwnedDHTRecordPointer get accountRecord;
|
||||
final OwnedDHTRecordPointer accountRecord;
|
||||
|
||||
/// Create a copy of AccountRecordInfo
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$AccountRecordInfoImplCopyWith<_$AccountRecordInfoImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
@pragma('vm:prefer-inline')
|
||||
_$AccountRecordInfoCopyWith<_AccountRecordInfo> get copyWith =>
|
||||
__$AccountRecordInfoCopyWithImpl<_AccountRecordInfo>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$AccountRecordInfoToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _AccountRecordInfo &&
|
||||
(identical(other.accountRecord, accountRecord) ||
|
||||
other.accountRecord == accountRecord));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, accountRecord);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AccountRecordInfo(accountRecord: $accountRecord)';
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$AccountRecordInfoCopyWith<$Res>
|
||||
implements $AccountRecordInfoCopyWith<$Res> {
|
||||
factory _$AccountRecordInfoCopyWith(
|
||||
_AccountRecordInfo value, $Res Function(_AccountRecordInfo) _then) =
|
||||
__$AccountRecordInfoCopyWithImpl;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({OwnedDHTRecordPointer accountRecord});
|
||||
|
||||
@override
|
||||
$OwnedDHTRecordPointerCopyWith<$Res> get accountRecord;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$AccountRecordInfoCopyWithImpl<$Res>
|
||||
implements _$AccountRecordInfoCopyWith<$Res> {
|
||||
__$AccountRecordInfoCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _AccountRecordInfo _self;
|
||||
final $Res Function(_AccountRecordInfo) _then;
|
||||
|
||||
/// Create a copy of AccountRecordInfo
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$Res call({
|
||||
Object? accountRecord = null,
|
||||
}) {
|
||||
return _then(_AccountRecordInfo(
|
||||
accountRecord: null == accountRecord
|
||||
? _self.accountRecord
|
||||
: accountRecord // ignore: cast_nullable_to_non_nullable
|
||||
as OwnedDHTRecordPointer,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of AccountRecordInfo
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$OwnedDHTRecordPointerCopyWith<$Res> get accountRecord {
|
||||
return $OwnedDHTRecordPointerCopyWith<$Res>(_self.accountRecord, (value) {
|
||||
return _then(_self.copyWith(accountRecord: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
|
|
|
@ -6,14 +6,12 @@ part of 'account_record_info.dart';
|
|||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$AccountRecordInfoImpl _$$AccountRecordInfoImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$AccountRecordInfoImpl(
|
||||
_AccountRecordInfo _$AccountRecordInfoFromJson(Map<String, dynamic> json) =>
|
||||
_AccountRecordInfo(
|
||||
accountRecord: OwnedDHTRecordPointer.fromJson(json['account_record']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$AccountRecordInfoImplToJson(
|
||||
_$AccountRecordInfoImpl instance) =>
|
||||
Map<String, dynamic> _$AccountRecordInfoToJson(_AccountRecordInfo instance) =>
|
||||
<String, dynamic>{
|
||||
'account_record': instance.accountRecord.toJson(),
|
||||
};
|
||||
|
|
|
@ -14,7 +14,7 @@ part 'identity.g.dart';
|
|||
/// DHT Secret: IdentityInstance Secret Key (stored encrypted with unlock code
|
||||
/// in local table store)
|
||||
@freezed
|
||||
class Identity with _$Identity {
|
||||
sealed class Identity with _$Identity {
|
||||
const factory Identity({
|
||||
// Top level account keys and secrets
|
||||
required IMap<String, ISet<AccountRecordInfo>> accountRecords,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// dart format width=80
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
|
@ -9,122 +10,29 @@ part of 'identity.dart';
|
|||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
Identity _$IdentityFromJson(Map<String, dynamic> json) {
|
||||
return _Identity.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$Identity {
|
||||
// Top level account keys and secrets
|
||||
IMap<String, ISet<AccountRecordInfo>> get accountRecords =>
|
||||
throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this Identity to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
IMap<String, ISet<AccountRecordInfo>> get accountRecords;
|
||||
|
||||
/// Create a copy of Identity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$IdentityCopyWith<Identity> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
_$IdentityCopyWithImpl<Identity>(this as Identity, _$identity);
|
||||
|
||||
/// @nodoc
|
||||
abstract class $IdentityCopyWith<$Res> {
|
||||
factory $IdentityCopyWith(Identity value, $Res Function(Identity) then) =
|
||||
_$IdentityCopyWithImpl<$Res, Identity>;
|
||||
@useResult
|
||||
$Res call({IMap<String, ISet<AccountRecordInfo>> accountRecords});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$IdentityCopyWithImpl<$Res, $Val extends Identity>
|
||||
implements $IdentityCopyWith<$Res> {
|
||||
_$IdentityCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of Identity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? accountRecords = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
accountRecords: null == accountRecords
|
||||
? _value.accountRecords
|
||||
: accountRecords // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, ISet<AccountRecordInfo>>,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$IdentityImplCopyWith<$Res>
|
||||
implements $IdentityCopyWith<$Res> {
|
||||
factory _$$IdentityImplCopyWith(
|
||||
_$IdentityImpl value, $Res Function(_$IdentityImpl) then) =
|
||||
__$$IdentityImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({IMap<String, ISet<AccountRecordInfo>> accountRecords});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$IdentityImplCopyWithImpl<$Res>
|
||||
extends _$IdentityCopyWithImpl<$Res, _$IdentityImpl>
|
||||
implements _$$IdentityImplCopyWith<$Res> {
|
||||
__$$IdentityImplCopyWithImpl(
|
||||
_$IdentityImpl _value, $Res Function(_$IdentityImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of Identity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? accountRecords = null,
|
||||
}) {
|
||||
return _then(_$IdentityImpl(
|
||||
accountRecords: null == accountRecords
|
||||
? _value.accountRecords
|
||||
: accountRecords // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, ISet<AccountRecordInfo>>,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$IdentityImpl implements _Identity {
|
||||
const _$IdentityImpl({required this.accountRecords});
|
||||
|
||||
factory _$IdentityImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$IdentityImplFromJson(json);
|
||||
|
||||
// Top level account keys and secrets
|
||||
@override
|
||||
final IMap<String, ISet<AccountRecordInfo>> accountRecords;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Identity(accountRecords: $accountRecords)';
|
||||
}
|
||||
/// Serializes this Identity to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$IdentityImpl &&
|
||||
other is Identity &&
|
||||
(identical(other.accountRecords, accountRecords) ||
|
||||
other.accountRecords == accountRecords));
|
||||
}
|
||||
|
@ -133,38 +41,119 @@ class _$IdentityImpl implements _Identity {
|
|||
@override
|
||||
int get hashCode => Object.hash(runtimeType, accountRecords);
|
||||
|
||||
/// Create a copy of Identity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$IdentityImplCopyWith<_$IdentityImpl> get copyWith =>
|
||||
__$$IdentityImplCopyWithImpl<_$IdentityImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$IdentityImplToJson(
|
||||
this,
|
||||
);
|
||||
String toString() {
|
||||
return 'Identity(accountRecords: $accountRecords)';
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Identity implements Identity {
|
||||
const factory _Identity(
|
||||
{required final IMap<String, ISet<AccountRecordInfo>>
|
||||
accountRecords}) = _$IdentityImpl;
|
||||
/// @nodoc
|
||||
abstract mixin class $IdentityCopyWith<$Res> {
|
||||
factory $IdentityCopyWith(Identity value, $Res Function(Identity) _then) =
|
||||
_$IdentityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({IMap<String, ISet<AccountRecordInfo>> accountRecords});
|
||||
}
|
||||
|
||||
factory _Identity.fromJson(Map<String, dynamic> json) =
|
||||
_$IdentityImpl.fromJson;
|
||||
/// @nodoc
|
||||
class _$IdentityCopyWithImpl<$Res> implements $IdentityCopyWith<$Res> {
|
||||
_$IdentityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final Identity _self;
|
||||
final $Res Function(Identity) _then;
|
||||
|
||||
/// Create a copy of Identity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? accountRecords = null,
|
||||
}) {
|
||||
return _then(_self.copyWith(
|
||||
accountRecords: null == accountRecords
|
||||
? _self.accountRecords
|
||||
: accountRecords // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, ISet<AccountRecordInfo>>,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _Identity implements Identity {
|
||||
const _Identity({required this.accountRecords});
|
||||
factory _Identity.fromJson(Map<String, dynamic> json) =>
|
||||
_$IdentityFromJson(json);
|
||||
|
||||
// Top level account keys and secrets
|
||||
@override
|
||||
IMap<String, ISet<AccountRecordInfo>> get accountRecords;
|
||||
final IMap<String, ISet<AccountRecordInfo>> accountRecords;
|
||||
|
||||
/// Create a copy of Identity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$IdentityImplCopyWith<_$IdentityImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
@pragma('vm:prefer-inline')
|
||||
_$IdentityCopyWith<_Identity> get copyWith =>
|
||||
__$IdentityCopyWithImpl<_Identity>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$IdentityToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _Identity &&
|
||||
(identical(other.accountRecords, accountRecords) ||
|
||||
other.accountRecords == accountRecords));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, accountRecords);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Identity(accountRecords: $accountRecords)';
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$IdentityCopyWith<$Res>
|
||||
implements $IdentityCopyWith<$Res> {
|
||||
factory _$IdentityCopyWith(_Identity value, $Res Function(_Identity) _then) =
|
||||
__$IdentityCopyWithImpl;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({IMap<String, ISet<AccountRecordInfo>> accountRecords});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$IdentityCopyWithImpl<$Res> implements _$IdentityCopyWith<$Res> {
|
||||
__$IdentityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _Identity _self;
|
||||
final $Res Function(_Identity) _then;
|
||||
|
||||
/// Create a copy of Identity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$Res call({
|
||||
Object? accountRecords = null,
|
||||
}) {
|
||||
return _then(_Identity(
|
||||
accountRecords: null == accountRecords
|
||||
? _self.accountRecords
|
||||
: accountRecords // ignore: cast_nullable_to_non_nullable
|
||||
as IMap<String, ISet<AccountRecordInfo>>,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
|
|
|
@ -6,8 +6,7 @@ part of 'identity.dart';
|
|||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$IdentityImpl _$$IdentityImplFromJson(Map<String, dynamic> json) =>
|
||||
_$IdentityImpl(
|
||||
_Identity _$IdentityFromJson(Map<String, dynamic> json) => _Identity(
|
||||
accountRecords: IMap<String, ISet<AccountRecordInfo>>.fromJson(
|
||||
json['account_records'] as Map<String, dynamic>,
|
||||
(value) => value as String,
|
||||
|
@ -15,8 +14,7 @@ _$IdentityImpl _$$IdentityImplFromJson(Map<String, dynamic> json) =>
|
|||
value, (value) => AccountRecordInfo.fromJson(value))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$IdentityImplToJson(_$IdentityImpl instance) =>
|
||||
<String, dynamic>{
|
||||
Map<String, dynamic> _$IdentityToJson(_Identity instance) => <String, dynamic>{
|
||||
'account_records': instance.accountRecords.toJson(
|
||||
(value) => value,
|
||||
(value) => value.toJson(
|
||||
|
|
|
@ -10,7 +10,7 @@ part 'identity_instance.freezed.dart';
|
|||
part 'identity_instance.g.dart';
|
||||
|
||||
@freezed
|
||||
class IdentityInstance with _$IdentityInstance {
|
||||
sealed class IdentityInstance with _$IdentityInstance {
|
||||
const factory IdentityInstance({
|
||||
// Private DHT record storing identity account mapping
|
||||
required TypedKey recordKey,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// dart format width=80
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
|
@ -9,112 +10,76 @@ part of 'identity_instance.dart';
|
|||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
IdentityInstance _$IdentityInstanceFromJson(Map<String, dynamic> json) {
|
||||
return _IdentityInstance.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$IdentityInstance {
|
||||
// Private DHT record storing identity account mapping
|
||||
Typed<FixedEncodedString43> get recordKey =>
|
||||
throw _privateConstructorUsedError; // Public key of identity instance
|
||||
FixedEncodedString43 get publicKey =>
|
||||
throw _privateConstructorUsedError; // Secret key of identity instance
|
||||
TypedKey get recordKey; // Public key of identity instance
|
||||
PublicKey get publicKey; // Secret key of identity instance
|
||||
// Encrypted with appended salt, key is DeriveSharedSecret(
|
||||
// password = SuperIdentity.secret,
|
||||
// salt = publicKey)
|
||||
// Used to recover accounts without generating a new instance
|
||||
@Uint8ListJsonConverter()
|
||||
Uint8List get encryptedSecretKey =>
|
||||
throw _privateConstructorUsedError; // Signature of SuperInstance recordKey and SuperInstance publicKey
|
||||
Uint8List
|
||||
get encryptedSecretKey; // Signature of SuperInstance recordKey and SuperInstance publicKey
|
||||
// by publicKey
|
||||
FixedEncodedString86 get superSignature =>
|
||||
throw _privateConstructorUsedError; // Signature of recordKey, publicKey, encryptedSecretKey, and superSignature
|
||||
Signature
|
||||
get superSignature; // Signature of recordKey, publicKey, encryptedSecretKey, and superSignature
|
||||
// by SuperIdentity publicKey
|
||||
FixedEncodedString86 get signature => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this IdentityInstance to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
Signature get signature;
|
||||
|
||||
/// Create a copy of IdentityInstance
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$IdentityInstanceCopyWith<IdentityInstance> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $IdentityInstanceCopyWith<$Res> {
|
||||
factory $IdentityInstanceCopyWith(
|
||||
IdentityInstance value, $Res Function(IdentityInstance) then) =
|
||||
_$IdentityInstanceCopyWithImpl<$Res, IdentityInstance>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{Typed<FixedEncodedString43> recordKey,
|
||||
FixedEncodedString43 publicKey,
|
||||
@Uint8ListJsonConverter() Uint8List encryptedSecretKey,
|
||||
FixedEncodedString86 superSignature,
|
||||
FixedEncodedString86 signature});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$IdentityInstanceCopyWithImpl<$Res, $Val extends IdentityInstance>
|
||||
implements $IdentityInstanceCopyWith<$Res> {
|
||||
_$IdentityInstanceCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of IdentityInstance
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
$IdentityInstanceCopyWith<IdentityInstance> get copyWith =>
|
||||
_$IdentityInstanceCopyWithImpl<IdentityInstance>(
|
||||
this as IdentityInstance, _$identity);
|
||||
|
||||
/// Serializes this IdentityInstance to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
@override
|
||||
$Res call({
|
||||
Object? recordKey = null,
|
||||
Object? publicKey = null,
|
||||
Object? encryptedSecretKey = null,
|
||||
Object? superSignature = null,
|
||||
Object? signature = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
recordKey: null == recordKey
|
||||
? _value.recordKey
|
||||
: recordKey // ignore: cast_nullable_to_non_nullable
|
||||
as Typed<FixedEncodedString43>,
|
||||
publicKey: null == publicKey
|
||||
? _value.publicKey
|
||||
: publicKey // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString43,
|
||||
encryptedSecretKey: null == encryptedSecretKey
|
||||
? _value.encryptedSecretKey
|
||||
: encryptedSecretKey // ignore: cast_nullable_to_non_nullable
|
||||
as Uint8List,
|
||||
superSignature: null == superSignature
|
||||
? _value.superSignature
|
||||
: superSignature // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString86,
|
||||
signature: null == signature
|
||||
? _value.signature
|
||||
: signature // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString86,
|
||||
) as $Val);
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is IdentityInstance &&
|
||||
(identical(other.recordKey, recordKey) ||
|
||||
other.recordKey == recordKey) &&
|
||||
(identical(other.publicKey, publicKey) ||
|
||||
other.publicKey == publicKey) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other.encryptedSecretKey, encryptedSecretKey) &&
|
||||
(identical(other.superSignature, superSignature) ||
|
||||
other.superSignature == superSignature) &&
|
||||
(identical(other.signature, signature) ||
|
||||
other.signature == signature));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
recordKey,
|
||||
publicKey,
|
||||
const DeepCollectionEquality().hash(encryptedSecretKey),
|
||||
superSignature,
|
||||
signature);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'IdentityInstance(recordKey: $recordKey, publicKey: $publicKey, encryptedSecretKey: $encryptedSecretKey, superSignature: $superSignature, signature: $signature)';
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$IdentityInstanceImplCopyWith<$Res>
|
||||
implements $IdentityInstanceCopyWith<$Res> {
|
||||
factory _$$IdentityInstanceImplCopyWith(_$IdentityInstanceImpl value,
|
||||
$Res Function(_$IdentityInstanceImpl) then) =
|
||||
__$$IdentityInstanceImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
abstract mixin class $IdentityInstanceCopyWith<$Res> {
|
||||
factory $IdentityInstanceCopyWith(
|
||||
IdentityInstance value, $Res Function(IdentityInstance) _then) =
|
||||
_$IdentityInstanceCopyWithImpl;
|
||||
@useResult
|
||||
$Res call(
|
||||
{Typed<FixedEncodedString43> recordKey,
|
||||
|
@ -125,12 +90,12 @@ abstract class _$$IdentityInstanceImplCopyWith<$Res>
|
|||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$IdentityInstanceImplCopyWithImpl<$Res>
|
||||
extends _$IdentityInstanceCopyWithImpl<$Res, _$IdentityInstanceImpl>
|
||||
implements _$$IdentityInstanceImplCopyWith<$Res> {
|
||||
__$$IdentityInstanceImplCopyWithImpl(_$IdentityInstanceImpl _value,
|
||||
$Res Function(_$IdentityInstanceImpl) _then)
|
||||
: super(_value, _then);
|
||||
class _$IdentityInstanceCopyWithImpl<$Res>
|
||||
implements $IdentityInstanceCopyWith<$Res> {
|
||||
_$IdentityInstanceCopyWithImpl(this._self, this._then);
|
||||
|
||||
final IdentityInstance _self;
|
||||
final $Res Function(IdentityInstance) _then;
|
||||
|
||||
/// Create a copy of IdentityInstance
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
|
@ -143,25 +108,25 @@ class __$$IdentityInstanceImplCopyWithImpl<$Res>
|
|||
Object? superSignature = null,
|
||||
Object? signature = null,
|
||||
}) {
|
||||
return _then(_$IdentityInstanceImpl(
|
||||
return _then(_self.copyWith(
|
||||
recordKey: null == recordKey
|
||||
? _value.recordKey
|
||||
? _self.recordKey!
|
||||
: recordKey // ignore: cast_nullable_to_non_nullable
|
||||
as Typed<FixedEncodedString43>,
|
||||
publicKey: null == publicKey
|
||||
? _value.publicKey
|
||||
? _self.publicKey!
|
||||
: publicKey // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString43,
|
||||
encryptedSecretKey: null == encryptedSecretKey
|
||||
? _value.encryptedSecretKey
|
||||
? _self.encryptedSecretKey
|
||||
: encryptedSecretKey // ignore: cast_nullable_to_non_nullable
|
||||
as Uint8List,
|
||||
superSignature: null == superSignature
|
||||
? _value.superSignature
|
||||
? _self.superSignature!
|
||||
: superSignature // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString86,
|
||||
signature: null == signature
|
||||
? _value.signature
|
||||
? _self.signature!
|
||||
: signature // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString86,
|
||||
));
|
||||
|
@ -170,17 +135,16 @@ class __$$IdentityInstanceImplCopyWithImpl<$Res>
|
|||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$IdentityInstanceImpl extends _IdentityInstance {
|
||||
const _$IdentityInstanceImpl(
|
||||
class _IdentityInstance extends IdentityInstance {
|
||||
const _IdentityInstance(
|
||||
{required this.recordKey,
|
||||
required this.publicKey,
|
||||
@Uint8ListJsonConverter() required this.encryptedSecretKey,
|
||||
required this.superSignature,
|
||||
required this.signature})
|
||||
: super._();
|
||||
|
||||
factory _$IdentityInstanceImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$IdentityInstanceImplFromJson(json);
|
||||
factory _IdentityInstance.fromJson(Map<String, dynamic> json) =>
|
||||
_$IdentityInstanceFromJson(json);
|
||||
|
||||
// Private DHT record storing identity account mapping
|
||||
@override
|
||||
|
@ -205,16 +169,26 @@ class _$IdentityInstanceImpl extends _IdentityInstance {
|
|||
@override
|
||||
final FixedEncodedString86 signature;
|
||||
|
||||
/// Create a copy of IdentityInstance
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
String toString() {
|
||||
return 'IdentityInstance(recordKey: $recordKey, publicKey: $publicKey, encryptedSecretKey: $encryptedSecretKey, superSignature: $superSignature, signature: $signature)';
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$IdentityInstanceCopyWith<_IdentityInstance> get copyWith =>
|
||||
__$IdentityInstanceCopyWithImpl<_IdentityInstance>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$IdentityInstanceToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$IdentityInstanceImpl &&
|
||||
other is _IdentityInstance &&
|
||||
(identical(other.recordKey, recordKey) ||
|
||||
other.recordKey == recordKey) &&
|
||||
(identical(other.publicKey, publicKey) ||
|
||||
|
@ -237,60 +211,70 @@ class _$IdentityInstanceImpl extends _IdentityInstance {
|
|||
superSignature,
|
||||
signature);
|
||||
|
||||
/// Create a copy of IdentityInstance
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$IdentityInstanceImplCopyWith<_$IdentityInstanceImpl> get copyWith =>
|
||||
__$$IdentityInstanceImplCopyWithImpl<_$IdentityInstanceImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$IdentityInstanceImplToJson(
|
||||
this,
|
||||
);
|
||||
String toString() {
|
||||
return 'IdentityInstance(recordKey: $recordKey, publicKey: $publicKey, encryptedSecretKey: $encryptedSecretKey, superSignature: $superSignature, signature: $signature)';
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _IdentityInstance extends IdentityInstance {
|
||||
const factory _IdentityInstance(
|
||||
{required final Typed<FixedEncodedString43> recordKey,
|
||||
required final FixedEncodedString43 publicKey,
|
||||
@Uint8ListJsonConverter() required final Uint8List encryptedSecretKey,
|
||||
required final FixedEncodedString86 superSignature,
|
||||
required final FixedEncodedString86 signature}) = _$IdentityInstanceImpl;
|
||||
const _IdentityInstance._() : super._();
|
||||
/// @nodoc
|
||||
abstract mixin class _$IdentityInstanceCopyWith<$Res>
|
||||
implements $IdentityInstanceCopyWith<$Res> {
|
||||
factory _$IdentityInstanceCopyWith(
|
||||
_IdentityInstance value, $Res Function(_IdentityInstance) _then) =
|
||||
__$IdentityInstanceCopyWithImpl;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{Typed<FixedEncodedString43> recordKey,
|
||||
FixedEncodedString43 publicKey,
|
||||
@Uint8ListJsonConverter() Uint8List encryptedSecretKey,
|
||||
FixedEncodedString86 superSignature,
|
||||
FixedEncodedString86 signature});
|
||||
}
|
||||
|
||||
factory _IdentityInstance.fromJson(Map<String, dynamic> json) =
|
||||
_$IdentityInstanceImpl.fromJson;
|
||||
/// @nodoc
|
||||
class __$IdentityInstanceCopyWithImpl<$Res>
|
||||
implements _$IdentityInstanceCopyWith<$Res> {
|
||||
__$IdentityInstanceCopyWithImpl(this._self, this._then);
|
||||
|
||||
// Private DHT record storing identity account mapping
|
||||
@override
|
||||
Typed<FixedEncodedString43> get recordKey; // Public key of identity instance
|
||||
@override
|
||||
FixedEncodedString43 get publicKey; // Secret key of identity instance
|
||||
// Encrypted with appended salt, key is DeriveSharedSecret(
|
||||
// password = SuperIdentity.secret,
|
||||
// salt = publicKey)
|
||||
// Used to recover accounts without generating a new instance
|
||||
@override
|
||||
@Uint8ListJsonConverter()
|
||||
Uint8List
|
||||
get encryptedSecretKey; // Signature of SuperInstance recordKey and SuperInstance publicKey
|
||||
// by publicKey
|
||||
@override
|
||||
FixedEncodedString86
|
||||
get superSignature; // Signature of recordKey, publicKey, encryptedSecretKey, and superSignature
|
||||
// by SuperIdentity publicKey
|
||||
@override
|
||||
FixedEncodedString86 get signature;
|
||||
final _IdentityInstance _self;
|
||||
final $Res Function(_IdentityInstance) _then;
|
||||
|
||||
/// Create a copy of IdentityInstance
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$IdentityInstanceImplCopyWith<_$IdentityInstanceImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
@pragma('vm:prefer-inline')
|
||||
$Res call({
|
||||
Object? recordKey = null,
|
||||
Object? publicKey = null,
|
||||
Object? encryptedSecretKey = null,
|
||||
Object? superSignature = null,
|
||||
Object? signature = null,
|
||||
}) {
|
||||
return _then(_IdentityInstance(
|
||||
recordKey: null == recordKey
|
||||
? _self.recordKey
|
||||
: recordKey // ignore: cast_nullable_to_non_nullable
|
||||
as Typed<FixedEncodedString43>,
|
||||
publicKey: null == publicKey
|
||||
? _self.publicKey
|
||||
: publicKey // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString43,
|
||||
encryptedSecretKey: null == encryptedSecretKey
|
||||
? _self.encryptedSecretKey
|
||||
: encryptedSecretKey // ignore: cast_nullable_to_non_nullable
|
||||
as Uint8List,
|
||||
superSignature: null == superSignature
|
||||
? _self.superSignature
|
||||
: superSignature // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString86,
|
||||
signature: null == signature
|
||||
? _self.signature
|
||||
: signature // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString86,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
|
|
|
@ -6,9 +6,8 @@ part of 'identity_instance.dart';
|
|||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$IdentityInstanceImpl _$$IdentityInstanceImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$IdentityInstanceImpl(
|
||||
_IdentityInstance _$IdentityInstanceFromJson(Map<String, dynamic> json) =>
|
||||
_IdentityInstance(
|
||||
recordKey: Typed<FixedEncodedString43>.fromJson(json['record_key']),
|
||||
publicKey: FixedEncodedString43.fromJson(json['public_key']),
|
||||
encryptedSecretKey:
|
||||
|
@ -17,8 +16,7 @@ _$IdentityInstanceImpl _$$IdentityInstanceImplFromJson(
|
|||
signature: FixedEncodedString86.fromJson(json['signature']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$IdentityInstanceImplToJson(
|
||||
_$IdentityInstanceImpl instance) =>
|
||||
Map<String, dynamic> _$IdentityInstanceToJson(_IdentityInstance instance) =>
|
||||
<String, dynamic>{
|
||||
'record_key': instance.recordKey.toJson(),
|
||||
'public_key': instance.publicKey.toJson(),
|
||||
|
|
|
@ -22,7 +22,7 @@ part 'super_identity.g.dart';
|
|||
/// DHT Owner Secret: SuperIdentity Secret Key (kept offline)
|
||||
/// Encryption: None
|
||||
@freezed
|
||||
class SuperIdentity with _$SuperIdentity {
|
||||
sealed class SuperIdentity with _$SuperIdentity {
|
||||
const factory SuperIdentity({
|
||||
/// Public DHT record storing this structure for account recovery
|
||||
/// changing this can migrate/forward the SuperIdentity to a new DHT record
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// dart format width=80
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
|
@ -9,65 +10,93 @@ part of 'super_identity.dart';
|
|||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
SuperIdentity _$SuperIdentityFromJson(Map<String, dynamic> json) {
|
||||
return _SuperIdentity.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$SuperIdentity {
|
||||
/// Public DHT record storing this structure for account recovery
|
||||
/// changing this can migrate/forward the SuperIdentity to a new DHT record
|
||||
/// Instances should not hash this recordKey, rather the actual record
|
||||
/// key used to store the superIdentity, as this may change.
|
||||
Typed<FixedEncodedString43> get recordKey =>
|
||||
throw _privateConstructorUsedError;
|
||||
TypedKey get recordKey;
|
||||
|
||||
/// Public key of the SuperIdentity used to sign identity keys for recovery
|
||||
/// This must match the owner of the superRecord DHT record and can not be
|
||||
/// changed without changing the record
|
||||
FixedEncodedString43 get publicKey => throw _privateConstructorUsedError;
|
||||
PublicKey get publicKey;
|
||||
|
||||
/// Current identity instance
|
||||
/// The most recently generated identity instance for this SuperIdentity
|
||||
IdentityInstance get currentInstance => throw _privateConstructorUsedError;
|
||||
IdentityInstance get currentInstance;
|
||||
|
||||
/// Deprecated identity instances
|
||||
/// These may be compromised and should not be considered valid for
|
||||
/// new signatures, but may be used to validate old signatures
|
||||
List<IdentityInstance> get deprecatedInstances =>
|
||||
throw _privateConstructorUsedError;
|
||||
List<IdentityInstance> get deprecatedInstances;
|
||||
|
||||
/// Deprecated superRecords
|
||||
/// These may be compromised and should not be considered valid for
|
||||
/// new signatures, but may be used to validate old signatures
|
||||
List<Typed<FixedEncodedString43>> get deprecatedSuperRecordKeys =>
|
||||
throw _privateConstructorUsedError;
|
||||
List<TypedKey> get deprecatedSuperRecordKeys;
|
||||
|
||||
/// Signature of recordKey, currentInstance signature,
|
||||
/// signatures of deprecatedInstances, and deprecatedSuperRecordKeys
|
||||
/// by publicKey
|
||||
FixedEncodedString86 get signature => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this SuperIdentity to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
Signature get signature;
|
||||
|
||||
/// Create a copy of SuperIdentity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$SuperIdentityCopyWith<SuperIdentity> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
_$SuperIdentityCopyWithImpl<SuperIdentity>(
|
||||
this as SuperIdentity, _$identity);
|
||||
|
||||
/// Serializes this SuperIdentity to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is SuperIdentity &&
|
||||
(identical(other.recordKey, recordKey) ||
|
||||
other.recordKey == recordKey) &&
|
||||
(identical(other.publicKey, publicKey) ||
|
||||
other.publicKey == publicKey) &&
|
||||
(identical(other.currentInstance, currentInstance) ||
|
||||
other.currentInstance == currentInstance) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other.deprecatedInstances, deprecatedInstances) &&
|
||||
const DeepCollectionEquality().equals(
|
||||
other.deprecatedSuperRecordKeys, deprecatedSuperRecordKeys) &&
|
||||
(identical(other.signature, signature) ||
|
||||
other.signature == signature));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
recordKey,
|
||||
publicKey,
|
||||
currentInstance,
|
||||
const DeepCollectionEquality().hash(deprecatedInstances),
|
||||
const DeepCollectionEquality().hash(deprecatedSuperRecordKeys),
|
||||
signature);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SuperIdentity(recordKey: $recordKey, publicKey: $publicKey, currentInstance: $currentInstance, deprecatedInstances: $deprecatedInstances, deprecatedSuperRecordKeys: $deprecatedSuperRecordKeys, signature: $signature)';
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $SuperIdentityCopyWith<$Res> {
|
||||
abstract mixin class $SuperIdentityCopyWith<$Res> {
|
||||
factory $SuperIdentityCopyWith(
|
||||
SuperIdentity value, $Res Function(SuperIdentity) then) =
|
||||
_$SuperIdentityCopyWithImpl<$Res, SuperIdentity>;
|
||||
SuperIdentity value, $Res Function(SuperIdentity) _then) =
|
||||
_$SuperIdentityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call(
|
||||
{Typed<FixedEncodedString43> recordKey,
|
||||
|
@ -81,14 +110,12 @@ abstract class $SuperIdentityCopyWith<$Res> {
|
|||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$SuperIdentityCopyWithImpl<$Res, $Val extends SuperIdentity>
|
||||
class _$SuperIdentityCopyWithImpl<$Res>
|
||||
implements $SuperIdentityCopyWith<$Res> {
|
||||
_$SuperIdentityCopyWithImpl(this._value, this._then);
|
||||
_$SuperIdentityCopyWithImpl(this._self, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
final SuperIdentity _self;
|
||||
final $Res Function(SuperIdentity) _then;
|
||||
|
||||
/// Create a copy of SuperIdentity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
|
@ -102,32 +129,32 @@ class _$SuperIdentityCopyWithImpl<$Res, $Val extends SuperIdentity>
|
|||
Object? deprecatedSuperRecordKeys = null,
|
||||
Object? signature = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
return _then(_self.copyWith(
|
||||
recordKey: null == recordKey
|
||||
? _value.recordKey
|
||||
? _self.recordKey!
|
||||
: recordKey // ignore: cast_nullable_to_non_nullable
|
||||
as Typed<FixedEncodedString43>,
|
||||
publicKey: null == publicKey
|
||||
? _value.publicKey
|
||||
? _self.publicKey!
|
||||
: publicKey // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString43,
|
||||
currentInstance: null == currentInstance
|
||||
? _value.currentInstance
|
||||
? _self.currentInstance
|
||||
: currentInstance // ignore: cast_nullable_to_non_nullable
|
||||
as IdentityInstance,
|
||||
deprecatedInstances: null == deprecatedInstances
|
||||
? _value.deprecatedInstances
|
||||
? _self.deprecatedInstances
|
||||
: deprecatedInstances // ignore: cast_nullable_to_non_nullable
|
||||
as List<IdentityInstance>,
|
||||
deprecatedSuperRecordKeys: null == deprecatedSuperRecordKeys
|
||||
? _value.deprecatedSuperRecordKeys
|
||||
? _self.deprecatedSuperRecordKeys!
|
||||
: deprecatedSuperRecordKeys // ignore: cast_nullable_to_non_nullable
|
||||
as List<Typed<FixedEncodedString43>>,
|
||||
signature: null == signature
|
||||
? _value.signature
|
||||
? _self.signature!
|
||||
: signature // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString86,
|
||||
) as $Val);
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of SuperIdentity
|
||||
|
@ -135,85 +162,16 @@ class _$SuperIdentityCopyWithImpl<$Res, $Val extends SuperIdentity>
|
|||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$IdentityInstanceCopyWith<$Res> get currentInstance {
|
||||
return $IdentityInstanceCopyWith<$Res>(_value.currentInstance, (value) {
|
||||
return _then(_value.copyWith(currentInstance: value) as $Val);
|
||||
return $IdentityInstanceCopyWith<$Res>(_self.currentInstance, (value) {
|
||||
return _then(_self.copyWith(currentInstance: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SuperIdentityImplCopyWith<$Res>
|
||||
implements $SuperIdentityCopyWith<$Res> {
|
||||
factory _$$SuperIdentityImplCopyWith(
|
||||
_$SuperIdentityImpl value, $Res Function(_$SuperIdentityImpl) then) =
|
||||
__$$SuperIdentityImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{Typed<FixedEncodedString43> recordKey,
|
||||
FixedEncodedString43 publicKey,
|
||||
IdentityInstance currentInstance,
|
||||
List<IdentityInstance> deprecatedInstances,
|
||||
List<Typed<FixedEncodedString43>> deprecatedSuperRecordKeys,
|
||||
FixedEncodedString86 signature});
|
||||
|
||||
@override
|
||||
$IdentityInstanceCopyWith<$Res> get currentInstance;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SuperIdentityImplCopyWithImpl<$Res>
|
||||
extends _$SuperIdentityCopyWithImpl<$Res, _$SuperIdentityImpl>
|
||||
implements _$$SuperIdentityImplCopyWith<$Res> {
|
||||
__$$SuperIdentityImplCopyWithImpl(
|
||||
_$SuperIdentityImpl _value, $Res Function(_$SuperIdentityImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of SuperIdentity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? recordKey = null,
|
||||
Object? publicKey = null,
|
||||
Object? currentInstance = null,
|
||||
Object? deprecatedInstances = null,
|
||||
Object? deprecatedSuperRecordKeys = null,
|
||||
Object? signature = null,
|
||||
}) {
|
||||
return _then(_$SuperIdentityImpl(
|
||||
recordKey: null == recordKey
|
||||
? _value.recordKey
|
||||
: recordKey // ignore: cast_nullable_to_non_nullable
|
||||
as Typed<FixedEncodedString43>,
|
||||
publicKey: null == publicKey
|
||||
? _value.publicKey
|
||||
: publicKey // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString43,
|
||||
currentInstance: null == currentInstance
|
||||
? _value.currentInstance
|
||||
: currentInstance // ignore: cast_nullable_to_non_nullable
|
||||
as IdentityInstance,
|
||||
deprecatedInstances: null == deprecatedInstances
|
||||
? _value._deprecatedInstances
|
||||
: deprecatedInstances // ignore: cast_nullable_to_non_nullable
|
||||
as List<IdentityInstance>,
|
||||
deprecatedSuperRecordKeys: null == deprecatedSuperRecordKeys
|
||||
? _value._deprecatedSuperRecordKeys
|
||||
: deprecatedSuperRecordKeys // ignore: cast_nullable_to_non_nullable
|
||||
as List<Typed<FixedEncodedString43>>,
|
||||
signature: null == signature
|
||||
? _value.signature
|
||||
: signature // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString86,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$SuperIdentityImpl extends _SuperIdentity {
|
||||
const _$SuperIdentityImpl(
|
||||
class _SuperIdentity extends SuperIdentity {
|
||||
const _SuperIdentity(
|
||||
{required this.recordKey,
|
||||
required this.publicKey,
|
||||
required this.currentInstance,
|
||||
|
@ -224,9 +182,8 @@ class _$SuperIdentityImpl extends _SuperIdentity {
|
|||
: _deprecatedInstances = deprecatedInstances,
|
||||
_deprecatedSuperRecordKeys = deprecatedSuperRecordKeys,
|
||||
super._();
|
||||
|
||||
factory _$SuperIdentityImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$SuperIdentityImplFromJson(json);
|
||||
factory _SuperIdentity.fromJson(Map<String, dynamic> json) =>
|
||||
_$SuperIdentityFromJson(json);
|
||||
|
||||
/// Public DHT record storing this structure for account recovery
|
||||
/// changing this can migrate/forward the SuperIdentity to a new DHT record
|
||||
|
@ -284,16 +241,26 @@ class _$SuperIdentityImpl extends _SuperIdentity {
|
|||
@override
|
||||
final FixedEncodedString86 signature;
|
||||
|
||||
/// Create a copy of SuperIdentity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
String toString() {
|
||||
return 'SuperIdentity(recordKey: $recordKey, publicKey: $publicKey, currentInstance: $currentInstance, deprecatedInstances: $deprecatedInstances, deprecatedSuperRecordKeys: $deprecatedSuperRecordKeys, signature: $signature)';
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$SuperIdentityCopyWith<_SuperIdentity> get copyWith =>
|
||||
__$SuperIdentityCopyWithImpl<_SuperIdentity>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$SuperIdentityToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SuperIdentityImpl &&
|
||||
other is _SuperIdentity &&
|
||||
(identical(other.recordKey, recordKey) ||
|
||||
other.recordKey == recordKey) &&
|
||||
(identical(other.publicKey, publicKey) ||
|
||||
|
@ -319,76 +286,89 @@ class _$SuperIdentityImpl extends _SuperIdentity {
|
|||
const DeepCollectionEquality().hash(_deprecatedSuperRecordKeys),
|
||||
signature);
|
||||
|
||||
/// Create a copy of SuperIdentity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SuperIdentityImplCopyWith<_$SuperIdentityImpl> get copyWith =>
|
||||
__$$SuperIdentityImplCopyWithImpl<_$SuperIdentityImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$SuperIdentityImplToJson(
|
||||
this,
|
||||
);
|
||||
String toString() {
|
||||
return 'SuperIdentity(recordKey: $recordKey, publicKey: $publicKey, currentInstance: $currentInstance, deprecatedInstances: $deprecatedInstances, deprecatedSuperRecordKeys: $deprecatedSuperRecordKeys, signature: $signature)';
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _SuperIdentity extends SuperIdentity {
|
||||
const factory _SuperIdentity(
|
||||
{required final Typed<FixedEncodedString43> recordKey,
|
||||
required final FixedEncodedString43 publicKey,
|
||||
required final IdentityInstance currentInstance,
|
||||
required final List<IdentityInstance> deprecatedInstances,
|
||||
required final List<Typed<FixedEncodedString43>>
|
||||
deprecatedSuperRecordKeys,
|
||||
required final FixedEncodedString86 signature}) = _$SuperIdentityImpl;
|
||||
const _SuperIdentity._() : super._();
|
||||
|
||||
factory _SuperIdentity.fromJson(Map<String, dynamic> json) =
|
||||
_$SuperIdentityImpl.fromJson;
|
||||
|
||||
/// Public DHT record storing this structure for account recovery
|
||||
/// changing this can migrate/forward the SuperIdentity to a new DHT record
|
||||
/// Instances should not hash this recordKey, rather the actual record
|
||||
/// key used to store the superIdentity, as this may change.
|
||||
/// @nodoc
|
||||
abstract mixin class _$SuperIdentityCopyWith<$Res>
|
||||
implements $SuperIdentityCopyWith<$Res> {
|
||||
factory _$SuperIdentityCopyWith(
|
||||
_SuperIdentity value, $Res Function(_SuperIdentity) _then) =
|
||||
__$SuperIdentityCopyWithImpl;
|
||||
@override
|
||||
Typed<FixedEncodedString43> get recordKey;
|
||||
@useResult
|
||||
$Res call(
|
||||
{Typed<FixedEncodedString43> recordKey,
|
||||
FixedEncodedString43 publicKey,
|
||||
IdentityInstance currentInstance,
|
||||
List<IdentityInstance> deprecatedInstances,
|
||||
List<Typed<FixedEncodedString43>> deprecatedSuperRecordKeys,
|
||||
FixedEncodedString86 signature});
|
||||
|
||||
/// Public key of the SuperIdentity used to sign identity keys for recovery
|
||||
/// This must match the owner of the superRecord DHT record and can not be
|
||||
/// changed without changing the record
|
||||
@override
|
||||
FixedEncodedString43 get publicKey;
|
||||
$IdentityInstanceCopyWith<$Res> get currentInstance;
|
||||
}
|
||||
|
||||
/// Current identity instance
|
||||
/// The most recently generated identity instance for this SuperIdentity
|
||||
@override
|
||||
IdentityInstance get currentInstance;
|
||||
/// @nodoc
|
||||
class __$SuperIdentityCopyWithImpl<$Res>
|
||||
implements _$SuperIdentityCopyWith<$Res> {
|
||||
__$SuperIdentityCopyWithImpl(this._self, this._then);
|
||||
|
||||
/// Deprecated identity instances
|
||||
/// These may be compromised and should not be considered valid for
|
||||
/// new signatures, but may be used to validate old signatures
|
||||
@override
|
||||
List<IdentityInstance> get deprecatedInstances;
|
||||
|
||||
/// Deprecated superRecords
|
||||
/// These may be compromised and should not be considered valid for
|
||||
/// new signatures, but may be used to validate old signatures
|
||||
@override
|
||||
List<Typed<FixedEncodedString43>> get deprecatedSuperRecordKeys;
|
||||
|
||||
/// Signature of recordKey, currentInstance signature,
|
||||
/// signatures of deprecatedInstances, and deprecatedSuperRecordKeys
|
||||
/// by publicKey
|
||||
@override
|
||||
FixedEncodedString86 get signature;
|
||||
final _SuperIdentity _self;
|
||||
final $Res Function(_SuperIdentity) _then;
|
||||
|
||||
/// Create a copy of SuperIdentity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$SuperIdentityImplCopyWith<_$SuperIdentityImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
@pragma('vm:prefer-inline')
|
||||
$Res call({
|
||||
Object? recordKey = null,
|
||||
Object? publicKey = null,
|
||||
Object? currentInstance = null,
|
||||
Object? deprecatedInstances = null,
|
||||
Object? deprecatedSuperRecordKeys = null,
|
||||
Object? signature = null,
|
||||
}) {
|
||||
return _then(_SuperIdentity(
|
||||
recordKey: null == recordKey
|
||||
? _self.recordKey
|
||||
: recordKey // ignore: cast_nullable_to_non_nullable
|
||||
as Typed<FixedEncodedString43>,
|
||||
publicKey: null == publicKey
|
||||
? _self.publicKey
|
||||
: publicKey // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString43,
|
||||
currentInstance: null == currentInstance
|
||||
? _self.currentInstance
|
||||
: currentInstance // ignore: cast_nullable_to_non_nullable
|
||||
as IdentityInstance,
|
||||
deprecatedInstances: null == deprecatedInstances
|
||||
? _self._deprecatedInstances
|
||||
: deprecatedInstances // ignore: cast_nullable_to_non_nullable
|
||||
as List<IdentityInstance>,
|
||||
deprecatedSuperRecordKeys: null == deprecatedSuperRecordKeys
|
||||
? _self._deprecatedSuperRecordKeys
|
||||
: deprecatedSuperRecordKeys // ignore: cast_nullable_to_non_nullable
|
||||
as List<Typed<FixedEncodedString43>>,
|
||||
signature: null == signature
|
||||
? _self.signature
|
||||
: signature // ignore: cast_nullable_to_non_nullable
|
||||
as FixedEncodedString86,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of SuperIdentity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$IdentityInstanceCopyWith<$Res> get currentInstance {
|
||||
return $IdentityInstanceCopyWith<$Res>(_self.currentInstance, (value) {
|
||||
return _then(_self.copyWith(currentInstance: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
|
|
|
@ -6,8 +6,8 @@ part of 'super_identity.dart';
|
|||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$SuperIdentityImpl _$$SuperIdentityImplFromJson(Map<String, dynamic> json) =>
|
||||
_$SuperIdentityImpl(
|
||||
_SuperIdentity _$SuperIdentityFromJson(Map<String, dynamic> json) =>
|
||||
_SuperIdentity(
|
||||
recordKey: Typed<FixedEncodedString43>.fromJson(json['record_key']),
|
||||
publicKey: FixedEncodedString43.fromJson(json['public_key']),
|
||||
currentInstance: IdentityInstance.fromJson(json['current_instance']),
|
||||
|
@ -21,7 +21,7 @@ _$SuperIdentityImpl _$$SuperIdentityImplFromJson(Map<String, dynamic> json) =>
|
|||
signature: FixedEncodedString86.fromJson(json['signature']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SuperIdentityImplToJson(_$SuperIdentityImpl instance) =>
|
||||
Map<String, dynamic> _$SuperIdentityToJson(_SuperIdentity instance) =>
|
||||
<String, dynamic>{
|
||||
'record_key': instance.recordKey.toJson(),
|
||||
'public_key': instance.publicKey.toJson(),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:typed_data';
|
||||
|
||||
import '../src/dynamic_debug.dart';
|
||||
import '../veilid_support.dart' as veilid;
|
||||
import 'veilid.pb.dart' as proto;
|
||||
|
||||
|
@ -150,3 +151,26 @@ extension ProtoKeyPair on proto.KeyPair {
|
|||
veilid.KeyPair toVeilid() =>
|
||||
veilid.KeyPair(key: key.toVeilid(), secret: secret.toVeilid());
|
||||
}
|
||||
|
||||
void registerVeilidProtoToDebug() {
|
||||
dynamic toDebug(dynamic protoObj) {
|
||||
if (protoObj is proto.CryptoKey) {
|
||||
return protoObj.toVeilid();
|
||||
}
|
||||
if (protoObj is proto.Signature) {
|
||||
return protoObj.toVeilid();
|
||||
}
|
||||
if (protoObj is proto.Nonce) {
|
||||
return protoObj.toVeilid();
|
||||
}
|
||||
if (protoObj is proto.TypedKey) {
|
||||
return protoObj.toVeilid();
|
||||
}
|
||||
if (protoObj is proto.KeyPair) {
|
||||
return protoObj.toVeilid();
|
||||
}
|
||||
return protoObj;
|
||||
}
|
||||
|
||||
DynamicDebug.registerToDebug(toDebug);
|
||||
}
|
||||
|
|
130
packages/veilid_support/lib/src/dynamic_debug.dart
Normal file
130
packages/veilid_support/lib/src/dynamic_debug.dart
Normal file
|
@ -0,0 +1,130 @@
|
|||
import 'package:async_tools/async_tools.dart';
|
||||
import 'package:bloc_advanced_tools/bloc_advanced_tools.dart';
|
||||
import 'package:convert/convert.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
|
||||
import 'online_element_state.dart';
|
||||
|
||||
typedef ToDebugFunction = dynamic Function(dynamic protoObj);
|
||||
|
||||
// This should be implemented to add toDebug capability
|
||||
// ignore: one_member_abstracts
|
||||
abstract class ToDebugMap {
|
||||
Map<String, dynamic> toDebugMap();
|
||||
}
|
||||
|
||||
// We explicitly want this class to avoid having a global function 'toDebug'
|
||||
// ignore: avoid_classes_with_only_static_members
|
||||
class DynamicDebug {
|
||||
/// Add a 'toDebug' handler to the chain
|
||||
static void registerToDebug(ToDebugFunction toDebugFunction) {
|
||||
final _oldToDebug = _toDebug;
|
||||
_toDebug = (obj) => _oldToDebug(toDebugFunction(obj));
|
||||
}
|
||||
|
||||
/// Convert a type to a debug version of the same type that
|
||||
/// has a better `toString` representation and possibly other extra debug
|
||||
/// information
|
||||
static dynamic toDebug(dynamic obj) {
|
||||
try {
|
||||
return _toDebug(obj);
|
||||
// In this case we watch to catch everything
|
||||
// because toDebug need to never fail
|
||||
// ignore: avoid_catches_without_on_clauses
|
||||
} catch (e) {
|
||||
// Ensure this gets printed, but continue
|
||||
// ignore: avoid_print
|
||||
print('Exception in toDebug: $e');
|
||||
return obj.toString();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
static dynamic _baseToDebug(dynamic obj) {
|
||||
if (obj is AsyncValue<dynamic>) {
|
||||
if (obj.isLoading) {
|
||||
return {r'$runtimeType': obj.runtimeType, 'loading': null};
|
||||
}
|
||||
if (obj.isError) {
|
||||
return {
|
||||
r'$runtimeType': obj.runtimeType,
|
||||
'error': toDebug(obj.asError!.error),
|
||||
'stackTrace': toDebug(obj.asError!.stackTrace),
|
||||
};
|
||||
}
|
||||
if (obj.isData) {
|
||||
return {
|
||||
r'$runtimeType': obj.runtimeType,
|
||||
'data': toDebug(obj.asData!.value),
|
||||
};
|
||||
}
|
||||
return obj.toString();
|
||||
}
|
||||
if (obj is IMap<dynamic, dynamic>) {
|
||||
// Handled by Map
|
||||
return _baseToDebug(obj.unlockView);
|
||||
}
|
||||
if (obj is IMapOfSets<dynamic, dynamic>) {
|
||||
// Handled by Map
|
||||
return _baseToDebug(obj.unlock);
|
||||
}
|
||||
if (obj is ISet<dynamic>) {
|
||||
// Handled by Iterable
|
||||
return _baseToDebug(obj.unlockView);
|
||||
}
|
||||
if (obj is IList<dynamic>) {
|
||||
return _baseToDebug(obj.unlockView);
|
||||
}
|
||||
if (obj is BlocBusyState<dynamic>) {
|
||||
return {
|
||||
r'$runtimeType': obj.runtimeType,
|
||||
'busy': obj.busy,
|
||||
'state': toDebug(obj.state),
|
||||
};
|
||||
}
|
||||
if (obj is OnlineElementState<dynamic>) {
|
||||
return {
|
||||
r'$runtimeType': obj.runtimeType,
|
||||
'isOffline': obj.isOffline,
|
||||
'value': toDebug(obj.value),
|
||||
};
|
||||
}
|
||||
if (obj is List<int>) {
|
||||
try {
|
||||
// Do bytes as a hex string for brevity and clarity
|
||||
return 'List<int>: ${hex.encode(obj)}';
|
||||
// One has to be able to catch this
|
||||
// ignore: avoid_catching_errors
|
||||
} on RangeError {
|
||||
// Otherwise directly convert as list of integers
|
||||
return obj.toString();
|
||||
}
|
||||
}
|
||||
if (obj is Map<dynamic, dynamic>) {
|
||||
return obj.map((k, v) => MapEntry(toDebug(k), toDebug(v)));
|
||||
}
|
||||
if (obj is Iterable<dynamic>) {
|
||||
return obj.map(toDebug).toList();
|
||||
}
|
||||
if (obj is String || obj is bool || obj is num || obj == null) {
|
||||
return obj;
|
||||
}
|
||||
if (obj is ToDebugMap) {
|
||||
// Handled by Map
|
||||
return _baseToDebug(obj.toDebugMap());
|
||||
}
|
||||
|
||||
try {
|
||||
// Let's try convering to a json object
|
||||
// ignore: avoid_dynamic_calls
|
||||
return obj.toJson();
|
||||
|
||||
// No matter how this fails, we shouldn't throw
|
||||
// ignore: avoid_catches_without_on_clauses
|
||||
} catch (_) {}
|
||||
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
static ToDebugFunction _toDebug = _baseToDebug;
|
||||
}
|
|
@ -1,13 +1,14 @@
|
|||
/// Dart Veilid Support Library
|
||||
/// Common functionality for interfacing with Veilid
|
||||
|
||||
library veilid_support;
|
||||
library;
|
||||
|
||||
export 'package:veilid/veilid.dart';
|
||||
|
||||
export 'dht_support/dht_support.dart';
|
||||
export 'identity_support/identity_support.dart';
|
||||
export 'src/config.dart';
|
||||
export 'src/dynamic_debug.dart';
|
||||
export 'src/json_tools.dart';
|
||||
export 'src/memory_tools.dart';
|
||||
export 'src/online_element_state.dart';
|
||||
|
|
|
@ -178,7 +178,7 @@ packages:
|
|||
source: hosted
|
||||
version: "1.19.1"
|
||||
convert:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: convert
|
||||
sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68
|
||||
|
|
|
@ -12,6 +12,7 @@ dependencies:
|
|||
bloc_advanced_tools: ^0.1.10
|
||||
charcode: ^1.4.0
|
||||
collection: ^1.19.1
|
||||
convert: ^3.1.2
|
||||
equatable: ^2.0.7
|
||||
fast_immutable_collections: ^11.0.3
|
||||
freezed_annotation: ^3.0.0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue