1.1.4f
This commit is contained in:
parent
51024a16e3
commit
e462d421f3
15
helpers.js
15
helpers.js
|
@ -625,6 +625,21 @@ const DEX = {
|
|||
}
|
||||
exports.DEX = DEX
|
||||
|
||||
var log = {
|
||||
last: 0,
|
||||
block: function (num) {
|
||||
if (log.last + 1 == num || !log.last) {
|
||||
log.last = num;
|
||||
console.log(`${num}`);
|
||||
} else {
|
||||
log.last = num;
|
||||
console.log(`${num} WARNING`);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
exports.Log = log
|
||||
|
||||
const Watchdog = {
|
||||
current : 0,
|
||||
timeout: config.timeoutStart,
|
||||
|
|
9
index.js
9
index.js
|
@ -1,5 +1,5 @@
|
|||
const config = require("./config");
|
||||
const VERSION = "v1.1.4e"; //Did you change the package version?
|
||||
const VERSION = "v1.1.4f"; //Did you change the package version?
|
||||
exports.VERSION = VERSION;
|
||||
exports.exit = exit;
|
||||
exports.processor = processor;
|
||||
|
@ -131,7 +131,7 @@ let TXID = {
|
|||
exports.TXID = TXID;
|
||||
const API = require("./routes/api");
|
||||
const HR = require("./processing_routes/index");
|
||||
const { NFT, Chron, Watchdog } = require("./helpers");
|
||||
const { NFT, Chron, Watchdog, Log } = require("./helpers");
|
||||
const { release } = require("./processing_routes/dex");
|
||||
const { enforce } = require("./enforce");
|
||||
const { tally } = require("./tally");
|
||||
|
@ -243,7 +243,6 @@ http.listen(config.port, function () {
|
|||
if (config.rta && config.rtp) {
|
||||
rtrades.handleLogin(config.rta, config.rtp);
|
||||
}
|
||||
|
||||
//starts block processor after memory has been loaded
|
||||
function startApp() {
|
||||
TXID.blocknumber = 0;
|
||||
|
@ -253,7 +252,7 @@ function startApp() {
|
|||
}
|
||||
if (res) plasma.id = res.id;
|
||||
});
|
||||
processor = hiveState(client, startingBlock, 10, config.prefix);
|
||||
processor = hiveState(client, startingBlock, config.prefix);
|
||||
processor.on("send", HR.send);
|
||||
processor.on("spk_send", HR.spk_send);
|
||||
processor.on("claim", HR.drop_claim);
|
||||
|
@ -333,7 +332,7 @@ function startApp() {
|
|||
}
|
||||
//do things in cycles based on block time
|
||||
processor.onBlock(function (num, pc, prand, bh) {
|
||||
console.log(num);
|
||||
Log.block(num)
|
||||
if (num < TXID.blocknumber) {
|
||||
require("process").exit(2);
|
||||
} else {
|
||||
|
|
84
processor.js
84
processor.js
|
@ -1,9 +1,8 @@
|
|||
const fetch = require('node-fetch');
|
||||
const { TXID, block } = require('./index');
|
||||
const { TXID } = require('./index');
|
||||
module.exports = function (
|
||||
client,
|
||||
currentBlockNumber = 1,
|
||||
blockComputeSpeed = 1000,
|
||||
nextBlock = 1,
|
||||
prefix = ""
|
||||
) {
|
||||
var onCustomJsonOperation = {}; // Stores the function to be run for each operation id.
|
||||
|
@ -16,48 +15,48 @@ module.exports = function (
|
|||
var stream;
|
||||
var blocks = {
|
||||
processing: 0,
|
||||
time: 0,
|
||||
completed: 0,
|
||||
completed: nextBlock,
|
||||
ensure: function (last) {
|
||||
setTimeout(()=>{if(!blocks.processing && blocks.completed == last){getBlockNumber(currentBlockNumber);
|
||||
setTimeout(()=>{if(!blocks.processing && blocks.completed == last){getBlockNumber(nextBlock);
|
||||
getHeadOrIrreversibleBlockNumber(function (result) {
|
||||
if (currentBlockNumber < result - 10) {
|
||||
behind = result - currentBlockNumber;
|
||||
if (nextBlock < result - 3) {
|
||||
behind = result - nextBlock;
|
||||
beginBlockComputing();
|
||||
}
|
||||
});};},6000)
|
||||
},
|
||||
v: {},
|
||||
manage: function (block_num){
|
||||
if (
|
||||
block_num == currentBlockNumber &&
|
||||
!blocks.processing
|
||||
) {
|
||||
blocks.processing = currentBlockNumber;
|
||||
processBlock(blocks[block_num], block_num).then(() => {
|
||||
currentBlockNumber = block_num;
|
||||
if (blocks.processing){
|
||||
setTimeout(()=>{blocks.manage(block_num)},100)
|
||||
var blockNums = Object.keys(blocks);
|
||||
for (var i = 0; i < blockNums.length; i++) {
|
||||
if (
|
||||
parseInt(blockNums[i]) &&
|
||||
parseInt(blockNums[i]) < nextBlock - 1
|
||||
) {
|
||||
delete blocks[blockNums[i]];
|
||||
}
|
||||
}
|
||||
} else if ( block_num == nextBlock) {
|
||||
blocks.processing = nextBlock;
|
||||
processBlock(blocks[block_num]).then(() => {
|
||||
nextBlock = block_num + 1 ;
|
||||
blocks.completed = blocks.processing;
|
||||
blocks.processing = 0
|
||||
delete blocks[block_num];
|
||||
});
|
||||
} else if (block_num > currentBlockNumber) {
|
||||
if (
|
||||
blocks[currentBlockNumber + 1] &&
|
||||
!blocks.processing
|
||||
) processBlock(blocks[block_num], block_num).then(() => {
|
||||
delete blocks[block_num];
|
||||
currentBlockNumber = block_num;
|
||||
blocks.completed = blocks.processing;
|
||||
blocks.processing = 0;
|
||||
});
|
||||
else if (!blocks[block_num]) getBlockNumber(block_num);
|
||||
} else if (block_num <= currentBlockNumber) {
|
||||
var blockNums = Object.keys(blocks);
|
||||
for (var i = 0; i < blockNums.length; i++) {
|
||||
if (parseInt(blockNums[i]) && parseInt(blockNums[i]) < currentBlockNumber) {
|
||||
delete blocks[blockNums[i]];
|
||||
}
|
||||
}
|
||||
} else if (block_num > nextBlock) {
|
||||
if ( blocks[nextBlock]) {
|
||||
processBlock(blocks[nextBlock]).then(
|
||||
() => {
|
||||
delete blocks[nextBlock];
|
||||
nextBlock++
|
||||
blocks.completed = blocks.processing;
|
||||
blocks.processing = 0;
|
||||
}
|
||||
);
|
||||
} else if (!blocks[nextBlock]) getBlockNumber(nextBlock);
|
||||
}
|
||||
blocks.ensure(block_num);
|
||||
}
|
||||
|
@ -96,10 +95,10 @@ module.exports = function (
|
|||
|
||||
function isAtRealTime(computeBlock) {
|
||||
getHeadOrIrreversibleBlockNumber(function (result) {
|
||||
if (currentBlockNumber >= result) {
|
||||
if (nextBlock >= result) {
|
||||
beginBlockStreaming();
|
||||
} else {
|
||||
behind = result - currentBlockNumber;
|
||||
behind = result - nextBlock;
|
||||
computeBlock();
|
||||
}
|
||||
});
|
||||
|
@ -193,8 +192,9 @@ function getBlock(bn) {
|
|||
}
|
||||
|
||||
function beginBlockComputing() {
|
||||
var blockNum = currentBlockNumber; // Helper variable to prevent race condition
|
||||
var blockNum = nextBlock; // Helper variable to prevent race condition
|
||||
// in getBlock()
|
||||
blocks.ensure(nextBlock)
|
||||
//var vops = getVops(blockNum);
|
||||
getBlock(blockNum)
|
||||
.then((result) => {
|
||||
|
@ -211,9 +211,9 @@ function getBlock(bn) {
|
|||
if (parseInt(bl.block_id.slice(0, 8), 16) != blockNum) return;
|
||||
else
|
||||
return new Promise((resolve, reject) => {
|
||||
processBlock(bl, blockNum)
|
||||
processBlock(bl)
|
||||
.then((r) => {
|
||||
currentBlockNumber++;
|
||||
nextBlock++;
|
||||
if (!stopping && !remaining) {
|
||||
isAtRealTime(beginBlockComputing);
|
||||
} else if (remaining) {
|
||||
|
@ -358,11 +358,11 @@ function getBlock(bn) {
|
|||
}
|
||||
}
|
||||
|
||||
function processBlock(block, num, Pvops) {
|
||||
function processBlock(block, Pvops) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var transactions = block.transactions;
|
||||
let ops = [];
|
||||
if (parseInt(block.block_id.slice(0, 8), 16) === num){
|
||||
if (parseInt(block.block_id.slice(0, 8), 16) === nextBlock){
|
||||
for (var i = 0; i < transactions.length; i++) {
|
||||
for (var j = 0; j < transactions[i].operations.length; j++) {
|
||||
var op = transactions[i].operations[j];
|
||||
|
@ -397,7 +397,7 @@ function getBlock(bn) {
|
|||
}
|
||||
}
|
||||
}
|
||||
transactional(ops, 0, [resolve, reject], num, block, Pvops);
|
||||
transactional(ops, 0, [resolve, reject], nextBlock, block, Pvops);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ function getBlock(bn) {
|
|||
},
|
||||
|
||||
getCurrentBlockNumber: function () {
|
||||
return currentBlockNumber;
|
||||
return nextBlock;
|
||||
},
|
||||
|
||||
isStreaming: function () {
|
||||
|
|
14
tally.js
14
tally.js
|
@ -440,12 +440,16 @@ function verify(trx, sig, at){
|
|||
} else if (err.data.code == 3010000) { //missing authority
|
||||
console.log('MISSING')
|
||||
sendit(tx, sg, t, j+1)
|
||||
} else if (err.data.code == 10) { //duplicate transaction
|
||||
console.log('SENT:Verifier')
|
||||
resolve('SENT')
|
||||
} else if (
|
||||
err.data.code == 10 ||
|
||||
err.data.code == -32603
|
||||
) {
|
||||
//duplicate transaction
|
||||
console.log("SENT:Verifier");
|
||||
resolve("SENT");
|
||||
} else {
|
||||
console.log(err.data)
|
||||
sendit(tx, sg, t, j+1)
|
||||
console.log(err.data);
|
||||
sendit(tx, sg, t, j + 1);
|
||||
}
|
||||
} else {
|
||||
hiveClient.api.broadcastTransactionSynchronous(tx, function(err, result) {
|
||||
|
|
Loading…
Reference in New Issue