mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2024-10-01 06:55:46 -04:00
dht data structures
This commit is contained in:
parent
44a2761f87
commit
dc59703f41
28
lib/entities/dht.dart
Normal file
28
lib/entities/dht.dart
Normal file
@ -0,0 +1,28 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:change_case/change_case.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:veilid/veilid.dart';
|
||||
|
||||
part 'dht.freezed.dart';
|
||||
part 'dht.g.dart';
|
||||
|
||||
// Header in subkey 0 for Fixed DHT Data
|
||||
// Subkeys 1..=stride on the first key are concatenated chunks
|
||||
// Subkeys 0..stride on the 'keys' keys are concatenated chunks
|
||||
@freezed
|
||||
class DHTData with _$DHTData {
|
||||
const factory DHTData({
|
||||
// Other keys to concatenate
|
||||
required List<TypedKey> keys,
|
||||
// Total data size
|
||||
required int size,
|
||||
// Chunk size per subkey
|
||||
required int chunk,
|
||||
// Subkeys per key
|
||||
required int stride,
|
||||
}) = _DHTData;
|
||||
factory DHTData.fromJson(Map<String, dynamic> json) => _$DHTData(json);
|
||||
}
|
@ -27,8 +27,8 @@ class Messages with _$Messages {
|
||||
}
|
||||
|
||||
// A record of a 1-1 chat that is synchronized between
|
||||
// two users. Backed up on a DHT key.
|
||||
//
|
||||
// two users. Backed up on a DHT key. Visible and encrypted
|
||||
// for the other party
|
||||
//
|
||||
// DHT Key (UnicastOutbox): conversationPublicKey
|
||||
// DHT Secret: conversationSecret
|
||||
@ -53,11 +53,16 @@ class Conversation with _$Conversation {
|
||||
// Contains
|
||||
@freezed
|
||||
class Contact with _$Contact {
|
||||
const factory Contact(
|
||||
{required Profile remoteProfile,
|
||||
required Profile localProfile,
|
||||
required Identity identity,
|
||||
required bool available}) = _Contact;
|
||||
const factory Contact({
|
||||
// Profile as locally edited
|
||||
required Profile localProfile,
|
||||
// Profile from remote conversation
|
||||
required Profile remoteProfile,
|
||||
// Identity from remote conversation
|
||||
required Identity identity,
|
||||
// xxx
|
||||
required bool available,
|
||||
}) = _Contact;
|
||||
|
||||
factory Contact.fromJson(Map<String, dynamic> json) =>
|
||||
_$ContactFromJson(json);
|
||||
@ -80,13 +85,15 @@ class Profile with _$Profile {
|
||||
required String title,
|
||||
// Status/away message
|
||||
required String status,
|
||||
// Icon data (png 128x128x24bit)
|
||||
required Uint8List icon,
|
||||
// Icon DHTData
|
||||
required TypedKey icon,
|
||||
}) = _Profile;
|
||||
factory Profile.fromJson(Map<String, dynamic> json) =>
|
||||
_$ProfileFromJson(json);
|
||||
}
|
||||
|
||||
// A linked list of DHT subvalues
|
||||
|
||||
// A record of an individual account
|
||||
// DHT Key (Private): accountPublicKey
|
||||
// DHT Secret: accountSecretKey
|
||||
@ -100,10 +107,7 @@ class Account with _$Account {
|
||||
// Auto-away sets 'away' mode after an inactivity time
|
||||
required autoAwayTimeoutSec,
|
||||
// The contacts for this account
|
||||
required List<Contact>,
|
||||
|
||||
xxx investigate immutable FIC lists and their use with freezed/jsonserializable, switch them here
|
||||
|
||||
required DHTListRef<Contact> contacts,
|
||||
}) = _Account;
|
||||
|
||||
factory Account.fromJson(Map<String, dynamic> json) =>
|
||||
|
Loading…
Reference in New Issue
Block a user