fix hash and time in Block sync

This commit is contained in:
Matias Alejo Garcia 2014-01-16 10:51:39 -03:00
parent 60a2dfa1c2
commit 479b262361
2 changed files with 6 additions and 4 deletions

View File

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

View File

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