Skip to content

Commit

Permalink
fix buffertool's fill calls
Browse files Browse the repository at this point in the history
  • Loading branch information
maraoz committed Feb 18, 2014
1 parent d961818 commit bf0010b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions bitcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports.Peer = require('./Peer');
module.exports.Block = require('./Block');
module.exports.Connection = require('./Connection');
module.exports.ScriptInterpreter = require('./ScriptInterpreter');
module.exports.networks = require('./networks');


if (typeof process.versions === 'undefined') {
Expand Down
5 changes: 3 additions & 2 deletions networks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var Put = require('bufferput');
var buffertools = require('buffertools');
var hex = function(hex) {return new Buffer(hex, 'hex');};

exports.livenet = {
Expand All @@ -10,7 +11,7 @@ exports.livenet = {
nonce: 2083236893,
version: 1,
hash: hex('6FE28C0AB6F1B372C1A6A246AE63F74F931E8365E15A089C68D6190000000000'),
prev_hash: new Buffer(32).fill(0),
prev_hash: buffertools.fill(new Buffer(32), 0),
timestamp: 1231006505,
merkle_root: hex('3BA3EDFD7A7B12B27AC72C3E67768F617FC81BC3888A51323A9FB8AA4B1E5E4A'),
bits: 486604799
Expand Down Expand Up @@ -53,7 +54,7 @@ exports.testnet = {
nonce: 414098458,
version: 1,
hash: hex('43497FD7F826957108F4A30FD9CEC3AEBA79972084E90EAD01EA330900000000'),
prev_hash: new Buffer(32).fill(0),
prev_hash: buffertools.fill(new Buffer(32), 0),
timestamp: 1296688602,
merkle_root: hex('3BA3EDFD7A7B12B27AC72C3E67768F617FC81BC3888A51323A9FB8AA4B1E5E4A'),
bits: 486604799,
Expand Down
9 changes: 4 additions & 5 deletions util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ var decodeDiffBits = exports.decodeDiffBits = function (diffBits, asBigInt) {

// Convert to buffer
var diffBuf = target.toBuffer();
var targetBuf = new Buffer(32).fill(0);
var targetBuf = new Buffer(32);
buffertools.fill(targetBuf, 0);
diffBuf.copy(targetBuf, 32-diffBuf.length);
return targetBuf;
};
Expand Down Expand Up @@ -325,11 +326,9 @@ var varStrBuf = exports.varStrBuf = function varStrBuf(s) {
};

// Initializations
exports.NULL_HASH = new Buffer(32)
buffertools.fill(exports.NULL_HASH, 0);
exports.NULL_HASH = buffertools.fill(new Buffer(32), 0);
exports.EMPTY_BUFFER = new Buffer(0);
exports.ZERO_VALUE = new Buffer(8)
buffertools.fill(exports.ZERO_VALUE, 0);
exports.ZERO_VALUE = buffertools.fill(new Buffer(8), 0);
var INT64_MAX = new Buffer('ffffffffffffffff', 'hex');
exports.INT64_MAX = INT64_MAX;

Expand Down

0 comments on commit bf0010b

Please sign in to comment.