How to use the interface-datastore.MemoryDatastore function in interface-datastore

To help you get started, we’ve selected a few interface-datastore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github libp2p / js-libp2p / test / dht.node.js View on Github external
describe('enabled', () => {
    let nodeA
    const datastore = new MemoryStore()

    before(function (done) {
      createNode('/ip4/0.0.0.0/tcp/0', {
        datastore
      }, (err, node) => {
        expect(err).to.not.exist()
        nodeA = node

        // Rewrite validators
        nodeA._dht.validators.v = {
          func (key, publicKey, callback) {
            setImmediate(callback)
          },
          sign: false
        }
github peer-base / peer-base / test / shared.spec.js View on Github external
it('can be created', async () => {
    const ipfs = {
      id () {
        return {
          id: 'replica id'
        }
      },
      _repo: {
        datastore: new MemoryDatastore()
      }
    }
    const collaboration = {
      name: 'shared test collaboration'
    }
    const store = new Store(ipfs, collaboration, storeOptions)
    await store.start()
    const keys = await Keys.generate()
    shared = await Shared('name', 'replica id', CRDT('fake'), {}, store, keys)
    store.setShared(shared)
  })
github peer-base / peer-base / test / collaboration-protocol.spec.js View on Github external
it('introduces another pusher', async () => {
    const ipfs = {
      id () {
        return { id: 'pusher 2' }
      },
      _peerInfo: fakePeerInfoFor('pusher 2'),
      _repo: {
        datastore: new MemoryDatastore()
      }
    }
    const collaboration = { name: 'collaboration protocol test' }
    pusher2.store = new Store(ipfs, collaboration, storeOptions)
    await pusher2.store.start()
    const clocks = new Clocks()
    const replication = Replication(ipfs.id().id, clocks)
    pusher2.protocol = Protocol(ipfs, collaboration, pusher2.store, null, clocks, replication)
    pusher2.shared = await Shared(null, 'pusher 2', Type, collaboration, pusher2.store, keys)
    pusher2.store.setShared(pusher2.shared)
  })
github ipfs / js-datastore-pubsub / test / index.spec.js View on Github external
])
    peerIdA = pubsubA.peerInfo.id
    peerIdB = pubsubB.peerInfo.id

    await connectPubsubNodes(
      {
        router: pubsubA,
        registrar: registrarRecordA
      },
      {
        router: pubsubB,
        registrar: registrarRecordB
      })

    datastoreA = new MemoryDatastore()
    datastoreB = new MemoryDatastore()
  })
github ipfs / js-datastore-pubsub / test / index.spec.js View on Github external
createPubsubNode(registrarRecordB)
    ])
    peerIdA = pubsubA.peerInfo.id
    peerIdB = pubsubB.peerInfo.id

    await connectPubsubNodes(
      {
        router: pubsubA,
        registrar: registrarRecordA
      },
      {
        router: pubsubB,
        registrar: registrarRecordB
      })

    datastoreA = new MemoryDatastore()
    datastoreB = new MemoryDatastore()
  })
github ipfs / js-ipfs / test / core / libp2p.spec.js View on Github external
Discovery: {
            MDNS: {
              Enabled: false
            },
            webRTCStar: {
              Enabled: false
            }
          },
          EXPERIMENTAL: {
            dht: false,
            pubsub: false
          }
        })
      }
    }
    datastore = new MemoryStore()
    peerBook = new PeerBook()
    PeerInfo.create((err, pi) => {
      peerInfo = pi
      done(err)
    })
  })
github decentraland / builder / src / modules / deployment / utils.ts View on Github external
export async function getCID(files: ContentServiceFile[], shareRoot: boolean): Promise {
  const importer = new Importer(new MemoryDatastore(), { onlyHash: true })
  return new Promise((resolve, reject) => {
    pull(
      pull.values(files),
      pull.asyncMap((file: ContentServiceFile, cb: any) => {
        const data = {
          path: shareRoot ? '/tmp/' + file.path : file.path,
          content: file.content
        }
        cb(null, data)
      }),
      importer,
      pull.onEnd(() => {
        return importer.flush((err: any, content: any) => {
          if (err) {
            reject(err)
          }