Skip to content
This repository has been archived by the owner on Dec 10, 2020. It is now read-only.

ethashjs/index.js - Array.fill() does not exist #6

Closed
bokkypoobah opened this issue Mar 15, 2016 · 3 comments
Closed

ethashjs/index.js - Array.fill() does not exist #6

bokkypoobah opened this issue Mar 15, 2016 · 3 comments

Comments

@bokkypoobah
Copy link

Hi,

I'm getting the following error from ethashjs/index.js. The text fullSize, n, w, s and mixhashes are just my additional debugging logs. The problem occurred before I added the debugging information.

block number (hex) 0x1199e1
fullSize : 1392507008
n : 21757922
w : 32
s : ?1w�V��FJ��Ey��[��fj�#�׋�V.
g�)����Bm��eU\y��cB3�?�f�[�� �i�ٗ
mixhashes: 2

/home/beef/BeefPool/node_modules/ethashjs/index.js:60
var mix = Buffer.concat(Array(mixhashes).fill(s))
^
TypeError: Object , has no method 'fill'
at Ethash.run (/home/beef/BeefPool/node_modules/ethashjs/index.js:60:44)
at /home/beef/BeefPool/shareHandler.js:43:19
at Object._onImmediate (/home/beef/BeefPool/node_modules/ethashjs/node_modules/levelup/lib/levelup.js:258:9)
at processImmediate as _immediateCallback

The snippet from ethashjs/index.js modified with my debugging information:
Ethash.prototype.run = function (val, nonce, fullSize) {
fullSize = fullSize || this.fullSize
console.log("fullSize : " + fullSize);
const n = Math.floor(fullSize / ethHashUtil.params.HASH_BYTES)
console.log("n : " + n);
const w = Math.floor(ethHashUtil.params.MIX_BYTES / ethHashUtil.params.WORD_BYTES)
console.log("w : " + w);
const s = ethUtil.sha3(Buffer.concat([val, ethHashUtil.bufReverse(nonce)]), 512)
console.log("s : " + s);
const mixhashes = Math.floor(ethHashUtil.params.MIX_BYTES / ethHashUtil.params.HASH_BYTES)
console.log("mixhashes: " + mixhashes);
var mix = Buffer.concat(Array(mixhashes).fill(s))

@bokkypoobah
Copy link
Author

I git cloned a new copy of this library and ran the example with the following results:

git clone https://github.com/ethereumjs/ethashjs.git
cd ethashjs
npm install
cd example
node example
beef@localhost:~/test/ethashjs/example$ node example.js

/home/beef/test/ethashjs/index.js:54
var mix = Buffer.concat(Array(mixhashes).fill(s))
^
TypeError: Object , has no method 'fill'
at Ethash.run (/home/beef/test/ethashjs/index.js:54:44)
at Object. (/home/beef/test/ethashjs/example/example.js:7:21)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3

@bokkypoobah
Copy link
Author

I've just installed nodejs v4x instead of the default Ubuntu packaged version and the example works. I'll test the other areas. Don't worry about this at the moment - hopefully it's not a problem at all and just a nodejs version issue.

@bokkypoobah
Copy link
Author

This is not an issue with your library. I was using the wrong version of nodejs that comes packaged with Ubuntu by default. I've installed nodejs 4x from the nodesource repository and it's all working. Closing this issue. Have a good day.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant