-
Notifications
You must be signed in to change notification settings - Fork 1
/
staking.js
108 lines (77 loc) · 4.9 KB
/
staking.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright (C) 2018 EdwardNolan, Lakewood OH 44107, nolanedward@sbcglobal.net
// All rights reserved. 7/1/18
var check = 0;
var sofarsogood = 0; // This is essentially the mempool. Its also part of BIP35 (Bitcoin Improvement Proposal)
var letsConfirm = [];
var staking = 0
var spendable = 0
sofarsogood = sofarsogood + 1; // pending transactions = mempool = sofarsogood
function genesisCoins(){
blockClone = blocks.slice(check); // make a clone of blocks console.log("blocks:", blocks); console.log("blockClone:", blockClone);
letsConfirm.unshift(blockClone[0]); // console.log("letsConfirm:", letsConfirm);
var lcHash = letsConfirm[0].Hash; // Get Hash value from blockClone[] through letsConfirm[]
var blHash = blocks[check].Hash; // Get Hash value from block
var blRewardvalue = blocks[check].PvPCoins; // Get reward amount from block console.log("lcHash:", lcHash); console.log("blHash:", blHash);
if (lcHash === blHash){
blocks[check].confirmed = 1; // console.log("They match!", ); console.log("block confirmed = 1?", blocks[0].confirmed); REHASH BLOCK AS A LOCK?
spendable = spendable + blRewardvalue; // console.log("spendable", spendable);
document.getElementById("spend").innerHTML = spendable;
blockClone.splice(0); // remove this block now from clone, now thats its confirmed
check = check + 1;
letsConfirm = []; // console.log("Block Reward Value?", blRewardvalue);
// spendable = spendable + blRewardvalue; // console.log("spendable", spendable);
// document.getElementById("spend").innerHTML = spendable;
miningReward = (miningReward - blRewardvalue);
if (miningReward < 0){
miningReward = 0;
}
document.getElementById("unconfirmed").innerHTML = miningReward;
}
}
function stakeCoins(){ // moves coins from mempool unconfirmed on dom to staking on dom via sofarsogood
blockClone = blocks.slice(check); // make a clone of blocks console.log("blocks:", blocks); console.log("blockClone:", blockClone);
letsConfirm.unshift(blockClone[0]); // console.log("letsConfirm:", letsConfirm);
var lcHash = letsConfirm[0].Hash; // Get Hash value from blockClone[] through letsConfirm[]
var blHash = blocks[check].Hash; // Get Hash value from block
var blRewardvalue = blocks[check].PvPCoins; // Get reward amount from block console.log("lcHash:", lcHash); console.log("blHash:", blHash);
if (lcHash === blHash){
blocks[check].confirmed = 1; // console.log("They match!", ); console.log("block confirmed = 1?", blocks[0].confirmed); REHASH BLOCK AS A LOCK?
blockClone.splice(0); // remove this block now from clone, now thats its confirmed
check = check + 1;
letsConfirm = []; // console.log("Block Reward Value?", blRewardvalue);
staking = staking + blRewardvalue; // console.log("staking", staking);
document.getElementById("staking").innerHTML = staking; // 200 confirmations b4 becoming spendable
miningReward = (miningReward - blRewardvalue);
if (miningReward < 0){
miningReward = 0;
}
document.getElementById("unconfirmed").innerHTML = miningReward;
}
}
// console.log("Index+1", blocks.Index+1);
// console.log("block.Index", block.Index);
if (sofarsogood > 3){ stakeCoins() } // Wait 3 hands MEMPOOL b4 starting to compare/confirm, wagers/blocks and start staking?
genesisCoins()
function transferCoins(){
sofarsogood = sofarsogood + 1;
if (sofarsogood > 3){ // mempool = sofarsogood = pending transactions
blockClone = blocks.slice(check); // make a clone of blocks console.log("blocks:", blocks); console.log("blockClone:", blockClone);
letsConfirm.unshift(blockClone[0]); // console.log("letsConfirm:", letsConfirm);
var lcHash = letsConfirm[0].Hash; // Get Hash value from blockClone[] through letsConfirm[]
var blHash = blocks[check].Hash; // Get Hash value from block
var blRewardvalue = blocks[check].PvPCoins; // Get reward amount from block console.log("lcHash:", lcHash); console.log("blHash:", blHash);
if (lcHash === blHash){
blocks[check].confirmed = 1; // console.log("They match!", ); console.log("block confirmed = 1?", blocks[0].confirmed); REHASH BLOCK AS A LOCK?
blockClone.splice(0); // remove this block now from clone, now thats its confirmed
check = check + 1;
letsConfirm = []; // console.log("Block Reward Value?", blRewardvalue);
staking = staking + blRewardvalue; // console.log("staking", staking);
document.getElementById("staking").innerHTML = staking;
miningReward = (miningReward - blRewardvalue);
if (miningReward < 0){
miningReward = 0;
}
document.getElementById("unconfirmed").innerHTML = miningReward;
}
}
}