diff --git a/lib/plugin.js b/lib/plugin.js index 1b63f92..9f21b38 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -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,