Skip to content

Commit

Permalink
Update daemon to use new rpc package.
Browse files Browse the repository at this point in the history
  • Loading branch information
saul-jb committed Apr 11, 2024
1 parent 77b2d7e commit 1f59249
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 225 deletions.
16 changes: 1 addition & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/daemon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
"@organicdesign/db-helia-pin-manager": "^0.1.0",
"@organicdesign/db-key-manager": "^0.1.0",
"@organicdesign/db-manual-block-broker": "^0.1.0",
"@organicdesign/db-rpc": "^0.1.0",
"@organicdesign/db-rpc-interfaces": "^0.1.0",
"@organicdesign/db-utils": "^0.1.0",
"@organicdesign/net-rpc": "^0.2.1",
"any-signal": "^4.1.1",
"blockstore-core": "^4.4.0",
"blockstore-fs": "^1.1.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/daemon/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { unixfs as createUnixfs } from '@helia/unixfs'
import { PinManager as HeliaPinManager } from '@organicdesign/db-helia-pin-manager'
import { createKeyManager, type KeyManager } from '@organicdesign/db-key-manager'
import { ManualBlockBroker } from '@organicdesign/db-manual-block-broker'
import { createRPCServer } from '@organicdesign/db-rpc'
import { extendDatastore } from '@organicdesign/db-utils'
import { MemoryBlockstore } from 'blockstore-core'
import { FsBlockstore } from 'blockstore-fs'
Expand All @@ -21,7 +22,6 @@ import handleEvents from './handle-events.js'
import { Config, MEMORY_MAGIC, type Components } from './interface.js'
import createLibp2p from './libp2p.js'
import { PinManager } from './pin-manager/index.js'
import { createRPCServer } from './rpc-server.js'
import { Sneakernet } from './sneakernet/index.js'
import { createTick } from './tick.js'
import type { KeyvalueDB } from '@/interface.js'
Expand Down
2 changes: 1 addition & 1 deletion packages/daemon/src/common/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { Downloader } from './downloader/index.js'
import type { EntryTracker } from './entry-tracker.js'
import type { Groups } from './groups.js'
import type { PinManager } from './pin-manager/index.js'
import type { RPCServer } from './rpc-server.js'
import type { Sneakernet } from './sneakernet/index.js'
import type { Tick } from './tick.js'
import type { KeyvalueDB } from '@/interface.js'
Expand All @@ -13,6 +12,7 @@ import type { UnixFS } from '@helia/unixfs'
import type { Libp2p } from '@libp2p/interface'
import type { PinManager as HeliaPinManager } from '@organicdesign/db-helia-pin-manager'
import type { KeyManager } from '@organicdesign/db-key-manager'
import type { RPCServer } from '@organicdesign/db-rpc'
import type { Blockstore } from 'interface-blockstore'
import type { Datastore } from 'interface-datastore'
import type { Welo } from 'welo'
Expand Down
146 changes: 0 additions & 146 deletions packages/daemon/src/common/rpc-server.ts

This file was deleted.

14 changes: 7 additions & 7 deletions packages/daemon/test/modules/downloader.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'assert/strict'
import fs from 'fs/promises'
import Path from 'path'
import { createRPCClient } from '@organicdesign/db-rpc'
import { createDag } from '@organicdesign/db-test-utils'
import { createNetClient } from '@organicdesign/net-rpc'
import { MemoryBlockstore } from 'blockstore-core'
import { CID } from 'multiformats/cid'
import { mkTestPath } from '../utils/paths.js'
Expand Down Expand Up @@ -32,7 +32,7 @@ describe('downloader', () => {
const path = '/test.txt'
const priority = 50
const { components, socket } = await create()
const client = createNetClient(socket)
const client = createRPCClient(socket)
const key = Path.join('/', group, path)

await components.pinManager.put(key, { priority: 1, cid: CID.parse(group) })
Expand All @@ -46,7 +46,7 @@ describe('downloader', () => {
assert(pinData != null)
assert.equal(pinData.priority, priority)

client.close()
client.stop()
await components.stop()
})

Expand All @@ -57,7 +57,7 @@ describe('downloader', () => {
const group = 'QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN'
const path = '/test.txt'
const age = 500
const client = createNetClient(socket)
const client = createRPCClient(socket)
const key = Path.join('/', group, path)

await components.pinManager.put(key, { priority: 1, cid: dag[0] })
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('downloader', () => {
assert.equal(state3[0].size, values.reduce((a, c) => c.length + a, 0))
assert.equal(state3[0].blocks, values.length)

client.close()
client.stop()
await components.stop()
})

Expand All @@ -118,7 +118,7 @@ describe('downloader', () => {
const dag = await createDag({ blockstore }, 2, 2)
const group = 'QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN'
const path = '/test.txt'
const client = createNetClient(socket)
const client = createRPCClient(socket)
const key = Path.join('/', group, path)

const status1 = await client.rpc.request('get-state', {
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('downloader', () => {
status: 'COMPLETED'
}])

client.close()
client.stop()
await components.stop()
})
})
Loading

0 comments on commit 1f59249

Please sign in to comment.