From b6b5b568c30db9f40ab38ec55ce184dce06bec6d Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Fri, 28 Nov 2014 10:30:07 +1100 Subject: [PATCH] block: re-order functions to project standard --- src/block.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/block.js b/src/block.js index be409c0..8b786cb 100644 --- a/src/block.js +++ b/src/block.js @@ -97,6 +97,21 @@ Block.fromHex = function(hex) { return Block.fromBuffer(new Buffer(hex, 'hex')) } +Block.prototype.getHash = function() { + return crypto.hash256(this.toBuffer(true)) +} + +Block.prototype.getId = function() { + return bufferutils.reverse(this.getHash()).toString('hex') +} + +Block.prototype.getUTCDate = function() { + var date = new Date(0) // epoch + date.setUTCSeconds(this.timestamp) + + return date +} + Block.prototype.toBuffer = function(headersOnly) { var buffer = new Buffer(80) @@ -132,19 +147,4 @@ Block.prototype.toHex = function(headersOnly) { return this.toBuffer(headersOnly).toString('hex') } -Block.prototype.getHash = function() { - return crypto.hash256(this.toBuffer(true)) -} - -Block.prototype.getId = function() { - return bufferutils.reverse(this.getHash()).toString('hex') -} - -Block.prototype.getUTCDate = function() { - var date = new Date(0) // epoch - date.setUTCSeconds(this.timestamp) - - return date -} - module.exports = Block