├── README.md ├── config.js ├── package.json ├── run.js ├── views ├── address.jade ├── index.jade.save └── index.jade ├── ethRPC.js └── runServer.js /README.md: -------------------------------------------------------------------------------- 1 | # EtherPool-Frontend 2 | 3 | This is the code for weipool's frontend. 4 | 5 | # Requirements 6 | 7 | 1. Redis 8 | 2. Node 9 | 3. EtherPool 10 | 11 | # Usage 12 | 13 | Type 14 | 15 | > node run.js 16 | 17 | to start the service that calculates the hashrates 18 | 19 | > node runServer.js 20 | 21 | to start the webserver 22 | -------------------------------------------------------------------------------- /config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | ethServer : { 3 | host: '127.0.0.1', 4 | path: '/', 5 | //since we are listening on a custom port, we need to specify it by hand 6 | port: '8079', 7 | //This is what changes the request to a POST request 8 | method: 'POST' 9 | }, 10 | 11 | poolAddress : "0xd1e56c2e765180aa0371928fd4d1e41fbcda34d4", 12 | 13 | redisPassword : "your password here" 14 | }; 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ethfrontend", 3 | "version": "0.0.0", 4 | "description": "", 5 | "main": "run.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "BSD-2-Clause", 11 | "dependencies": { 12 | "jade": "~1.11.0", 13 | "redis": "~2.0.0", 14 | "express": "~4.13.3", 15 | "body-parser": "~1.14.0", 16 | "http": "0.0.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /run.js: -------------------------------------------------------------------------------- 1 | var redis = require("redis"); 2 | var config = require('./config.js'); 3 | 4 | 5 | 6 | var client = redis.createClient(); 7 | client.auth(config.redisPassword, redis.print); 8 | 9 | var twentyMin = 60*20*1000; 10 | 11 | 12 | 13 | var interval = 1*60*1000; 14 | 15 | setInterval(function(){ 16 | var currentTime = new Date().getTime(); 17 | //get all the shares 18 | client.del("20minshares"); 19 | client.keys("shares:*", function(err, response){ 20 | //loop through each address 21 | response.forEach(function(address, i){ 22 | //get shares 23 | client.zrangebyscore(address, (currentTime - twentyMin), currentTime, function(err, response){ 24 | var shares = 0; 25 | response.forEach(function(share, i){ 26 | var array = share.split(":"); 27 | shares = shares + parseInt(array[0]); 28 | }); 29 | client.zadd("20minshares", shares, address.split(":")[1] + ":" + shares); 30 | client.zadd("20minsharespersonal", shares, address.split(":")[1]); 31 | }); 32 | }); 33 | }); 34 | 35 | console.log("updated shares"); 36 | }, interval); 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /views/address.jade: -------------------------------------------------------------------------------- 1 | html 2 | head 3 | title Weipool 4 | link(href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css", rel="stylesheet") 5 | link(href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css", rel="stylesheet") 6 | script(src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js") 7 | body 8 | 9 | 10 | nav(class="navbar navbar-inverse navbar-static-top") 11 | div(class="container-fluid") 12 | div(class="navbar-header") 13 | a(class="navbar-brand" href="/") Weipool 14 | form(class="from-inline") 15 | 16 | 17 | div(class="container") 18 | h1 19 | a(href="https://etherchain.org/account/" + address)= "Your Stats: " + address 20 | h1 NOTE: Your balance is updated a couple times a day after a few blocks have been found! 21 | 22 | div(class="row") 23 | div(class="col-md-3 col-xs-12") 24 | div(class="panel panel-primary") 25 | div(class="panel-heading") Your speed 26 | div(class="panel-body")= yourSpeed/1000000 + " Mh/s" 27 | div(class="col-md-3 col-xs-12") 28 | div(class="panel panel-primary") 29 | div(class="panel-heading") Your round shares 30 | div(class="panel-body")= yourShares 31 | div(class="col-md-3 col-xs-12") 32 | div(class="panel panel-primary") 33 | div(class="panel-heading") Total round shares 34 | div(class="panel-body")= totalShares 35 | div(class="col-md-3 col-xs-12") 36 | div(class="panel panel-primary") 37 | div(class="panel-heading") Your balance 38 | div(class="panel-body")= balance/1000000000000000000 + " ether" 39 | 40 | 41 | h1 Last Payments 42 | table(class="table table-striped") 43 | thead 44 | tr 45 | th Time 46 | th Amount 47 | tbody 48 | - for (var i=0; i 0.1) 83 | tr 84 | td 85 | a(href= "/"+address)= address 86 | td= hashrate 87 | 88 | 89 | 90 | 91 | 92 | --------------------------------------------------------------------------------