Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit 330e19f

Browse files
pgtedaviddias
authored andcommitted
feat: rename online -> exchange (#67)
1 parent 5627f47 commit 330e19f

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BlockService {
2727
* @param {Bitswap} bitswap
2828
* @returns {void}
2929
*/
30-
goOnline (bitswap) {
30+
setExchange (bitswap) {
3131
this._bitswap = bitswap
3232
}
3333

@@ -36,7 +36,7 @@ class BlockService {
3636
*
3737
* @returns {void}
3838
*/
39-
goOffline () {
39+
unsetExchange () {
4040
this._bitswap = null
4141
}
4242

@@ -45,7 +45,7 @@ class BlockService {
4545
*
4646
* @returns {bool}
4747
*/
48-
isOnline () {
48+
hasExchange () {
4949
return this._bitswap != null
5050
}
5151

@@ -57,7 +57,7 @@ class BlockService {
5757
* @returns {void}
5858
*/
5959
put (block, callback) {
60-
if (this.isOnline()) {
60+
if (this.hasExchange()) {
6161
return this._bitswap.put(block, callback)
6262
}
6363

@@ -72,7 +72,7 @@ class BlockService {
7272
* @returns {void}
7373
*/
7474
putMany (blocks, callback) {
75-
if (this.isOnline()) {
75+
if (this.hasExchange()) {
7676
return this._bitswap.putMany(blocks, callback)
7777
}
7878

@@ -87,7 +87,7 @@ class BlockService {
8787
* @returns {void}
8888
*/
8989
get (cid, callback) {
90-
if (this.isOnline()) {
90+
if (this.hasExchange()) {
9191
return this._bitswap.get(cid, callback)
9292
}
9393

test/block-service-test.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,23 @@ module.exports = (repo) => {
129129
})
130130
})
131131

132-
it('goes offline', () => {
132+
it('sets and unsets exchange', () => {
133133
bs = new BlockService(repo)
134-
bs.goOnline({})
135-
expect(bs.isOnline()).to.be.eql(true)
136-
bs.goOffline()
137-
expect(bs.isOnline()).to.be.eql(false)
134+
bs.setExchange({})
135+
expect(bs.hasExchange()).to.be.eql(true)
136+
bs.unsetExchange()
137+
expect(bs.hasExchange()).to.be.eql(false)
138138
})
139139
})
140140

141-
describe('online', () => {
141+
describe('has exchange', () => {
142142
beforeEach(() => {
143143
bs = new BlockService(repo)
144144
})
145145

146-
it('isOnline returns true when online', () => {
147-
bs.goOnline({})
148-
expect(bs.isOnline()).to.be.eql(true)
146+
it('hasExchange returns true when online', () => {
147+
bs.setExchange({})
148+
expect(bs.hasExchange()).to.be.eql(true)
149149
})
150150

151151
it('retrieves a block through bitswap', (done) => {
@@ -156,7 +156,7 @@ module.exports = (repo) => {
156156
}
157157
}
158158

159-
bs.goOnline(bitswap)
159+
bs.setExchange(bitswap)
160160

161161
const data = new Buffer('secret')
162162

@@ -178,7 +178,7 @@ module.exports = (repo) => {
178178
callback()
179179
}
180180
}
181-
bs.goOnline(bitswap)
181+
bs.setExchange(bitswap)
182182

183183
const data = new Buffer('secret sauce')
184184

0 commit comments

Comments
 (0)