From 166e70f62822cea1655387c28d679594ee72b509 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 7 Apr 2017 10:32:26 +0200 Subject: [PATCH] test new rpc apis --- www/examples/pin/main.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/www/examples/pin/main.js b/www/examples/pin/main.js index 1c3df4d2f..1eb0388e0 100644 --- a/www/examples/pin/main.js +++ b/www/examples/pin/main.js @@ -36,11 +36,6 @@ define([ console.log(msg); }); } - call.getFileListSize(list, function (e, bytes) { - if (e) { return void console.error(e); } - console.log("%s total bytes used", bytes); - }); - call.getServerHash(function (e, hash) { if (e) { return void console.error(e); } console.log("the server believes your user hash is [%s]", hash); @@ -51,6 +46,11 @@ define([ var localHash = call.localChannelsHash(); var serverHash; + call.getFileListSize(function (e, bytes) { + if (e) { return void console.error(e); } + console.log("%s total bytes used", bytes); + }); + call.getServerHash(function (e, hash) { if (e) { return void console.error(e); } serverHash = hash; @@ -64,10 +64,21 @@ define([ var list = call.uniqueChannelList(); + var left = list.length; + // now start pinning... list.forEach(function (channel) { - call.pin(channel, function (e, out) { - if (e) { return console.error(e); } + call.pin(channel, function (e, hash) { + left--; + + if (!e) { + console.log('pinned channel [%s]. new hash is [%s]', channel, hash); + } else { + console.error(e); + } + if (left === 0) { + console.log('done pinning'); + } }); }); });