Browse Source

block: re-order functions to project standard

hk-custom-address
Daniel Cousens 10 years ago
parent
commit
b6b5b568c3
  1. 30
      src/block.js

30
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

Loading…
Cancel
Save