cleaning up getClaimByName route

This commit is contained in:
bill bittner 2017-06-17 10:50:18 -07:00
parent c89061c83f
commit 6b7bea6471

View file

@ -24,13 +24,15 @@ module.exports = {
// get all free public claims
getAllFreePublicClaims(claimName)
.then(function(freePublicClaimList){
console.log(">> Decided on public claim id:", freePublicClaimList[0].claim_id);
var claimId = freePublicClaimList[0].claim_id;
var name = freePublicClaimList[0].name;
var freePublicClaimOutpoint = freePublicClaimList[0].txid + ":" + freePublicClaimList[0].nout;
var freePublicClaimUri = freePublicClaimList[0].name + "#" + freePublicClaimList[0].claim_id;
var freePublicClaimUri = name + "#" + claimId;
console.log(">> Decided on public claim id:", claimId);
// check to see if the file is available locally
db.File.findOne({where: { claim_id: freePublicClaimList[0].claim_id }})
db.File.findOne({where: { name: name, claim_id: claimId }})
.then(function(claim){
// if a found locally...
// if a matching claim is found locally...
if (claim){
console.log(">> A matching claim_id was found locally");
// if the outpoint's match return it