cleanup logs

pull/19/head
Niko PLP 8 months ago
parent 5460a22737
commit 3e4c2a70dc
  1. 2
      ng-app/src-tauri/src/lib.rs
  2. 6
      ng-app/src/lib/Test.svelte
  3. 14
      ng-app/src/store.ts
  4. 2
      ng-sdk-js/src/lib.rs
  5. 4
      ng-verifier/src/request_processor.rs
  6. 20
      ng-verifier/src/verifier.rs

@ -269,7 +269,7 @@ async fn app_request_stream(
.await .await
.map_err(|e| e.to_string())?; .map_err(|e| e.to_string())?;
log_debug!("END OF LOOP"); //log_debug!("END OF LOOP");
Ok(()) Ok(())
} }

@ -259,11 +259,11 @@
{:then} {:then}
{#each $files as file} {#each $files as file}
<p> <p>
{file.V0.File.name}<br /> {file.V0.File.name}
did:ng{file.V0.File.nuri}
{#await get_img(file.V0.File) then url} {#await get_img(file.V0.File) then url}
{#if url} {#if url}
<img src={url} /> <img src={url} title={"did:ng" + file.V0.File.nuri} />
{/if} {/if}
{/await} {/await}
</p> </p>

@ -174,11 +174,11 @@ export const branch_subs = function(nura) {
return { return {
load: async () => { load: async () => {
console.log("load upper"); //console.log("load upper");
let already_subscribed = all_branches[nura]; let already_subscribed = all_branches[nura];
if (!already_subscribed) return; if (!already_subscribed) return;
if (already_subscribed.load) { if (already_subscribed.load) {
console.log("doing the load"); //console.log("doing the load");
let loader = already_subscribed.load; let loader = already_subscribed.load;
already_subscribed.load = undefined; already_subscribed.load = undefined;
// already_subscribed.load2 = loader; // already_subscribed.load2 = loader;
@ -195,7 +195,7 @@ export const branch_subs = function(nura) {
already_subscribed = { already_subscribed = {
load: async () => { load: async () => {
try { try {
console.log("load down"); //console.log("load down");
let session = get(active_session); let session = get(active_session);
if (!session) { if (!session) {
console.error("no session"); console.error("no session");
@ -206,7 +206,7 @@ export const branch_subs = function(nura) {
set([]); set([]);
unsub = await ng.app_request_stream(session.session_id, await ng.doc_fetch_private_subscribe(), unsub = await ng.app_request_stream(session.session_id, await ng.doc_fetch_private_subscribe(),
async (commit) => { async (commit) => {
console.log("GOT APP RESPONSE", commit); //console.log("GOT APP RESPONSE", commit);
update( (old) => {old.unshift(commit); return old;} ) update( (old) => {old.unshift(commit); return old;} )
}); });
} }
@ -218,12 +218,12 @@ export const branch_subs = function(nura) {
}, },
increase: () => { increase: () => {
count += 1; count += 1;
console.log("increase sub to",count); //console.log("increase sub to",count);
return readonly({subscribe}); return readonly({subscribe});
}, },
decrease: () => { decrease: () => {
count -= 1; count -= 1;
console.log("decrease sub to",count); //console.log("decrease sub to",count);
// if (count == 0) { // if (count == 0) {
// unsub(); // unsub();
// console.log("removed sub"); // console.log("removed sub");
@ -238,7 +238,7 @@ export const branch_subs = function(nura) {
let read_unsub = new_store.subscribe(run, invalid); let read_unsub = new_store.subscribe(run, invalid);
return () => { return () => {
read_unsub(); read_unsub();
console.log("callback unsub"); //console.log("callback unsub");
already_subscribed.decrease(); already_subscribed.decrease();
} }

@ -537,7 +537,7 @@ pub async fn app_request_stream(
} }
} }
} }
log_info!("END OF LOOP"); //log_info!("END OF LOOP");
Ok(()) Ok(())
} }

@ -41,9 +41,7 @@ impl AppRequestCommandV0 {
AppFetchContentV0::Subscribe => { AppFetchContentV0::Subscribe => {
let (_, branch_id, _) = let (_, branch_id, _) =
Self::open_for_target(verifier, &nuri.target, false).await?; Self::open_for_target(verifier, &nuri.target, false).await?;
Ok(verifier Ok(verifier.create_branch_subscription(branch_id).await?)
.create_branch_subscription(branch_id, false)
.await?)
} }
_ => unimplemented!(), _ => unimplemented!(),
}, },

@ -154,11 +154,11 @@ impl Verifier {
} }
pub(crate) async fn push_app_response(&mut self, branch: &BranchId, response: AppResponse) { pub(crate) async fn push_app_response(&mut self, branch: &BranchId, response: AppResponse) {
log_info!( // log_info!(
"push_app_response {} {:?}", // "push_app_response {} {:?}",
branch, // branch,
self.branch_subscriptions // self.branch_subscriptions
); // );
if let Some(sender) = self.branch_subscriptions.get_mut(branch) { if let Some(sender) = self.branch_subscriptions.get_mut(branch) {
if sender.is_closed() { if sender.is_closed() {
log_info!("closed so removed"); log_info!("closed so removed");
@ -172,7 +172,6 @@ impl Verifier {
pub(crate) async fn create_branch_subscription( pub(crate) async fn create_branch_subscription(
&mut self, &mut self,
branch: BranchId, branch: BranchId,
resub: bool,
) -> Result<(Receiver<AppResponse>, CancelFn), VerifierError> { ) -> Result<(Receiver<AppResponse>, CancelFn), VerifierError> {
// async fn send(mut tx: Sender<AppResponse>, msg: AppResponse) -> ResultSend<()> { // async fn send(mut tx: Sender<AppResponse>, msg: AppResponse) -> ResultSend<()> {
// while let Ok(_) = tx.send(msg.clone()).await { // while let Ok(_) = tx.send(msg.clone()).await {
@ -185,16 +184,16 @@ impl Verifier {
// spawn_and_log_error(send(tx.clone(), commit)); // spawn_and_log_error(send(tx.clone(), commit));
//log_info!("#### create_branch_subscription {}", branch); //log_info!("#### create_branch_subscription {}", branch);
let (tx, rx) = mpsc::unbounded::<AppResponse>(); let (tx, rx) = mpsc::unbounded::<AppResponse>();
log_info!("SUBSCRIBE"); //log_info!("SUBSCRIBE");
if let Some(returned) = self.branch_subscriptions.insert(branch, tx.clone()) { if let Some(returned) = self.branch_subscriptions.insert(branch, tx.clone()) {
log_info!("RESUBSCRIBE"); //log_info!("RESUBSCRIBE");
if !returned.is_closed() { if !returned.is_closed() {
log_info!("FORCE CLOSE"); //log_info!("FORCE CLOSE");
returned.close_channel(); returned.close_channel();
//return Err(VerifierError::DoubleBranchSubscription); //return Err(VerifierError::DoubleBranchSubscription);
} }
} }
if !resub {
//let tx = self.branch_subscriptions.entry(branch).or_insert_with(|| {}); //let tx = self.branch_subscriptions.entry(branch).or_insert_with(|| {});
for file in self for file in self
.user_storage .user_storage
@ -205,7 +204,6 @@ impl Verifier {
self.push_app_response(&branch, AppResponse::V0(AppResponseV0::File(file))) self.push_app_response(&branch, AppResponse::V0(AppResponseV0::File(file)))
.await; .await;
} }
}
let fnonce = Box::new(move || { let fnonce = Box::new(move || {
log_info!("CLOSE_CHANNEL"); log_info!("CLOSE_CHANNEL");

Loading…
Cancel
Save