Commit 26c250a9 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] #1094 Raspberry PI could no more find a block (CPU at 100%, IPC broken)

parent 152c9c4c
......@@ -97,6 +97,9 @@ export const CommonConstants = {
MAXIMUM_LEN_OF_OUTPUT,
MAXIMUM_LEN_OF_UNLOCK,
POW_TURN_DURATION_PC: 100,
POW_TURN_DURATION_ARM: 500,
PROOF_OF_WORK: {
UPPER_BOUND: [
'9A-F',
......
......@@ -5,7 +5,8 @@ import {DBBlock} from "../../../lib/db/DBBlock"
import {CommonConstants} from "../../../lib/common-libs/constants"
import {BlockDTO} from "../../../lib/dto/BlockDTO"
const querablep = require('querablep');
const os = require('os')
const querablep = require('querablep')
const POW_FOUND = true;
const POW_NOT_FOUND_YET = false;
......@@ -168,12 +169,20 @@ export class BlockProver {
this.logger.info('Generating proof-of-work with %s leading zeros followed by [0-' + highMark + ']... (CPU usage set to %s%) for block#%s', nbZeros, (this.conf.cpu * 100).toFixed(0), block.number, block.issuer.slice(0,6));
const start = Date.now();
let result = await powFarm.askNewProof({
newPoW: { conf: {
newPoW: {
turnDuration: os.arch().match(/arm/) ? CommonConstants.POW_TURN_DURATION_ARM : CommonConstants.POW_TURN_DURATION_PC,
conf: {
cpu: this.conf.cpu,
prefix: this.conf.prefix,
avgGenTime: this.conf.avgGenTime,
medianTimeBlocks: this.conf.medianTimeBlocks
}, block: block, zeros: nbZeros, highMark: highMark, forcedTime: forcedTime, pair: this.pair }
},
block: block,
zeros: nbZeros,
highMark: highMark,
forcedTime: forcedTime,
pair: this.pair
}
});
if (!result) {
this.logger.info('GIVEN proof-of-work for block#%s with %s leading zeros followed by [0-' + highMark + ']! stop PoW for %s', block.number, nbZeros, this.pair && this.pair.pub.slice(0,6));
......
......@@ -46,6 +46,9 @@ export class PowEngine {
}
setConf(value:any) {
if (os.arch().match(/arm/) && value.cpu !== undefined) {
value.cpu /= 2; // Don't know exactly why is ARM so much saturated by PoW, so let's divide by 2
}
return this.cluster.changeConf(value)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment