Closed jaros1 closed 6 years ago
Most important for money. Add bottom to Money or Wallet page
/* ---- /1GLndW2MJn7japuF3X2tbfBqgPMR52zaLQ/js/GetAllHub.coffee ---- */ (function () { var GetAllHub, bind = function (fn, me) { return function () { return fn.apply(me, arguments); }; }, extend = function (child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty, indexOf = [].indexOf || function (item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; GetAllHub = (function (superClass) { extend(GetAllHub, superClass); function GetAllHub() { this.onRequest = bind(this.onRequest, this); this.init = bind(this.init, this); return GetAllHub.__super__.constructor.apply(this, arguments); } GetAllHub.prototype.init = function () { return this.siteList = ['1BLueGvui1GdbtsjcKqCf4F67uKfritG49', '1GrEenUGRWnzaNZjR3XsQa6dQgdPDTyt7i', '1RedkCkVaXuVXrqCMpoXQS29bwaqsuFdL', '1oranGeS2xsKZ4jVsu9SVttzgkYXu4k9v', '18FheQ1v3bz4iv5yx8hr9hg5W5BJ8WNJ8d', 'hub.kaffie.bit', '1ARSTRDgMSH2E81pcZCbaEq28TZ72Levxh', '16bNGdxFkGWGnCEfVue3w4CSp3Ew2hcyBB', '12rTbtzcEZH7RiVfShBB3qhoe3rfwbpm8S', '1JUDmCT4UCSdnPsJAHBoXNkDS61Y31Ue52', '1Gb25pK7XqrgnBYjhHLGBjEYURg2MhbJCq', '1HNf26SK9Hi9LES1kUKg6r36hDwhBdNBKM', '1GnSLuqqmB8oRAJ4SK4hvzt6Jo1qAnEbXn', '149fpM31r6YUc7WZ1m28Lq6Ef3zwdBFKBq', '1KNmG5rJUGhgUJGFbLkv2B5isaqu9PrZqi', '1MATTnuthfsvTUqEwtvTR6nMiLmtqGXyfv', '15mV5T1R1wxg3E1FPsvZw19bw6QzvRREfn', '12cm58PYhaSaHUkKgsbf62Rg9Db5DukWYd', '1CiGGh6RrTtaTJfutVKUrfURsP5J4stJDk', '185yXNL48LTZyKfNo6WgyKshtMgcV3mecL', '1AbRRDveQD5EFtmXxBqQfS1guUWXxytMJZ', '1D7xb8vwnWUYSXziENcnoi3meD5Gk2xgFj', '1LQeBa8AgXPd9YXyfTGm9FbcJZTM4p1vgY', '1CouTPX7rK6cyffPCyyxttdZhB1u7NPtqz', '1White24UrrwQrD86o6Vrc1apgZ1x1o51', '1ABFCaadiEa3bFNzN3RcCZSsviqMNTbz3m', '1Jhb5snQN5z198ELyFoj2apeuuaRCM9Pqm', '1N9sU8qh3S4ei9PHE1qQyYPbcckJomvwMd', '1SunAWK2VUT9GQK32MpwRfFPVgcBSJN9a', '1H51ZJ118ubwYAceszZ6CRMp4MPaSwcMh1']; }; GetAllHub.prototype.onOpenWebsocket = function () { return this.cmd("siteInfo", {}, (function (_this) { return function (site_info) { _this.permission = indexOf.call(site_info.settings.permissions, 'Merger:ZeroMe') >= 0; return _this.siteInfo = site_info; }; })(this)); }; GetAllHub.prototype.onRequest = function (cmd, message) { if (cmd === "setSiteInfo") { return this.siteInfo = message.params; } else { return this.log("Unknown incoming message:", cmd); } }; GetAllHub.prototype.addHub = function () { if (!this.permission) { this.requirePermission(); return; } return this.cmd('mergerSiteAdd', [this.siteList], (function (_this) { return function (e) { return _this.cmd("wrapperNotification", ["done", "Please click \"add\" to seed these hub and then you can see all post in ZeroMe!", 10000]); }; })(this)); }; GetAllHub.prototype.requirePermission = function () { return this.cmd('wrapperPermissionAdd', ['Merger:ZeroMe'], (function (_this) { return function (e) { if (e === 'Granted') { _this.permission = true; return _this.addHub(); } }; })(this)); }; GetAllHub.prototype.buttonClick = function () { return this.addHub(); }; return GetAllHub; })(ZeroFrame); window.GetAllHub = new GetAllHub(); }).call(this);
Money Network: Get User Data Hubs and Wallet Data Hubs:
select keyvalue.value as hub, case json.file_name when 'data.json' then 'user' else 'wallet' end as hub_type, count(*) as no_users from keyvalue, json where keyvalue.key = 'hub' and keyvalue.value is not null and json.json_id = keyvalue.json_id and json.file_name in ('data.json', 'wallet.json') group by keyvalue.value, case json.file_name when 'data.json' then 'user' else 'wallet' end ;
Add hub title to data.json (MN) and wallet.json (MN wallet sites)? Now only hub address in json files.
select hub, hub_type, hub_title, count(*) as no_users from ( select hub.value as hub, case json.file_name when 'data.json' then 'user' else 'wallet' end as hub_type, (select keyvalue.value from keyvalue where keyvalue.key = 'hub_title' and keyvalue.json_id = hub.json_id) as hub_title from keyvalue as hub, json where hub.key = 'hub' and hub.value is not null and hub.value <> '1JeHa67QEvrrFpsSow82fLypw8LoRcmCXk' and json.json_id = hub.json_id and json.file_name in ('data.json', 'wallet.json') ) group by hub, hub_type, hub_title;
todo: add "Add all hubs" button" to log in page. Alternative wallet and/or user pages. Best as an angularJS template. OK 21 Jan 2017. todo: copy/paste changes in get_my_user_hub to W2. W2 must also add hub_title to wallet.json (now only one W2 wallet data hub. Hub in wallet.json will always be 1HXzvtSLuvxZfh6LgdaqTk4FSVf7x8w7NJ and hub_title will always be blank. Must have a greater number of wallet users to test this change. OK 21 Jan 2017
11:50:43.879 all.js:5416 MoneyNetworkHubService.get_all_hubs: mn query 21 = select hub, hub_type, hub_title, count(*) as no_users from ( select case when hub1 is not null and hub1 <> '1JeHa67QEvrrFpsSow82fLypw8LoRcmCXk' then hub1 else hub2 end as hub, hub_type, hub_title from ( select hub.value as hub1, substr(json.directory, 1, instr(json.directory,'/')-1) as hub2, case json.file_name when 'data.json' then 'user' else 'wallet' end as hub_type, (select keyvalue.value from keyvalue where keyvalue.key = 'hub_title' and keyvalue.json_id = hub.json_id) as hub_title from keyvalue as hub, json where hub.key = 'hub' and json.json_id = hub.json_id and json.file_name in ('data.json', 'wallet.json'))) group by hub, hub_type, hub_title 11:50:43.880 MoneyNetworkAPI.js:253 MoneyNetworkHubService.get_all_hubs: mn query 21 dbQuery started (2). 2 pending ZeroNet API operations (1,2) 11:50:43.962 MoneyNetworkAPI.js:275 MoneyNetworkHubService.get_all_hubs: mn query 21 dbQuery finished. res = "OK. Returned 4 rows". elapsed time 82 ms (2). 2 pending ZeroNet API operations (3,4) 11:50:43.987 MoneyNetworkAPI.js:275 MoneyNetworkService.load_server_info: serverInfo finished. res = "OK". elapsed time 27 ms (4). 1 pending ZeroNet API operation (3) 11:50:43.990 all.js:5494 MoneyNetworkHubService.get_all_hubs mergerSiteList callback 2: all_hubs (3) = [ {"hub":"182Uot1yJ6mZEwQYE5LX1P5f6VPyJ9gUGe","hub_type":"user","hub_title":"U1 User data hub","no_users":134,"add_hub":false,"peers":0}, {"hub":"1HXzvtSLuvxZfh6LgdaqTk4FSVf7x8w7NJ","hub_type":"wallet","hub_title":"W2 Wallet data hub","no_users":36,"add_hub":false,"peers":0}, {"hub":"1PgyTnnACGd1XRdpfiDihgKwYRRnzgz2zh","hub_type":"user","hub_title":"U3 User data hub","no_users":108,"add_hub":false,"peers":9}, {"hub":"1922ZMkwZdFjKbSAdFR1zA5YBHMsZC51uc","hub_type":"user","hub_title":"U2 User data hub","no_users":0,"add_hub":false,"peers":0}
Added section to Auth page with add/remove hubs. todo: change to template/directive and add to Account and Wallet pages.
todo: copy/paste changes in get_my_user_hub to W2. W2 must also add hub_title to wallet.json (now only one W2 wallet data hub. Hub in wallet.json will always be 1HXzvtSLuvxZfh6LgdaqTk4FSVf7x8w7NJ and hub_title will always be blank. Must have a greater number of wallet users to test this change.
Adding hub_title to W2. Problem with startup sequence. No MN-W2 handshake! MN is not listering to incoming files with other session filename 969ba6ba34.
Also a problem that wallet log in is restored from localStorage AFTER finishing api query 5 query. Should be possible to restore wallet log in info for choice = 2 before or while running api query 5.
W2: added get_wallet_login request before checking old and new session in initialize sequence. Only for save_login == '1' (wallet login saved in W2 localStorage). Still no mn-w2 handshake!
Restored mn-w2 handshake with a new wallet test from MN.
Added W2 Wallet Data Hub 2 and tested wallet.json update OK.
17:33:54.327 MoneyNetworkAPI.js:253 MoneyNetworkW2Service.get_my_wallet_hub: mergerSiteList started (4). 1 pending ZeroNet API operation (4) 17:33:54.331 MoneyNetworkAPI.js:275 MoneyNetworkW2Service.get_my_wallet_hub: mergerSiteList finished. res = "OK". elapsed time 4 ms (4). No pending ZeroNet API operations 17:33:54.332 all.js:138309 MoneyNetworkW2Service.get_my_wallet_hub mergerSiteList callback 1: wallet_data_hubs = [{"hub":"17k1QzQRhpkJubxCxaCcD6ytqnp8cqUkXe","title":"W2 Wallet data hub 2"},{"hub":"1HXzvtSLuvxZfh6LgdaqTk4FSVf7x8w7NJ","title":"W2 Wallet data hub 1"}] 17:33:54.332 all.js:138329 MoneyNetworkW2Service.get_my_wallet_hub mergerSiteList callback 1: w2 query 2 = select substr(wallet.directory, 1, instr(wallet.directory,'/')-1) as hub from keyvalue as wallet_address, json as wallet, json as content, keyvalue as modified where wallet_address.key = 'wallet_address' and wallet_address.value = '1LqUnXPEgcS15UGwEgkbuTbKYZqAUwQ7L1' and wallet.json_id = wallet_address.json_id and wallet.directory like '%/18DbeZgtVCcLghmtzvg4Uv8uRQAwR8wnDQ' and content.directory = wallet.directory and content.file_name = 'content.json' and modified.json_id = content.json_id and modified.key = 'modified' order by modified.value desc 17:33:54.332 MoneyNetworkAPI.js:253 MoneyNetworkW2Service.get_my_wallet_hub mergerSiteList callback 1: w2 query 2 dbQuery started (5). 1 pending ZeroNet API operation (5) 17:33:54.340 MoneyNetworkAPI.js:275 MoneyNetworkW2Service.get_my_wallet_hub mergerSiteList callback 1: w2 query 2 dbQuery finished. res = "OK. Returned 1 rows". elapsed time 8 ms (5). No pending ZeroNet API operations 17:33:54.340 all.js:138338 MoneyNetworkW2Service.get_my_wallet_hub.run_callbacks: my_wallet_hub = 1HXzvtSLuvxZfh6LgdaqTk4FSVf7x8w7NJ, other_wallet_hub = 17k1QzQRhpkJubxCxaCcD6ytqnp8cqUkXe, other_wallet_data_hub_title = W2 Wallet data hub 2
wallet.json: { "msgtype": "wallet", "wallet_address": "1LqUnXPEgcS15UGwEgkbuTbKYZqAUwQ7L1", "wallet_title": "MoneyNetworkW2", "wallet_description": "Money Network - Wallet 2 - BitCoins www.blocktrail.com - runner jro", ..... "hub": "17k1QzQRhpkJubxCxaCcD6ytqnp8cqUkXe", "hub_title": "W2 Wallet data hub 2" }
Also tested OK in "montreal". Add "add more hubs" section to W2. copy/paste from MN.
Added add more hubs section to W2
Move get_all_hubs JS code to MoneyNetworkAPI?
get_all_hubs JS code moved to MoneyNetworkAPILib and tested OK in MN and W2
Low number of wallet peers. Add buttom to add all MoneyNetwork data hubs (user data hubs and wallet data hubs). See Get All Hubs http://127.0.0.1:43110/0hub.bit