mirror of https://github.com/BTCPrivate/copay.git
add timestamp sync
This commit is contained in:
parent
1b783df70a
commit
981c56f091
|
@ -4,6 +4,7 @@ var EventEmitter = require('events').EventEmitter;
|
|||
var async = require('async');
|
||||
var preconditions = require('preconditions').singleton();
|
||||
var util = require('util');
|
||||
var microtime = require('microtime');
|
||||
|
||||
var bitcore = require('bitcore');
|
||||
var bignum = bitcore.Bignum;
|
||||
|
@ -315,6 +316,11 @@ Wallet.prototype._onAddressBook = function(senderId, data, isInbound) {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
Wallet.prototype.updateTimestamp = function() {
|
||||
this.lastTimestamp = microtime.now();
|
||||
};
|
||||
|
||||
Wallet.prototype._onData = function(senderId, data, isInbound) {
|
||||
preconditions.checkArgument(senderId);
|
||||
preconditions.checkArgument(data);
|
||||
|
@ -326,6 +332,8 @@ Wallet.prototype._onData = function(senderId, data, isInbound) {
|
|||
return;
|
||||
}
|
||||
|
||||
this.updateTimestamp();
|
||||
|
||||
switch (data.type) {
|
||||
// This handler is repeaded on WalletFactory (#join). TODO
|
||||
case 'walletId':
|
||||
|
@ -438,7 +446,8 @@ Wallet.prototype.netStart = function(callback) {
|
|||
var startOpts = {
|
||||
copayerId: myId,
|
||||
privkey: myIdPriv,
|
||||
maxPeers: self.totalCopayers
|
||||
maxPeers: self.totalCopayers,
|
||||
lastTimestamp: this.lastTimestamp,
|
||||
};
|
||||
|
||||
if (this.publicKeyRing.isComplete()) {
|
||||
|
|
|
@ -326,7 +326,7 @@ Network.prototype.start = function(opts, openCallback) {
|
|||
this._setupConnectionHandlers(openCallback);
|
||||
var pubkey = this.getKey().public.toString('hex');
|
||||
this.socket.emit('subscribe', pubkey);
|
||||
//this.socket.emit('sync');
|
||||
this.socket.emit('sync', opts.lastTimestamp);
|
||||
this.started = true;
|
||||
|
||||
};
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
},
|
||||
"version": "0.4.7",
|
||||
"dependencies": {
|
||||
"microtime": "^1.0.1",
|
||||
"mocha": "^1.18.2",
|
||||
"mocha-lcov-reporter": "0.0.1",
|
||||
"optimist": "^0.6.1",
|
||||
|
|
Loading…
Reference in New Issue