Skip to content

Commit

Permalink
update: reckless push to master for rename
Browse files Browse the repository at this point in the history
Signed-off-by: Carson Farmer <carson.farmer@gmail.com>
  • Loading branch information
carsonfarmer committed Nov 4, 2019
1 parent f28ea85 commit 2f6b191
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
@@ -1 +1 @@
* @carsonfarmer
* @sanderpick @asutula @carsonfarmer @andrewxhill @jsign
4 changes: 2 additions & 2 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions src/blockstore/index.ts
Expand Up @@ -34,12 +34,12 @@ export const keyToCid = (key: Key) => {
}

/**
* Blockstore defines a simple key/value store for storing and retrieving blocks of data.
* BlockStore defines a simple key/value store for storing and retrieving blocks of data.
* It nearly implements the IPFS `datastore` interface, but is specific to storage of immutable blocks of data.
*/
export class Blockstore {
export class BlockStore {
/**
* `constructor` creates a new Blockstore.
* `constructor` creates a new BlockStore.
* @param store The underlying datastore for locally caching immutable blocks of data.
*/
constructor(private store: Datastore) {}
Expand Down
9 changes: 6 additions & 3 deletions src/index.ts
Expand Up @@ -2,7 +2,10 @@ import Libp2p from 'libp2p'
import Bitswap from 'ipfs-bitswap'
import Ipld from 'ipld'
import { BlockService } from './blockservice'
import { Blockstore } from './blockstore'
import { BlockStore } from './blockstore'

export { BlockService } from './blockservice'
export { BlockStore, Block } from './blockstore'

// Options wraps configuration options for the Peer.
export interface Options {
Expand All @@ -17,7 +20,7 @@ export class Peer extends Ipld {
// Ipld makes us a "DAG service"
public config: Options
public host: Libp2p
public store: Blockstore
public store: BlockStore
private blockService: BlockService
private blockExchange: Bitswap
// reprovider: Reprovider
Expand All @@ -27,7 +30,7 @@ export class Peer extends Ipld {
/**
* Initialize an IPFS-Lite Peer
*/
constructor(store: Blockstore, host: Libp2p, config: Options = { offline: false }) {
constructor(store: BlockStore, host: Libp2p, config: Options = { offline: false }) {
const blockExchange = new Bitswap(host, store)
const blockService = new BlockService(store, config.offline ? undefined : blockExchange)
super({ blockService })
Expand Down
4 changes: 2 additions & 2 deletions tests/blockservice.test.ts
Expand Up @@ -4,11 +4,11 @@ import { collect } from 'streaming-iterables'
import Bitswap from 'ipfs-bitswap'
import { MemoryDatastore } from 'interface-datastore'
import { BlockService } from '../src/blockservice'
import { Blockstore, Block } from '../src/blockstore'
import { BlockStore, Block } from '../src/blockstore'

let bs: BlockService
let testBlocks: Block[]
const store = new Blockstore(new MemoryDatastore())
const store = new BlockStore(new MemoryDatastore())

beforeAll(async () => {
bs = new BlockService(store)
Expand Down
14 changes: 7 additions & 7 deletions tests/blockstore.test.ts
Expand Up @@ -2,9 +2,9 @@ import CID from 'cids'
import { Key, MemoryDatastore, Query } from 'interface-datastore'
import multihashing from 'multihashing-async'
import { collect } from 'streaming-iterables'
import { cidToKey, keyToCid, Block, Blockstore } from '../src/blockstore'
import { cidToKey, keyToCid, Block, BlockStore } from '../src/blockstore'

let blocks: Blockstore
let blocks: BlockStore

class ExplodingStore {
commitInvoked: boolean
Expand Down Expand Up @@ -51,7 +51,7 @@ class ExplodingStore {
}

beforeAll(async () => {
blocks = new Blockstore(new MemoryDatastore())
blocks = new BlockStore(new MemoryDatastore())
})

describe('blockstore', () => {
Expand All @@ -75,7 +75,7 @@ describe('blockstore', () => {
})

describe('.put', () => {
let other: Blockstore
let other: BlockStore

it('simple', async () => {
await blocks.put(b)
Expand Down Expand Up @@ -125,7 +125,7 @@ describe('blockstore', () => {
const hash = await multihashing(data, 'sha2-256')
const cid = new CID(hash)
const store = new ExplodingStore()
other = new Blockstore(store)
other = new BlockStore(store)

await other.putMany([
{
Expand All @@ -149,7 +149,7 @@ describe('blockstore', () => {
})

describe('.get', () => {
let other: Blockstore
let other: BlockStore

it('simple', async () => {
const block = await blocks.get(b.cid)
Expand Down Expand Up @@ -218,7 +218,7 @@ describe('blockstore', () => {
const data = Buffer.from(`TEST${Date.now()}`)
const hash = await multihashing(data, 'sha2-256')
const cid = new CID(hash)
const other = new Blockstore(new ExplodingStore())
const other = new BlockStore(new ExplodingStore())
await expect(other.get(cid)).rejects.toThrow('error')
})
})
Expand Down
6 changes: 3 additions & 3 deletions tests/dagpair.test.ts
@@ -1,6 +1,6 @@
import { MemoryDatastore } from 'interface-datastore'
import { Peer } from '../src'
import { Blockstore } from '../src/blockstore'
import { BlockStore } from '../src/blockstore'
import { setupLibP2PHost } from './utils'

const writeKey = require('libp2p/src/pnet').generate
Expand All @@ -17,8 +17,8 @@ let p2: Peer
describe('sync IPLD DAG between IPFS lite peers', () => {
beforeAll(async () => {
jest.setTimeout(20000)
p1 = new Peer(new Blockstore(new MemoryDatastore()), await setupLibP2PHost(undefined, swarmKey))
p2 = new Peer(new Blockstore(new MemoryDatastore()), await setupLibP2PHost(undefined, swarmKey))
p1 = new Peer(new BlockStore(new MemoryDatastore()), await setupLibP2PHost(undefined, swarmKey))
p2 = new Peer(new BlockStore(new MemoryDatastore()), await setupLibP2PHost(undefined, swarmKey))
await p1.start()
await p2.start()
await sleep(500)
Expand Down
5 changes: 3 additions & 2 deletions tests/files.test.ts
Expand Up @@ -3,7 +3,7 @@ import { MemoryDatastore } from 'interface-datastore'
import exporter from 'ipfs-unixfs-exporter'
import importer from 'ipfs-unixfs-importer'
import { Peer } from '../src'
import { Blockstore } from '../src/blockstore'
import { BlockStore } from '../src/blockstore'
import { setupLibP2PHost } from './utils'

const sleep = (ms: number) => new Promise(r => setTimeout(r, ms))
Expand All @@ -12,14 +12,15 @@ const results: any[] = []

describe('getting and putting files', () => {
beforeAll(async () => {
const bs = new Blockstore(new MemoryDatastore())
const bs = new BlockStore(new MemoryDatastore())
const host = await setupLibP2PHost(undefined, undefined, ['/ip4/0.0.0.0/tcp/4004'])
lite = new Peer(bs, host)
await lite.start()
await sleep(500)
})
afterAll(async () => {
await lite.stop()
await fs.unlink('bar.txt')
})

it('read file from disc and put to "network"', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/helloworld.test.ts
@@ -1,15 +1,15 @@
import { MemoryDatastore } from 'interface-datastore'
import CID from 'cids'
import { Peer } from '../src'
import { Blockstore } from '../src/blockstore'
import { BlockStore } from '../src/blockstore'
import { setupLibP2PHost } from './utils'

const sleep = (ms: number) => new Promise(r => setTimeout(r, ms))
let lite: Peer

describe.skip('fetching IPLD dag from network', () => {
beforeAll(async () => {
const bs = new Blockstore(new MemoryDatastore())
const bs = new BlockStore(new MemoryDatastore())
const host = await setupLibP2PHost(undefined, undefined, ['/ip4/0.0.0.0/tcp/4005'])
lite = new Peer(bs, host)
await lite.start()
Expand Down

0 comments on commit 2f6b191

Please sign in to comment.