mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-08-02 11:46:07 -04:00
update api surface for create_dht_record with owner
This commit is contained in:
parent
bebdbee41b
commit
69378ca9b0
20 changed files with 206 additions and 88 deletions
|
@ -293,7 +293,7 @@ abstract class VeilidRoutingContext {
|
|||
|
||||
// DHT Operations
|
||||
Future<DHTRecordDescriptor> createDHTRecord(DHTSchema schema,
|
||||
{CryptoKind kind = 0});
|
||||
{KeyPair? owner, CryptoKind kind = 0});
|
||||
Future<DHTRecordDescriptor> openDHTRecord(TypedKey key, {KeyPair? writer});
|
||||
Future<void> closeDHTRecord(TypedKey key);
|
||||
Future<void> deleteDHTRecord(TypedKey key);
|
||||
|
|
|
@ -65,9 +65,9 @@ typedef _RoutingContextAppCallDart = void Function(
|
|||
typedef _RoutingContextAppMessageDart = void Function(
|
||||
int, int, Pointer<Utf8>, Pointer<Utf8>);
|
||||
// fn routing_context_create_dht_record(port: i64,
|
||||
// id: u32, kind: u32, schema: FfiStr)
|
||||
// id: u32, schema: FfiStr, owner: FfiStr, kind: u32)
|
||||
typedef _RoutingContextCreateDHTRecordDart = void Function(
|
||||
int, int, Pointer<Utf8>, int);
|
||||
int, int, Pointer<Utf8>, Pointer<Utf8>, int);
|
||||
// fn routing_context_open_dht_record(port: i64,
|
||||
// id: u32, key: FfiStr, writer: FfiStr)
|
||||
typedef _RoutingContextOpenDHTRecordDart = void Function(
|
||||
|
@ -618,13 +618,15 @@ class VeilidRoutingContextFFI extends VeilidRoutingContext {
|
|||
|
||||
@override
|
||||
Future<DHTRecordDescriptor> createDHTRecord(DHTSchema schema,
|
||||
{CryptoKind kind = 0}) async {
|
||||
{KeyPair? owner, CryptoKind kind = 0}) async {
|
||||
_ctx.ensureValid();
|
||||
final nativeSchema = jsonEncode(schema).toNativeUtf8();
|
||||
final nativeOwner =
|
||||
owner != null ? jsonEncode(owner).toNativeUtf8() : nullptr;
|
||||
final recvPort = ReceivePort('routing_context_create_dht_record');
|
||||
final sendPort = recvPort.sendPort;
|
||||
_ctx.ffi._routingContextCreateDHTRecord(
|
||||
sendPort.nativePort, _ctx.id!, nativeSchema, kind);
|
||||
sendPort.nativePort, _ctx.id!, nativeSchema, nativeOwner, kind);
|
||||
final dhtRecordDescriptor =
|
||||
await processFutureJson(DHTRecordDescriptor.fromJson, recvPort.first);
|
||||
return dhtRecordDescriptor;
|
||||
|
@ -1283,10 +1285,12 @@ class VeilidFFI extends Veilid {
|
|||
_routingContextAppMessage = dylib.lookupFunction<
|
||||
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
||||
_RoutingContextAppMessageDart>('routing_context_app_message'),
|
||||
_routingContextCreateDHTRecord = dylib.lookupFunction<
|
||||
Void Function(Int64, Uint32, Pointer<Utf8>, Uint32),
|
||||
_RoutingContextCreateDHTRecordDart>(
|
||||
'routing_context_create_dht_record'),
|
||||
_routingContextCreateDHTRecord =
|
||||
dylib.lookupFunction<
|
||||
Void Function(
|
||||
Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>, Uint32),
|
||||
_RoutingContextCreateDHTRecordDart>(
|
||||
'routing_context_create_dht_record'),
|
||||
_routingContextOpenDHTRecord = dylib.lookupFunction<
|
||||
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
||||
_RoutingContextOpenDHTRecordDart>(
|
||||
|
|
|
@ -134,11 +134,15 @@ class VeilidRoutingContextJS extends VeilidRoutingContext {
|
|||
|
||||
@override
|
||||
Future<DHTRecordDescriptor> createDHTRecord(DHTSchema schema,
|
||||
{CryptoKind kind = 0}) async {
|
||||
{KeyPair? owner, CryptoKind kind = 0}) async {
|
||||
final id = _ctx.requireId();
|
||||
return DHTRecordDescriptor.fromJson(jsonDecode(await _wrapApiPromise(js_util
|
||||
.callMethod(wasm, 'routing_context_create_dht_record',
|
||||
[id, jsonEncode(schema), kind]))));
|
||||
.callMethod(wasm, 'routing_context_create_dht_record', [
|
||||
id,
|
||||
jsonEncode(schema),
|
||||
if (owner != null) jsonEncode(owner) else null,
|
||||
kind
|
||||
]))));
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue