Skip to content

Commit

Permalink
More CR fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
christosporios committed Sep 11, 2017
1 parent 86a512c commit 8f25118
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
15 changes: 6 additions & 9 deletions src/direct_trust.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,12 @@ class DirectTrust {
isValid() : boolean {
// TODO: Consider removing this function and ensure validity at build time by using the flow
// type system, possibly by creating sub-types like "IncreasingDirectTrust" etc.
var valid = true;

if ((this.outputIndex === null) !== (this.script === null)) valid = false;
if (this.outputIndex === null && this.isIncrease()) valid = false;
if (this.outputIndex === null && this.amount > 0) valid = false;
if (this.isIncrease() && this.isNull()) valid = false;
if (this.isSpent() && this.isNull()) valid = false;

return valid;
if ((this.outputIndex === null) !== (this.script === null)) return false;
if (this.outputIndex === null && this.isIncrease()) return false;
if (this.outputIndex === null && this.amount > 0) return false;
if (this.isIncrease() && this.isNull()) return false;
if (this.isSpent() && this.isNull()) return false;
return true;
}

getOriginEntity() : Entity {
Expand Down
2 changes: 1 addition & 1 deletion src/trust_db.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class TrustDB {
}

getEntities() : Entity[] {
return this.entities.slice(0, this.entities.length);
return this.entities.slice();
}

getEntityIndex(entity : Entity) : number {
Expand Down
6 changes: 2 additions & 4 deletions src/trust_is_risk.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ class TrustIsRisk {

getInputTrusts(inputs : bcoin$Input[]) : DirectTrust[] {
return inputs.map((input) => {
var trust = this.db.getDirectTrustByOutpoint(input.prevout);
if (trust && trust.outputIndex === input.prevout.index) return trust;
else return null;
return this.db.getDirectTrustByOutpoint(input.prevout);
}).filter(Boolean);
}

Expand All @@ -224,7 +222,7 @@ class TrustIsRisk {

nextTrust.prev = prevTrust;

assert(nextTrust.amount - prevTrust.amount <= 0);
assert(nextTrust.amount <= prevTrust.amount);
return nextTrust;
}

Expand Down

0 comments on commit 8f25118

Please sign in to comment.