@leofcoin/peernet 0.9.2 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,6 +5,30 @@
5
5
  import discovery from 'socket-discovery'
6
6
  ```
7
7
 
8
+ ## API
9
+ #### addRequestHandler
10
+
11
+ examples
12
+ ```js
13
+ peernet.addRequestHandler('lastBlock', () => {
14
+ let response;
15
+ const height = await chainStore.get('localIndex')
16
+ const hash = await chainStore.get('localBlock')
17
+ response = JSON.stringify({ height: height.toString(), hash: hash.toString() })
18
+ return new ResponseMessage({ response })
19
+ // or
20
+ return new peernet.protos['peernet-response']({ response })
21
+ })
22
+ ```
23
+
24
+ ```js
25
+ peernet.addRequestHandler('hello', () => {
26
+ return new ResponseMessage({ response: 'hi' })
27
+ // or
28
+ return new peernet.protos['peernet-response']({ response: 'hi' })
29
+ })
30
+ ```
31
+
8
32
  ## Development
9
33
  ### watch
10
34
  ```sh
@@ -19,7 +43,7 @@ npm run c
19
43
  npm run demo
20
44
  ```
21
45
 
22
- `note: you need to install jsproject`
46
+ `note: you need to install jsproject`
23
47
  ```sh
24
48
  npm i -g @vandeurenglenn/project
25
- ```
49
+ ```