block: re-order functions to project standard

This commit is contained in:
Daniel Cousens 2014-11-28 10:30:07 +11:00
parent 9897fa2876
commit b6b5b568c3

View file

@ -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