File tree Expand file tree Collapse file tree 2 files changed +56
-4
lines changed
Expand file tree Collapse file tree 2 files changed +56
-4
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,6 @@ module.exports = class Core {
4949 this . destroyed = false
5050 this . closed = false
5151
52- this . _manifestFlushed = false
5352 this . _bitfield = null
5453 this . _verifies = null
5554 this . _verifiesFlushed = null
@@ -264,6 +263,14 @@ module.exports = class Core {
264263 // to unslab
265264 if ( header . manifest ) {
266265 header . manifest = Verifier . createManifest ( header . manifest )
266+ const tx = storage . write ( )
267+ tx . setAuth ( {
268+ key : header . key ,
269+ discoveryKey : crypto . discoveryKey ( header . key ) ,
270+ manifest : header . manifest ,
271+ keyPair : header . keyPair
272+ } )
273+ await tx . flush ( )
267274 }
268275
269276 const verifier = header . manifest ? new Verifier ( header . key , header . manifest , { crypto, legacy } ) : null
@@ -279,8 +286,6 @@ module.exports = class Core {
279286 if ( this . discoveryKey === null ) this . discoveryKey = crypto . discoveryKey ( this . key )
280287 if ( this . id === null ) this . id = z32 . encode ( this . key )
281288 if ( this . manifest === null ) this . manifest = this . header . manifest
282-
283- this . _manifestFlushed = ! ! header . manifest
284289 }
285290
286291 async audit ( opts ) {
@@ -329,7 +334,6 @@ module.exports = class Core {
329334
330335 this . compat = verifier . compat
331336 this . verifier = verifier
332- this . _manifestFlushed = false
333337
334338 this . replicator . onupgrade ( )
335339 this . emitManifest ( )
Original file line number Diff line number Diff line change @@ -1487,6 +1487,54 @@ test('create verifier - open existing core with manifest', async function (t) {
14871487 await compatCore . close ( )
14881488} )
14891489
1490+ test ( 'manifest - persist if manifest is updated' , async function ( t ) {
1491+ const keyPair = crypto . keyPair ( )
1492+
1493+ const manifest = Verifier . createManifest ( {
1494+ quorum : 1 ,
1495+ signers : [ {
1496+ signature : 'ed25519' ,
1497+ publicKey : keyPair . publicKey
1498+ } ]
1499+ } )
1500+
1501+ const key = Verifier . manifestHash ( manifest )
1502+ const create = await createStored ( t )
1503+
1504+ {
1505+ const core = await create ( key , { compat : false } )
1506+ await core . ready ( )
1507+
1508+ t . is ( core . manifest , null )
1509+ t . is ( core . core . header . manifest , null )
1510+ t . alike ( core . key , key )
1511+
1512+ await core . close ( )
1513+ }
1514+
1515+ {
1516+ const core = await create ( key , { manifest, compat : false } )
1517+ await core . ready ( )
1518+
1519+ t . not ( core . manifest , null )
1520+ t . not ( core . core . header . manifest , null )
1521+ t . alike ( core . key , key )
1522+
1523+ await core . close ( )
1524+ }
1525+
1526+ {
1527+ const core = await create ( key , { compat : false } )
1528+ await core . ready ( )
1529+
1530+ t . not ( core . manifest , null )
1531+ t . not ( core . core . header . manifest , null )
1532+ t . alike ( core . key , key )
1533+
1534+ await core . close ( )
1535+ }
1536+ } )
1537+
14901538function createMultiManifest ( signers , prologue = null ) {
14911539 return {
14921540 hash : 'blake2b' ,
You can’t perform that action at this time.
0 commit comments