Skip to content

Commit f38e21f

Browse files
authored
add unhave/unwant. fixes hypercore-protocol#2 (hypercore-protocol#9)
1 parent 1551e7f commit f38e21f

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

index.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ var DEFAULT_TYPES = [
2626
messages.Cancel,
2727
null, // pause
2828
null, // resume
29-
null // end
29+
null, // end
30+
messages.Unhave,
31+
messages.Unwant
3032
]
3133

3234
var DEFAULT_EVENTS = [
@@ -38,7 +40,9 @@ var DEFAULT_EVENTS = [
3840
'cancel',
3941
'pause',
4042
'resume',
41-
'end'
43+
'end',
44+
'unhave',
45+
'unwant'
4246
]
4347

4448
while (DEFAULT_EVENTS.length < 64) { // reserved
@@ -117,6 +121,14 @@ function use (extensions) {
117121
return this.protocol._send(this, 8, null)
118122
}
119123

124+
Channel.prototype.unhave = function (message) {
125+
return this.protocol._send(this, 9, null)
126+
}
127+
128+
Channel.prototype.unwant = function (message) {
129+
return this.protocol._send(this, 10, null)
130+
}
131+
120132
Channel.prototype.close = function () { // non graceful close
121133
this.protocol._close(this)
122134
}

schema.proto

+10
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,13 @@ message Cancel {
4545
optional uint64 bytes = 2;
4646
optional bool hash = 3;
4747
}
48+
49+
message Unhave {
50+
required uint64 start = 1;
51+
optional uint64 end = 2;
52+
}
53+
54+
message Unwant {
55+
required uint64 start = 1;
56+
optional uint64 end = 2;
57+
}

0 commit comments

Comments
 (0)