block-syncer-js

Fast block sync and retrieval using bloom filters
git clone git://git.defalsify.org/block-sync-js.git
Info | Log | Files | Refs

plugin.js (999B)


      1 function fetcher(settings) {
      2 	let xhr = new XMLHttpRequest();
      3 	xhr.responseType = 'json';
      4 	xhr.open('GET', 'http://localhost:5555/tx/0/100');
      5 	xhr.addEventListener('load', async (e) => {
      6 		const d = xhr.response;
      7 
      8 		//const digest = await crypto.subtle.digest('SHA-256', ArrayBuffer.from(d.block_filter))
      9 		//console.log('block filter digest', digest)
     10 
     11 		const block_filter_binstr = window.atob(d.block_filter);
     12 		let b_one = new Uint8Array(block_filter_binstr.length);
     13 		b_one.map(function(e, i, v) {
     14 			v[i] = block_filter_binstr.charCodeAt([i]);
     15 		});
     16 
     17 		const blocktx_filter_binstr = window.atob(d.blocktx_filter);
     18 		let b_two = new Uint8Array(blocktx_filter_binstr.length);
     19 		b_two.map(function(e, i, v) {
     20 			v[i] = blocktx_filter_binstr.charCodeAt([i]);
     21 		});
     22 		for (let i = 0; i < block_filter_binstr.length; i++) {
     23 			if (b_one[i] > 0 ) {
     24 				console.debug('blocktx value on', i);
     25 			}
     26 		}
     27 		
     28 		settings.scanFilter(settings, d.low, d.high, b_one, b_two, d.filter_rounds)
     29 	});
     30 	xhr.send();
     31 }