fix: use correct mainline v2 API for DHT operations

- get_mutable takes &[u8; 32] directly (not VerifyingKey)
- MutableItem::new takes bytes::Bytes (not Vec<u8>)
- Remove VerifyingKey import (not exported from mainline v2)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-14 04:17:05 +00:00
parent b48b30b927
commit dc48d6fc8c

View File

@@ -108,7 +108,7 @@ pub async fn create_and_publish(
let dht = mainline::Dht::client().context("Failed to create DHT client")?;
let signer = mainline::SigningKey::from_bytes(&signing_key.to_bytes());
let item = mainline::MutableItem::new(signer, payload, 0, None);
let item = mainline::MutableItem::new(signer, bytes::Bytes::from(payload), 0, None);
dht.put_mutable(item).context("Failed to publish to DHT")?;
@@ -127,17 +127,13 @@ pub async fn resolve(did: &str, cache: Option<&DhtDidCache>) -> Result<serde_jso
}
let pubkey_bytes = pubkey_from_did(did)?;
let verifying_key = mainline::VerifyingKey::from_bytes(&pubkey_bytes)
.map_err(|e| anyhow::anyhow!("Invalid Ed25519 key: {:?}", e))?;
let target = mainline::MutableItem::target_from_key(&verifying_key, &None);
let dht = mainline::Dht::client().context("Failed to create DHT client")?;
let response = tokio::time::timeout(
std::time::Duration::from_secs(30),
tokio::task::spawn_blocking(move || {
// get_mutable returns a Result<IntoIter<MutableItem>>
match dht.get_mutable(&target, None, None) {
match dht.get_mutable(&pubkey_bytes, None, None) {
Ok(mut iter) => iter.next(),
Err(_) => None,
}