mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-03-14 01:46:41 -04:00
api update
This commit is contained in:
parent
c92f17b312
commit
2d2b26bc81
@ -229,7 +229,7 @@ impl StorageManager {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Create a local record from scratch with a new owner key, open it, and return the opened descriptor
|
||||
/// Builds the record key for a given schema and owner
|
||||
#[instrument(level = "trace", target = "stor", skip_all)]
|
||||
pub async fn get_record_key(
|
||||
&self,
|
||||
|
@ -708,7 +708,7 @@ impl StorageManagerInner {
|
||||
&self,
|
||||
kind: CryptoKind,
|
||||
owner_key: &PublicKey,
|
||||
schema: DHTSchema,,
|
||||
schema: DHTSchema,
|
||||
) -> VeilidAPIResult<TypedKey> {
|
||||
// Get cryptosystem
|
||||
let Some(vcrypto) = self.unlocked_inner.crypto.get(kind) else {
|
||||
|
@ -1477,7 +1477,7 @@ impl VeilidAPI {
|
||||
};
|
||||
|
||||
// Do a record create
|
||||
let record = match rc.create_dht_record(schema, Some(csv.kind())).await {
|
||||
let record = match rc.create_dht_record(schema, None, Some(csv.kind())).await {
|
||||
Err(e) => return Ok(format!("Can't open DHT record: {}", e)),
|
||||
Ok(v) => v,
|
||||
};
|
||||
|
@ -225,7 +225,7 @@ impl RoutingContext {
|
||||
///////////////////////////////////
|
||||
/// DHT Records
|
||||
|
||||
///
|
||||
/// Builds the record key for a given schema and owner
|
||||
#[instrument(target = "veilid_api", level = "debug", ret, err)]
|
||||
pub async fn get_dht_record_key(
|
||||
&self,
|
||||
@ -250,49 +250,25 @@ impl RoutingContext {
|
||||
/// The record is considered 'open' after the create operation succeeds.
|
||||
/// * 'schema' - the schema to use when creating the DHT record
|
||||
/// * 'kind' - specify a cryptosystem kind to use. Normally you will leave this as None to choose the 'best' cryptosystem available.
|
||||
/// Returns the newly allocated DHT record's key if successful.
|
||||
/// Returns the newly allocated DHT record's key if successful.
|
||||
///
|
||||
/// Note: if you pass in an owner keypair this call is a deterministic! This means that if you try to create a new record for a given owner and schema that already exists it *will* fail.
|
||||
#[instrument(target = "veilid_api", level = "debug", ret, err)]
|
||||
pub async fn create_dht_record(
|
||||
&self,
|
||||
schema: DHTSchema,
|
||||
owner: Option<KeyPair>,
|
||||
kind: Option<CryptoKind>,
|
||||
) -> VeilidAPIResult<DHTRecordDescriptor> {
|
||||
event!(target: "veilid_api", Level::DEBUG,
|
||||
"RoutingContext::create_dht_record(self: {:?}, schema: {:?}, kind: {:?})", self, schema, kind);
|
||||
"RoutingContext::create_dht_record(self: {:?}, schema: {:?}, owner: {:?}, kind: {:?})", self, schema, owner, kind);
|
||||
schema.validate()?;
|
||||
|
||||
let kind = kind.unwrap_or(best_crypto_kind());
|
||||
Crypto::validate_crypto_kind(kind)?;
|
||||
let storage_manager = self.api.storage_manager()?;
|
||||
storage_manager
|
||||
.create_record(kind, schema, None, self.unlocked_inner.safety_selection)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Creates a new DHT record with a specified crypto kind, schema, and owner
|
||||
/// This is intended to be used when you want to create a record with a given owner keypair rather than a randomly generated one.
|
||||
///
|
||||
/// Note: this is a deterministic way of creating a new record! This means that if you try to create a new record for a given owner and schema that already exists it *will* fail.
|
||||
///
|
||||
/// The record is considered 'open' after the create operation succeeds.
|
||||
///
|
||||
/// Returns the newly allocated DHT record's key if successful.
|
||||
#[instrument(target = "veilid_api", level = "debug", ret, err)]
|
||||
pub async fn create_dht_record_with_owner(
|
||||
&self,
|
||||
schema: DHTSchema,
|
||||
owner: KeyPair,
|
||||
kind: Option<CryptoKind>,
|
||||
) -> VeilidAPIResult<DHTRecordDescriptor> {
|
||||
event!(target: "veilid_api", Level::DEBUG,
|
||||
"RoutingContext::create_dht_record_with_owner(self: {:?}, schema: {:?}, owner: {:?}, kind: {:?})", self, schema, owner, kind);
|
||||
schema.validate()?;
|
||||
|
||||
let kind = kind.unwrap_or(best_crypto_kind());
|
||||
Crypto::validate_crypto_kind(kind)?;
|
||||
let storage_manager = self.api.storage_manager()?;
|
||||
storage_manager
|
||||
.create_record(kind, schema, Some(owner), self.unlocked_inner.safety_selection)
|
||||
.create_record(kind, schema, owner, self.unlocked_inner.safety_selection)
|
||||
.await
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user