block: re-order functions to project standard
This commit is contained in:
parent
9897fa2876
commit
b6b5b568c3
1 changed files with 15 additions and 15 deletions
30
src/block.js
30
src/block.js
|
@ -97,6 +97,21 @@ Block.fromHex = function(hex) {
|
||||||
return Block.fromBuffer(new Buffer(hex, '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) {
|
Block.prototype.toBuffer = function(headersOnly) {
|
||||||
var buffer = new Buffer(80)
|
var buffer = new Buffer(80)
|
||||||
|
|
||||||
|
@ -132,19 +147,4 @@ Block.prototype.toHex = function(headersOnly) {
|
||||||
return this.toBuffer(headersOnly).toString('hex')
|
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
|
module.exports = Block
|
||||||
|
|
Loading…
Add table
Reference in a new issue