2020-07-15 12:29:36 +02:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const errcode = require('err-code')
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Record is the base implementation of a record that can be used as the payload of a libp2p envelope.
|
|
|
|
*/
|
|
|
|
class Record {
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
* @param {String} domain signature domain
|
2020-08-24 12:20:24 +02:00
|
|
|
* @param {Uint8Array} codec identifier of the type of record
|
2020-07-15 12:29:36 +02:00
|
|
|
*/
|
|
|
|
constructor (domain, codec) {
|
|
|
|
this.domain = domain
|
|
|
|
this.codec = codec
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Marshal a record to be used in an envelope.
|
|
|
|
*/
|
|
|
|
marshal () {
|
|
|
|
throw errcode(new Error('marshal must be implemented by the subclass'), 'ERR_NOT_IMPLEMENTED')
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verifies if the other provided Record is identical to this one.
|
|
|
|
* @param {Record} other
|
|
|
|
*/
|
|
|
|
equals (other) {
|
|
|
|
throw errcode(new Error('equals must be implemented by the subclass'), 'ERR_NOT_IMPLEMENTED')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Record
|