Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
fix: add buffer (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias authored Apr 27, 2020
1 parent 8861f6c commit a28d279
Show file tree
Hide file tree
Showing 24 changed files with 25 additions and 19 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"abort-controller": "^3.0.0",
"async": "^2.6.2",
"base32.js": "~0.1.0",
"buffer": "^5.6.0",
"cids": "~0.8.0",
"debug": "^4.1.1",
"err-code": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/message/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const PeerId = require('peer-id')
const multiaddr = require('multiaddr')
const protons = require('protons')
const { Record } = require('libp2p-record')

const { Buffer } = require('buffer')
const pbm = protons(require('./dht.proto'))

const MESSAGE_TYPE = pbm.Message.MessageType
Expand Down
2 changes: 1 addition & 1 deletion src/providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const varint = require('varint')
const PeerId = require('peer-id')
const { Key } = require('interface-datastore')
const { default: Queue } = require('p-queue')

const { Buffer } = require('buffer')
const c = require('./constants')
const utils = require('./utils')

Expand Down
1 change: 1 addition & 0 deletions src/rpc/handlers/find-node.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const { Buffer } = require('buffer')
const Message = require('../../message')
const utils = require('../../utils')

Expand Down
1 change: 1 addition & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const pMap = require('p-map')
const { Record } = require('libp2p-record')
const PeerId = require('peer-id')
const errcode = require('err-code')
const { Buffer } = require('buffer')

/**
* Creates a DHT ID by hashing a given buffer.
Expand Down
2 changes: 1 addition & 1 deletion test/kad-dht.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ chai.use(require('dirty-chai'))
chai.use(require('chai-checkmark'))
const expect = chai.expect
const sinon = require('sinon')

const { Buffer } = require('buffer')
const multiaddr = require('multiaddr')
const { Record } = require('libp2p-record')
const errcode = require('err-code')
Expand Down
1 change: 1 addition & 0 deletions test/kad-utils.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-env mocha */
'use strict'

const { Buffer } = require('buffer')
const chai = require('chai')
chai.use(require('dirty-chai'))
const expect = chai.expect
Expand Down
2 changes: 1 addition & 1 deletion test/message.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const random = require('lodash.random')
const { Record } = require('libp2p-record')
const fs = require('fs')
const path = require('path')

const { Buffer } = require('buffer')
const Message = require('../src/message')

describe('Message', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/multiple-nodes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const chai = require('chai')
chai.use(require('dirty-chai'))
const expect = chai.expect

const { Buffer } = require('buffer')
const TestDHT = require('./utils/test-dht')

describe('multiple nodes', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/network.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const chai = require('chai')
chai.use(require('dirty-chai'))
const expect = chai.expect

const { Buffer } = require('buffer')
const pair = require('it-pair')
const pipe = require('it-pipe')
const delay = require('delay')
Expand Down
2 changes: 1 addition & 1 deletion test/peer-distance-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const chai = require('chai')
chai.use(require('dirty-chai'))
const expect = chai.expect
const PeerId = require('peer-id')

const { Buffer } = require('buffer')
const kadUtils = require('../src/utils')
const PeerDistanceList = require('../src/peer-list/peer-distance-list')

Expand Down
2 changes: 1 addition & 1 deletion test/peer-queue.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const chai = require('chai')
chai.use(require('dirty-chai'))
const expect = chai.expect
const PeerId = require('peer-id')

const { Buffer } = require('buffer')
const PeerQueue = require('../src/peer-list/peer-queue')

describe('PeerQueue', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/providers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const LevelStore = require('datastore-level')
const path = require('path')
const os = require('os')
const multihashing = require('multihashing-async')

const { Buffer } = require('buffer')
const Providers = require('../src/providers')

const createPeerId = require('./utils/create-peer-id')
Expand Down
2 changes: 1 addition & 1 deletion test/query.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ chai.use(require('dirty-chai'))
const expect = chai.expect
const pDefer = require('p-defer')
const delay = require('delay')

const { Buffer } = require('buffer')
const Query = require('../src/query')
const kadUtils = require('../src/utils')

Expand Down
2 changes: 1 addition & 1 deletion test/query/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const expect = chai.expect
const sinon = require('sinon')
const delay = require('delay')
const PeerStore = require('libp2p/src/peer-store')

const { Buffer } = require('buffer')
const Query = require('../../src/query')
const Path = require('../../src/query/path')
const Run = require('../../src/query/run')
Expand Down
2 changes: 1 addition & 1 deletion test/rpc/handlers/add-provider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const chai = require('chai')
chai.use(require('dirty-chai'))
const expect = chai.expect

const { Buffer } = require('buffer')
const multiaddr = require('multiaddr')

const Message = require('../../../src/message')
Expand Down
2 changes: 1 addition & 1 deletion test/rpc/handlers/find-node.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const chai = require('chai')
chai.use(require('dirty-chai'))
const expect = chai.expect

const { Buffer } = require('buffer')
const Message = require('../../../src/message')
const handler = require('../../../src/rpc/handlers/find-node')

Expand Down
2 changes: 1 addition & 1 deletion test/rpc/handlers/get-providers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const chai = require('chai')
chai.use(require('dirty-chai'))
const expect = chai.expect

const { Buffer } = require('buffer')
const Message = require('../../../src/message')
const utils = require('../../../src/utils')
const handler = require('../../../src/rpc/handlers/get-providers')
Expand Down
2 changes: 1 addition & 1 deletion test/rpc/handlers/get-value.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const chai = require('chai')
chai.use(require('dirty-chai'))
const expect = chai.expect

const { Buffer } = require('buffer')
const Message = require('../../../src/message')
const handler = require('../../../src/rpc/handlers/get-value')
const utils = require('../../../src/utils')
Expand Down
2 changes: 1 addition & 1 deletion test/rpc/handlers/ping.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const chai = require('chai')
chai.use(require('dirty-chai'))
const expect = chai.expect

const { Buffer } = require('buffer')
const Message = require('../../../src/message')
const handler = require('../../../src/rpc/handlers/ping')

Expand Down
2 changes: 1 addition & 1 deletion test/rpc/handlers/put-value.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ chai.use(require('dirty-chai'))
const expect = chai.expect
const { Record } = require('libp2p-record')
const delay = require('delay')

const { Buffer } = require('buffer')
const Message = require('../../../src/message')
const handler = require('../../../src/rpc/handlers/put-value')
const utils = require('../../../src/utils')
Expand Down
2 changes: 1 addition & 1 deletion test/rpc/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const pDefer = require('p-defer')
const pipe = require('it-pipe')
const lp = require('it-length-prefixed')
const { collect } = require('streaming-iterables')

const { Buffer } = require('buffer')
const Message = require('../../src/message')
const rpc = require('../../src/rpc')

Expand Down
2 changes: 1 addition & 1 deletion test/simulation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const PeerStore = require('libp2p/src/peer-store')
const PeerId = require('peer-id')
const multihashes = require('multihashes')

const { Buffer } = require('buffer')
const RoutingTable = require('../../src/routing')
const Message = require('../../src/message')
const { convertBuffer } = require('../../src/utils')
Expand Down
2 changes: 2 additions & 0 deletions test/utils/to-buffer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
'use strict'
const { Buffer } = require('buffer')

/**
* Converts BufferList messages to Buffers
* @param {*} source
Expand Down

0 comments on commit a28d279

Please sign in to comment.