Skip to content

Commit 35ad7f0

Browse files
committed
seed: 'pending' drive key
1 parent 0c60180 commit 35ad7f0

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

cmd/seed.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = async function seed(cmd) {
5151
key: 'contentKey',
5252
label: appendMode ? `${ansi.gray('...')} content key` : 'Content Key:',
5353
initial: loading,
54-
transform: (v) => (v === undefined ? ansi.yellow('unknown...') : ansi.gray(v))
54+
transform: (v) => (v === 'pending' ? ansi.yellow(v) : ansi.gray(v))
5555
},
5656
{
5757
key: 'firewalled',
@@ -151,7 +151,9 @@ module.exports = async function seed(cmd) {
151151
stats.update({
152152
driveKey: hypercoreid.normalize(driveKey),
153153
discoveryKey: hypercoreid.normalize(discoveryKey),
154-
contentKey: contentKey && hypercoreid.normalize(contentKey),
154+
contentKey: hypercoreid.isValid(contentKey)
155+
? hypercoreid.normalize(contentKey)
156+
: contentKey,
155157
firewalled,
156158
natType,
157159
network

subsystems/sidecar/ops/seed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = class Seed extends Opstream {
2424
peers: drive.core.peers.length,
2525
driveKey: drive.key?.toString('hex'),
2626
discoveryKey: drive.discoveryKey?.toString('hex'),
27-
contentKey: drive.contentKey?.toString('hex'),
27+
contentKey: drive.contentKey?.toString('hex') ?? 'pending',
2828
upload: {
2929
totalBytes: this.stats.totals.upload.bytes,
3030
totalBlocks: this.stats.totals.upload.blocks,

test/03-seed.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,21 @@ test('pear seed announces, join, drop', async function ({
110110
ok(dropped, 'peer drops')
111111
})
112112

113+
test('pear seed empty drive has pending content key', async function ({ is, plan, teardown }) {
114+
plan(1)
115+
116+
const helper = new Helper()
117+
teardown(() => helper.close(), { order: Infinity })
118+
await helper.ready()
119+
const link = await Helper.touchLink(helper)
120+
121+
const seeding = helper.seed({ link })
122+
teardown(() => Helper.teardownStream(seeding))
123+
const stats = await Helper.pick(seeding, { tag: 'stats', data: { contentKey: 'pending' } })
124+
125+
is(stats.contentKey, 'pending', 'content key is pending')
126+
})
127+
113128
test('pear seed fully syncs db and blobs cores', async function ({
114129
is,
115130
plan,

0 commit comments

Comments
 (0)