create account

Distributed calculations in your browser (beta) by sau412

View this thread on: hive.blogpeakd.comecency.com
· @sau412 · (edited)
$2.25
Distributed calculations in your browser (beta)
I created new project for distributed computing. It is successor of my previous project, distributed prime searching in browser.

![](https://cdn.steemitimages.com/DQmRnAKUEafeAqJi31izHG7gu5UKUfAfeeDsDY8YquLH4tF/%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5.png)

Improvements from my previous project:
* Larger workunits (workunit size can be changed without stopping project)
* Using JS threads
* Different types of workunits are possible
* Checking workunit results between users

Project in beta now. That means I can reset results when needed (but not your payouts). After some time I create release and move project to external hosting. Currently it hosted on my netbook.

# Current project
Twin primes - finding twin primes below 9×10<sup>15</sup> ([wiki link](https://en.wikipedia.org/wiki/Twin_prime)). Value 9×10<sup>15</sup> is upper limit of javascript integer variable. It could be avoided later.

# Rewards
Currently 0.0001 GRC per completed workunit. It could be adjusted later. Payroll happens daily.

# Future plans
I'm planning to implement next projects here:
* Amicable checker - check if BOINC amicable numbers didn't miss any amicable numbers.
* Collatz checker - analog for collatz conjecture.
* Anybody can add their own function - function format is easy as possible (but there is some limitations, because storage is limited). Also you can run your own instance, project is opensourced.

# Checking function
Each project should have checking function in JavaScript. Input is interval: start number and stop number, they are received with message. Function reports progress and results (when done). As I said above it's pretty easy. Sample for prime twins searching:
````
// Event listener. Listens to message with input parameters
self.addEventListener('message', function(e) {
	var thread_index = e.data[0];
	var workunit_result_uid = e.data[1];
	var start_number = parseInt(e.data[2]);
	var stop_number = parseInt(e.data[3]);
	var version = 1;

	// Check each number and report progress
	function check_number_seq(thread_index, start_number, stop_number) {
		var number;
		var seq_result = [];
		var is_prime;
		var progress = 0;
		progress_report_interval=Math.floor((stop_number-start_number)/100);
		progress_report=start_number;

		if((start_number % 2) == 0) start_number++;

		for(number=start_number; number<=stop_number; number+=2) {
			// Check number
			result = check_number(number);
			if(result !== null) {
				// Add number to results
				seq_result.push(number);
				// Optimization - next 4 numbers can be skipped
				number+=4;
			}
			// Report progress
			if(number > progress_report) {
				progress=(number-start_number)/(stop_number-start_number);
				self.postMessage([thread_index,0,progress]);
				progress_report+=progress_report_interval;
			}
		}
		// Return result
		return seq_result;
	}

	var result = check_number_seq(thread_index, start_number, stop_number);
	// Return result with message to parent thread
	self.postMessage([thread_index, 1, version, workunit_result_uid, result]);
}, false);

// Number checking function
// Returns null if not twin
// Returns first of twins otherwise
function check_number(number) {
        if((number%2)==0) return null;
        if(check_is_prime(number) && check_is_prime(number+2)) return [number,number+2];
        return null;
}

// Check is number prime or not
function check_is_prime(number) {
        number=parseInt(number);
        var i;
        var limit=Math.floor(Math.sqrt(number));
        for(i=2;i<=limit;i++) {
                if((number%i) == 0) return 0;
        }
        return 1;
}

````

# Links
* Project https://netbook.arikado.ru/microgrid/
* Github https://github.com/sau412/microgrid
* Twin primes https://en.wikipedia.org/wiki/Twin_primes
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorsau412
permlinkdistributed-calculations-in-yout-browser-beta
categorygridcoin
json_metadata{"tags":["gridcoin","microgrid","grid"],"image":["https://cdn.steemitimages.com/DQmRnAKUEafeAqJi31izHG7gu5UKUfAfeeDsDY8YquLH4tF/%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5.png"],"links":["https://en.wikipedia.org/wiki/Twin_prime","https://netbook.arikado.ru/microgrid/","https://github.com/sau412/microgrid","https://en.wikipedia.org/wiki/Twin_primes"],"app":"steemit/0.1","format":"markdown"}
created2019-02-12 12:33:12
last_update2019-02-12 12:38:30
depth0
children2
last_payout2019-02-19 12:33:12
cashout_time1969-12-31 23:59:59
total_payout_value1.723 HBD
curator_payout_value0.523 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,786
author_reputation8,198,119,818,978
root_title"Distributed calculations in your browser (beta)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id79,765,798
net_rshares4,531,638,989,856
author_curate_reward""
vote details (34)
@h202 ·
Awesome, I'm imagining right now calculations I'd be interested to put on there.
👍  
properties (23)
authorh202
permlinkre-sau412-distributed-calculations-in-yout-browser-beta-20190212t234917926z
categorygridcoin
json_metadata{"tags":["gridcoin"],"app":"steemit/0.1"}
created2019-02-12 23:49:18
last_update2019-02-12 23:49:18
depth1
children1
last_payout2019-02-19 23:49:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length80
author_reputation260,059,645,359
root_title"Distributed calculations in your browser (beta)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id79,791,120
net_rshares13,311,521,248
author_curate_reward""
vote details (1)
@grider123 ·
If you ever decide to try some interesting calculations there I'd be willing to do some crunching :D
👍  
properties (23)
authorgrider123
permlinkre-h202-re-sau412-distributed-calculations-in-yout-browser-beta-20190213t140533646z
categorygridcoin
json_metadata{"tags":["gridcoin"],"app":"steemit/0.1"}
created2019-02-13 14:05:33
last_update2019-02-13 14:05:33
depth2
children0
last_payout2019-02-20 14:05:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length100
author_reputation107,965,352,035,530
root_title"Distributed calculations in your browser (beta)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id79,816,084
net_rshares16,167,934,879
author_curate_reward""
vote details (1)