mirror of https://codeberg.org/pzp/pzp-db.git
new API validateTangle()
This commit is contained in:
parent
3ab7d98550
commit
f1e313461e
|
@ -324,6 +324,16 @@ exports.init = function initDB(peer, config) {
|
|||
return new DBTangle(tangleId, records())
|
||||
}
|
||||
|
||||
function validateTangle(tangleId, msgs) {
|
||||
let err
|
||||
const tangle = new FeedV1.Tangle(tangleId)
|
||||
for (const msg of msgs) {
|
||||
const msgHash = FeedV1.getMsgHash(msg)
|
||||
if ((err = FeedV1.validate(msg, tangle, msgHash, tangleId))) return err
|
||||
tangle.add(msgHash, msg)
|
||||
}
|
||||
}
|
||||
|
||||
function* msgs() {
|
||||
for (let i = 0; i < recs.length; i++) {
|
||||
const rec = recs[i]
|
||||
|
@ -351,6 +361,7 @@ exports.init = function initDB(peer, config) {
|
|||
erase,
|
||||
onRecordAdded,
|
||||
getTangle,
|
||||
validateTangle,
|
||||
msgs,
|
||||
records,
|
||||
|
||||
|
|
Loading…
Reference in New Issue