fix hash and time in Block sync
This commit is contained in:
parent
60a2dfa1c2
commit
479b262361
|
@ -42,14 +42,16 @@ BlockSchema.path('title').validate(function(title) {
|
|||
* Statics
|
||||
*/
|
||||
|
||||
BlockSchema.statics.createTimestamped = function(block, cb) {
|
||||
BlockSchema.statics.customCreate = function(block, cb) {
|
||||
|
||||
var That= this;
|
||||
var now = Math.round(new Date().getTime() / 1000);
|
||||
|
||||
var BlockSchema = mongoose.model('Block', BlockSchema);
|
||||
|
||||
var newBlock = new That();
|
||||
newBlock.time = now;
|
||||
|
||||
newBlock.time = block.time ? block.time : Math.round(new Date().getTime() / 1000);
|
||||
newBlock.hash = block.blockHash;
|
||||
|
||||
Transaction.createFromArray(block.tx, function(err, inserted_txs) {
|
||||
if (err) return cb(err);
|
||||
|
|
|
@ -113,7 +113,7 @@ function spec() {
|
|||
Sync.prototype.storeBlock = function(block, cb) {
|
||||
var that = this;
|
||||
|
||||
Block.createTimestamped(block, function(err, b){
|
||||
Block.customCreate(block, function(err, b){
|
||||
|
||||
if (b && that.opts.broadcast_blocks) {
|
||||
sockets.broadcast_block(b);
|
||||
|
|
Loading…
Reference in New Issue