Skip to content

Commit

Permalink
chore: add additional logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusc93 committed Dec 12, 2024
1 parent 5513ff2 commit 806b9ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
11 changes: 10 additions & 1 deletion extensions/warp-ipfs/src/shuttle/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ impl ShuttleTask {
}
};

tracing::info!(%document.did, "Receive register request");
tracing::info!(%document.did, "receive register request");
if identity_storage.contains(&document.did).await {
tracing::warn!(%document.did, "Identity is already registered");
let payload = payload_message_construct(
Expand All @@ -438,6 +438,7 @@ impl ShuttleTask {
return;
}

tracing::info!(%document.did, %sender_peer_id, "verifying identity document");
if document.verify().is_err() {
tracing::warn!(%document.did, "Identity cannot be verified");
let payload = payload_message_construct(
Expand All @@ -457,6 +458,8 @@ impl ShuttleTask {
return;
}

tracing::info!(%document.did, %sender_peer_id, "identity verified. registering identity");

if let Err(e) = identity_storage.register(&document, root_cid).await {
tracing::warn!(%document.did, error = %e, "Unable to register identity");
let res_error = match e {
Expand All @@ -481,6 +484,8 @@ impl ShuttleTask {
return;
}

tracing::info!(%document.did, %sender_peer_id, "identity regostered");

if let Err(e) = subscriptions.subscribe(document.did.inbox()).await {
tracing::warn!(%document.did, "Unable to subscribe to given topic: {e}. ignoring...");
// Although we arent able to subscribe, we can still process the request while leaving this as a warning
Expand Down Expand Up @@ -904,7 +909,11 @@ impl ShuttleTask {
}
};

tracing::info!(%sender_peer_id, "pushing task into queue");
self.requests.push(fut.boxed());
// since we have "pending" future, we can remove one from the total value since it will always be pending
let total_requests = self.requests.len() - 1;
tracing::debug!(total_requests);
}

fn process_message_events(
Expand Down
15 changes: 10 additions & 5 deletions extensions/warp-ipfs/src/shuttle/store/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,21 @@ impl IdentityStorageInner {
return Err(Error::IdentityExist);
}

tracing::info!(%did_str, "inserting document");
list.insert(did_str, root_cid);

tracing::info!(did = %document.did, "document inserted. restructuring dag");
let cid = self.ipfs.put_dag(list).await?;

self.ipfs.insert_pin(cid).recursive().await?;

// tracing::info!(did = %document.did, "pinning document");
// self.ipfs.insert_pin(cid).recursive().await?;
//
// tracing::info!(did = %document.did, "pinning successful");
let old_cid = self.users.replace(cid);

if let Some(old_cid) = old_cid {
if old_cid != cid && self.ipfs.is_pinned(&old_cid).await.unwrap_or_default() {
tracing::info!(did = %document.did, "unpinning previous document");
_ = self.ipfs.remove_pin(old_cid).await;
}
}
Expand Down Expand Up @@ -215,7 +220,7 @@ impl IdentityStorageInner {

let cid = self.ipfs.put_dag(list).await?;

self.ipfs.insert_pin(cid).recursive().await?;
// self.ipfs.insert_pin(cid).recursive().await?;

let old_cid = self.users.replace(cid);
if let Some(old_cid) = old_cid {
Expand Down Expand Up @@ -427,7 +432,7 @@ impl IdentityStorageInner {

list.insert(key_str, cid);

let cid = self.ipfs.put_dag(list).pin(true).await?;
let cid = self.ipfs.put_dag(list).await?;

let old_cid = self.mailbox.replace(cid);

Expand Down Expand Up @@ -490,7 +495,7 @@ impl IdentityStorageInner {

list.insert(key_str, cid);

let cid = self.ipfs.put_dag(list).pin(true).await?;
let cid = self.ipfs.put_dag(list).await?;

let old_cid = self.mailbox.replace(cid);

Expand Down

0 comments on commit 806b9ca

Please sign in to comment.