This commit is contained in:
Steven Ettinger 2022-02-03 13:07:10 -03:00
parent a94824f92a
commit 7b49b51497
7 changed files with 58 additions and 34 deletions

View File

@ -47,7 +47,7 @@ const clients = ENV.clients || [
//!!!!!!! -- THESE ARE COMMUNITY CONSTANTS -- !!!!!!!!!//
//TOKEN CONFIGS -- ALL COMMUNITY RUNNERS NEED THESE SAME VALUES
const starting_block = 61419700; //from what block does your token start
const starting_block = 61499500; //from what block does your token start
const prefix = 'spkcc_' //Community token name for Custom Json IDs
const TOKEN = 'LARYNX' //Token name
const precision = 3 //precision of token
@ -70,6 +70,7 @@ const hive_service_fee = 100 //HIVE service fee for transactions in Hive/HBD in
const features = {
pob: false, //proof of brain
delegate: false, //delegation
daily: true,
liquidity: false, //liquidity
ico: false, //ico
dex: true, //dex

6
dao.js
View File

@ -116,7 +116,7 @@ function dao(num) {
post = post + `Total Supply: ${parseFloat(parseInt(stats.tokenSupply) / 1000).toFixed(3)} ${config.TOKEN}\n* ${parseFloat(parseInt(stats.tokenSupply - powBal - (bals.ra + bals.rc + bals.rd + bals.ri + bals.rn + bals.rm)) / 1000).toFixed(3)} ${config.TOKEN} liquid\n`;
post = post + `* ${parseFloat(parseInt(powBal) / 1000).toFixed(3)} ${config.TOKEN} Powered up for Voting\n`;
post = post + `* ${parseFloat(parseInt(bals.ra + bals.rc + bals.rd + bals.ri + bals.rn + bals.rm) / 1000).toFixed(3)} ${config.TOKEN} in distribution accounts\n`;
post = post + `${parseFloat(parseInt(t) / 1000).toFixed(3)} ${config.TOKEN} has been generated today. 5% APY.\n${parseFloat(stats.marketingRate / 10000).toFixed(4)} is the marketing rate.\n${parseFloat(stats.nodeRate / 10000).toFixed(4)} is the node rate.\n`;
if(config.features.inflation)post = post + `${parseFloat(parseInt(t) / 1000).toFixed(3)} ${config.TOKEN} has been generated today. 5% APY.\n${parseFloat(stats.marketingRate / 10000).toFixed(4)} is the marketing rate.\n${parseFloat(stats.nodeRate / 10000).toFixed(4)} is the node rate.\n`;
console.log(`DAO Accounting In Progress:\n${t} has been generated today\n${stats.marketingRate} is the marketing rate.\n${stats.nodeRate} is the node rate.`);
bals.rn += parseInt(t * parseInt(stats.nodeRate) / 10000);
bals.ra = parseInt(bals.ra) - parseInt(t * parseInt(stats.nodeRate) / 10000);
@ -344,7 +344,7 @@ function dao(num) {
dex.hbd.days = {};
dex.hbd.days[num] = hib;
}
let liqt = parseInt((bal.rm/365)*(stats.liq_reward/100))
let liqt = config.features.liquidity ? parseInt((bals.rm/365)*(stats.liq_reward/100)) : 0
if (liqt > 0){
let liqa = 0
for (var acc in dex.liq){
@ -453,7 +453,7 @@ function dao(num) {
daops.push({ type: 'put', path: ['posts'], data: cpost });
daops.push({ type: 'put', path: ['markets', 'node'], data: mnode });
daops.push({ type: 'put', path: ['delegations'], data: deles });
if(config.DAILY)daops.push({ type: 'put', path: ['escrow', config.leader, 'comment'], data: op });
if(config.features.daily)daops.push({ type: 'put', path: ['escrow', config.leader, 'comment'], data: op });
for (var i = daops.length - 1; i >= 0; i--) {
if (daops[i].type == 'put' && Object.keys(daops[i].data).length == 0 && typeof daops[i].data != 'number' && typeof daops[i].data != 'string') {
daops.splice(i, 1);

View File

@ -1,12 +1,12 @@
version: '3'
services:
# snap:
# ports:
# - 8001:8001
# restart: unless-stopped
# build:
# context: .
# dockerfile: ./snap/Dockerfile
snap:
ports:
- 8001:8001
restart: unless-stopped
build:
context: .
dockerfile: ./snap/Dockerfile
ipfs:
# docker run -d --name ipfs_host -v $ipfs_staging:/export -v $ipfs_data:/data/ipfs -p 4001:4001 -p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 ipfs/go-ipfs:latest
image: ipfs/go-ipfs:latest
@ -36,7 +36,7 @@ services:
- ipfshost=ipfs
- ipfsprotocol=http
- ipfsport=5001
# - SNAPBASE_URL=http://localhost:8001
- SNAPBASE_URL=http://snap:8001
stdin_open: true
tty: true
# node-2:

View File

@ -132,8 +132,8 @@ var recents = []
//HIVE API CODE
//Start Program Options
//startWith('', true) //for testing and replaying 58859101
dynStart(config.follow)
startWith('', true) //for testing and replaying 58859101
//dynStart(config.follow)
// API defs
@ -472,7 +472,8 @@ function startApp() {
.catch(e => { rej(e) })
}))
}
if ((num - 20003) % 30240 === 0) { //time for daily magic
console.log((num - 18500) % 28800)
if ((num - 18500) % 28800 === 0) { //time for daily magic
promises.push(dao(num))
block.prev_root = block.root
block.root = ''
@ -842,25 +843,30 @@ function rundelta(arr, ops, sb, pr){
delta(values)
function delta(a){
if(a.length){
console.log('Blocks to apply:', a.length)
const b = JSON.parse(a.shift())
startingBlock = b[0]
delsfirst(b[1].ops).then(emp=>store.batch(unwrapOps(b[1].ops)[1], [delta, reject, a ? a : []]))
unwrapOps(b[1].ops).then(last=>{
if(last.length){
store.batch(last, [delta, reject, a ? a : []])
} else delta(a ? a : [])
})
} else {
console.log('Current Block')
block.ops = []
block.chain = arr
block.prev_root = pr
startingBlock = sb
delsfirst(ops).then(emp=>store.batch(unwrapOps(ops)[1], [reorderOps, reject, a ? a : []]))
unwrapOps(ops).then(last=>{
if(last.length){
store.batch(last, [reorderOps, reject, a ? a : []])
} else reorderOps()
})
}
function reorderOps(){
block.ops = ops
resolve([])
}
function delsfirst(b){
return new Promise((resolv, rejec) => {
store.batch(unwrapOps(b)[0], [resolv, rejec, 'OK'])
})
}
}
})
.catch(e=>reject(e))
@ -868,14 +874,26 @@ function rundelta(arr, ops, sb, pr){
}
function unwrapOps(arr){
var c = [],
return new Promise((resolve, reject) => {
var d = []
write(0)
function write (int){
d = []
for(var i = 0; i < arr.length; i++){
const e = JSON.parse(arr[i])
if (e.type != 'del')c.push(e)
else d.push(e)
}
return [d,c]
for(var i = int; i < arr.length; i++){
var e = arr[i]
try {
e = JSON.parse(e)
} catch(e){e = arr[i]}
if (e == 'W' && d.length && i != arr.length -1){
store.batch(d, [write, null, i+1])
break
} else if (e == 'W' && i == arr.length -1){
resolve(d)
} else if (e == 'W'){
} else d.push(e)
}
}
})
}
function ipfspromise(hash){
@ -887,9 +905,12 @@ function ipfspromise(hash){
resolve(data)
}
})
fetch(`https://ipfs.infura.io/ipfs/${hash}`)
fetch(`https://ipfs.io/ipfs/${hash}`)
.then(r=>r.text())
.then(res => {resolve(res)})
.catch(e=>console.log(e))
.catch(e=>{fetch(`https://ipfs.infura.io/ipfs/${hash}`)
.then(r=>r.text())
.then(res => {resolve(res)})
.catch(e=>reject(e))})
})
}

View File

@ -54,8 +54,10 @@ Pathwise.prototype.batch = function(ops, pc) { // promise chain[resolve(), rejec
console.log('fail', err)
pc[1](err)
} else if (pc.length > 2) {
block.ops.push('W')
batch.write(()=>{pc[0](pc[2])})
} else {
block.ops.push('W')
batch.write(()=>{pc[0]()})
}
});

View File

@ -113,7 +113,7 @@ exports.comment_options = (json, pc) => {
}
var ops = []
for (var i = 0; i < filter.length; i++) {
if (filter[i].account == config.ben && filter[i].weight >= config.delegationWeight) {
if (config.features.pob && filter[i].account == config.ben && filter[i].weight >= config.delegationWeight) {
store.get(['pend', `${json.author}/${json.permlink}`], function(e, a) {
if (e) { console.log(e) }
if (Object.keys(a).length) {

View File

@ -16,8 +16,8 @@ RUN \
RUN python3.8 -m pip install --upgrade pip
#Copy the source code
#COPY . /snapshot/
RUN git clone https://gitlab.com/PBSA/3speak-integration.git
COPY . /snapshot/
RUN git clone https://gitlab.com/PBSA/3speak-integration.git -b wip-main
WORKDIR /3speak-integration/claimdropweb
#Installing the requirements
RUN pip3 install -r requirements.txt