mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-06-27 16:32:30 +00:00
Fix hasChild of Node and OrbitNode
This commit is contained in:
parent
f258a53bd7
commit
491b578490
@ -9,6 +9,15 @@ class Node {
|
|||||||
this.next = next ? next.map((f) => f.compactId ? f.compactId : f) : [];
|
this.next = next ? next.map((f) => f.compactId ? f.compactId : f) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasChild(a) {
|
||||||
|
const id = a.compactId;
|
||||||
|
for(let i = 0; i < this.next.length; i++) {
|
||||||
|
if(this.next[i] === id)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
get compactId() {
|
get compactId() {
|
||||||
return "" + this.id + "." + this.seq + "." + this.ver;
|
return "" + this.id + "." + this.seq + "." + this.ver;
|
||||||
}
|
}
|
||||||
@ -24,15 +33,6 @@ class Node {
|
|||||||
static equals(a, b) {
|
static equals(a, b) {
|
||||||
return a.id === b.id && a.seq === b.seq && a.ver === b.ver;
|
return a.id === b.id && a.seq === b.seq && a.ver === b.ver;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasChild(a) {
|
|
||||||
const id = a.compactId;
|
|
||||||
for(let i = 0; i < this.next.length; i++) {
|
|
||||||
if(this.next[i] === id)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Node;
|
module.exports = Node;
|
||||||
|
@ -30,6 +30,15 @@ class OrbitNode extends Node {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasChild(a) {
|
||||||
|
const id = a.compactId;
|
||||||
|
for(let i = 0; i < this.next.length; i++) {
|
||||||
|
if(this.next[i].compactId === id)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
_commit() {
|
_commit() {
|
||||||
if(!this.hash) {
|
if(!this.hash) {
|
||||||
const r = await(ipfsAPI.putObject(this._ipfs, JSON.stringify(this.asJson)));
|
const r = await(ipfsAPI.putObject(this._ipfs, JSON.stringify(this.asJson)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user