@@ -18,29 +18,33 @@ p1.on('handshake', function () {
18
18
console . log ( 'got handshake, remote peer:' , p1 . remoteId )
19
19
} )
20
20
21
- p1 . on ( 'channel' , function ( key , channel ) {
21
+ p1 . on ( 'channel' , function ( channel ) {
22
22
channel . on ( 'ping' , function ( ) {
23
23
console . log ( 'got ping' )
24
24
channel . close ( )
25
25
} )
26
+
26
27
channel . on ( 'close' , function ( ) {
27
28
console . log ( 'closing shop' )
28
29
} )
29
- channel . on ( 'request' , function ( block ) {
30
- console . log ( 'remote requests:' , block )
31
- channel . response ( block , Buffer ( 'hello' ) )
30
+
31
+ channel . on ( 'request' , function ( message ) {
32
+ console . log ( 'remote requests:' , message . block )
33
+ channel . response ( { block : message . block , data : Buffer ( 'hello' ) } )
32
34
} )
33
35
} )
34
36
35
- p2 . on ( 'channel' , function ( key , channel ) {
37
+ p2 . on ( 'channel' , function ( channel ) {
36
38
channel . on ( 'close' , function ( ) {
37
39
console . log ( 'closing' )
38
40
} )
39
- channel . request ( 1 )
40
- channel . request ( 2 )
41
+
42
+ channel . request ( { block : 1 } )
43
+ channel . request ( { block : 2 } )
41
44
channel . ping ( )
42
- channel . on ( 'response' , function ( block , data , proof ) {
43
- console . log ( 'got response:' , block , data , proof )
45
+
46
+ channel . on ( 'response' , function ( message ) {
47
+ console . log ( 'got response:' , message )
44
48
} )
45
49
} )
46
50
0 commit comments