Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static branchContains(path, branch){
// console.log(path, branch)
let complete, error, response = false
let encodedBranch = []
for (let i = 0; i < branch.length; i++) {
encodedBranch.push(toHex(encode(branch[i])))
}
Trie.verifyProof(toHex(this.branchRootOf(branch)) , path, encodedBranch, (e,r)=>{
error = e
response = r
complete = true
})
while(!complete){/*wait*/}
if(error){
throw Error(error)
}else{
return response
}
}
}
return new Promise((accept, reject) => {
let encodedProof = []
for (let i = 0; i < proof.length; i++) {
encodedProof.push(encode(proof[i]))
}
Tree.verifyProof(toBuffer(this.getRootFromProof(proof)) , path, encodedProof, (e,r)=>{
if(e){
return reject(e)
}else{
return accept(r)
}
})
})
}