Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge 9909748 into 5873328
Browse files Browse the repository at this point in the history
  • Loading branch information
navillasa committed Feb 28, 2018
2 parents 5873328 + 9909748 commit 90ae55d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/renter.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,12 +636,23 @@ Renter.prototype._publishContract = function(contacts, contract, callback) {
userAgent: contact.userAgent,
address: contact.address,
port: contact.port,
lastSeen: contact.lastSeen
lastSeen: contact.lastSeen,
spaceAvailable: contact.spaceAvailable
});

const startTime = Date.now();
const nodeID = contact._id;

// changes spaceAvailable to false
// if contacts haven't been seen in last
// 24 hours so that they'll stop receiving
// ALLOC messages
function seenInLastDay(contact) {
if (contact.lastSeen < new Date(Date.now() - 864e5)) {
contact.spaceAvailable = false;
}
}

// Send the node a contract directly
this.network.publishContract(contactInst, contractInst, (err, data) => {
const responseTime = Date.now() - startTime;
Expand All @@ -650,6 +661,8 @@ Renter.prototype._publishContract = function(contacts, contract, callback) {

this._logger.warn('Error publishing contract to node: %j, reason: %s',
contact, err.message);

seenInLastDay(contactInst);
}

if (data && data.result) {
Expand Down

0 comments on commit 90ae55d

Please sign in to comment.