@leofcoin/peernet 1.1.80 → 1.1.82

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.
Files changed (71) hide show
  1. package/.esdoc.json +10 -10
  2. package/.gitattributes +2 -2
  3. package/.prettierrc +7 -7
  4. package/.travis.yml +27 -27
  5. package/BREAKING_CHANGES.md +34 -34
  6. package/LICENSE +21 -21
  7. package/README.md +72 -72
  8. package/deploy.js +8 -8
  9. package/exports/browser/{client-Depp28gl.js → client-C0VVXIWm.js} +2 -2
  10. package/exports/browser/{index-DqPlTtAJ.js → index-CEwkDK9g.js} +5 -496
  11. package/exports/browser/{messages-RYLqPGkg.js → messages-BdevLRCA.js} +164 -164
  12. package/exports/browser/{peernet-B7TZP-Wg.js → peernet-DEIKLS2i.js} +185 -185
  13. package/exports/browser/peernet.js +1 -1
  14. package/exports/{messages-CRhtDipD.js → messages-BmpgEM4y.js} +163 -163
  15. package/exports/peernet.js +184 -184
  16. package/exports/src/prompts/password.js +3 -3
  17. package/index.html +19 -19
  18. package/package.json +71 -71
  19. package/rollup.config.js +63 -63
  20. package/src/dht/dht.ts +147 -147
  21. package/src/discovery/peer-discovery.js +75 -75
  22. package/src/errors/errors.js +12 -12
  23. package/src/handlers/data.js +15 -15
  24. package/src/handlers/message.js +34 -34
  25. package/src/identity.ts +104 -104
  26. package/src/messages/chat.js +13 -13
  27. package/src/messages/data-response.js +13 -13
  28. package/src/messages/data.js +17 -17
  29. package/src/messages/dht-response.js +13 -13
  30. package/src/messages/dht.js +21 -21
  31. package/src/messages/file-link.js +17 -17
  32. package/src/messages/file.js +17 -17
  33. package/src/messages/peer-response.js +13 -13
  34. package/src/messages/peer.js +13 -13
  35. package/src/messages/peernet.js +13 -13
  36. package/src/messages/ps.js +13 -13
  37. package/src/messages/request.js +13 -13
  38. package/src/messages/response.js +13 -13
  39. package/src/messages.js +13 -13
  40. package/src/peer-info.js +9 -9
  41. package/src/peernet.ts +817 -817
  42. package/src/prompts/password/browser.js +1 -1
  43. package/src/prompts/password/node.js +6 -6
  44. package/src/proto/chat-message.proto.js +6 -6
  45. package/src/proto/data-response.proto.js +4 -4
  46. package/src/proto/data.proto.js +4 -4
  47. package/src/proto/dht-response.proto.js +4 -4
  48. package/src/proto/dht.proto.js +4 -4
  49. package/src/proto/file-link.proto.js +5 -5
  50. package/src/proto/file.proto.js +5 -5
  51. package/src/proto/peer-response.proto.js +3 -3
  52. package/src/proto/peer.proto.js +3 -3
  53. package/src/proto/peernet.proto.js +7 -7
  54. package/src/proto/ps.proto.js +4 -4
  55. package/src/proto/request.proto.js +4 -4
  56. package/src/proto/response.proto.js +3 -3
  57. package/src/types.ts +25 -25
  58. package/src/utils/utils.js +77 -77
  59. package/test/client.js +14 -14
  60. package/test/codec.js +56 -56
  61. package/test/hash.js +13 -13
  62. package/test/index.js +3 -3
  63. package/test/lastBlock.js +7 -7
  64. package/test/messages.js +26 -26
  65. package/test/peernet.js +17 -17
  66. package/test/peernet.test.js +159 -159
  67. package/test.js +62 -62
  68. package/test2.js +13 -13
  69. package/test3.js +15 -15
  70. package/test4.js +7 -7
  71. package/tsconfig.json +11 -11
@@ -1,34 +1,34 @@
1
- export default class MessageHandler {
2
- constructor(network) {
3
- this.network = network
4
- }
5
- /**
6
- * hash and sign message
7
- *
8
- * @param {object} message
9
- * @param {Buffer} message.from peer id
10
- * @param {Buffer} message.to peer id
11
- * @param {string} message.data Peernet message
12
- * (PeernetMessage excluded) encoded as a string
13
- * @return message
14
- */
15
- async hashAndSignMessage(message) {
16
- const hash = await message.peernetHash
17
- message.decoded.signature = globalThis.identity.sign(hash.buffer)
18
- return message
19
- }
20
-
21
- /**
22
- * @param {String} from - peer id
23
- * @param {String} to - peer id
24
- * @param {String|PeernetMessage} data - data encoded message string
25
- * or the messageNode itself
26
- */
27
- async prepareMessage(message) {
28
- if (message.keys.includes('signature')) {
29
- message = await this.hashAndSignMessage(message)
30
- }
31
-
32
- return message
33
- }
34
- }
1
+ export default class MessageHandler {
2
+ constructor(network) {
3
+ this.network = network
4
+ }
5
+ /**
6
+ * hash and sign message
7
+ *
8
+ * @param {object} message
9
+ * @param {Buffer} message.from peer id
10
+ * @param {Buffer} message.to peer id
11
+ * @param {string} message.data Peernet message
12
+ * (PeernetMessage excluded) encoded as a string
13
+ * @return message
14
+ */
15
+ async hashAndSignMessage(message) {
16
+ const hash = await message.peernetHash
17
+ message.decoded.signature = globalThis.identity.sign(hash.buffer)
18
+ return message
19
+ }
20
+
21
+ /**
22
+ * @param {String} from - peer id
23
+ * @param {String} to - peer id
24
+ * @param {String|PeernetMessage} data - data encoded message string
25
+ * or the messageNode itself
26
+ */
27
+ async prepareMessage(message) {
28
+ if (message.keys.includes('signature')) {
29
+ message = await this.hashAndSignMessage(message)
30
+ }
31
+
32
+ return message
33
+ }
34
+ }
package/src/identity.ts CHANGED
@@ -1,104 +1,104 @@
1
- import MultiWallet from '@leofcoin/multi-wallet'
2
- import base58 from '@vandeurenglenn/base58'
3
- import type { base58String } from '@vandeurenglenn/base58'
4
- import { encrypt, decrypt } from '@leofcoin/identity-utils'
5
- import QrScanner from 'qr-scanner'
6
- import qrcode from 'qrcode'
7
-
8
- export default class Identity {
9
- #wallet: MultiWallet
10
- network
11
- id: string
12
- selectedAccount: string
13
-
14
- constructor(network: string) {
15
- this.network = network
16
- }
17
-
18
- get accounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]> {
19
- return this.getAccounts()
20
- }
21
-
22
- async getAccounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]> {
23
- let accounts = await globalThis.walletStore.get('accounts')
24
- accounts = new TextDecoder().decode(accounts)
25
- return JSON.parse(accounts)
26
- }
27
-
28
- async load(password?: string): Promise<void> {
29
- if (password && password.includes('.txt')) {
30
- const { readFile } = await import('fs/promises')
31
- try {
32
- password = (await readFile(password)).toString()
33
- } catch (error) {
34
- console.error(error)
35
- }
36
- }
37
- if (!password) {
38
- // @ts-ignore
39
- const importee: { default: () => Promise<string> } = await import('./prompts/password.js')
40
- password = await importee.default()
41
- }
42
-
43
- const accountExists = await globalThis.accountStore.has('public')
44
- if (accountExists) {
45
- const pub = await globalThis.accountStore.get('public')
46
- this.id = JSON.parse(new TextDecoder().decode(pub)).walletId
47
- const selected = await globalThis.walletStore.get('selected-account')
48
- this.selectedAccount = new TextDecoder().decode(selected)
49
- } else {
50
- const importee = await import(/* webpackChunkName: "generate-account" */ '@leofcoin/generate-account')
51
- const { identity, accounts } = await importee.default(password, this.network)
52
- await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }))
53
-
54
- await globalThis.walletStore.put('version', String(1))
55
- await globalThis.walletStore.put('accounts', JSON.stringify(accounts))
56
- await globalThis.walletStore.put('selected-account', accounts[0][1])
57
- await globalThis.walletStore.put('identity', JSON.stringify(identity))
58
-
59
- this.selectedAccount = accounts[0][1]
60
- this.id = identity.walletId
61
- }
62
- const identity = JSON.parse(new TextDecoder().decode(await globalThis.walletStore.get('identity')))
63
- this.#wallet = new MultiWallet(this.network)
64
- const multiWIF = await decrypt(password, base58.decode(identity.multiWIF))
65
- await this.#wallet.fromMultiWif(multiWIF)
66
- }
67
-
68
- selectAccount(account: string) {
69
- this.selectedAccount = account
70
- return walletStore.put('selected-account', account)
71
- }
72
-
73
- sign(hash: Uint8Array) {
74
- return this.#wallet.sign(hash.subarray(0, 32))
75
- }
76
-
77
- lock(password: string) {
78
- this.#wallet.lock(password)
79
- }
80
-
81
- unlock(password: string) {
82
- this.#wallet.unlock(password)
83
- }
84
-
85
- async export(password: string) {
86
- return this.#wallet.export(password)
87
- }
88
-
89
- async import(password, encrypted: base58String) {
90
- await this.#wallet.import(password, encrypted)
91
- }
92
-
93
- async exportQR(password: string) {
94
- const exported = await this.export(password)
95
- return globalThis.navigator
96
- ? await qrcode.toDataURL(exported)
97
- : await qrcode.toString(exported, { type: 'terminal' })
98
- }
99
-
100
- async importQR(image: File | Blob, password: string) {
101
- const multiWIF = await QrScanner.default.scanImage(image)
102
- return this.import(password, multiWIF)
103
- }
104
- }
1
+ import MultiWallet from '@leofcoin/multi-wallet'
2
+ import base58 from '@vandeurenglenn/base58'
3
+ import type { base58String } from '@vandeurenglenn/base58'
4
+ import { encrypt, decrypt } from '@leofcoin/identity-utils'
5
+ import QrScanner from 'qr-scanner'
6
+ import qrcode from 'qrcode'
7
+
8
+ export default class Identity {
9
+ #wallet: MultiWallet
10
+ network
11
+ id: string
12
+ selectedAccount: string
13
+
14
+ constructor(network: string) {
15
+ this.network = network
16
+ }
17
+
18
+ get accounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]> {
19
+ return this.getAccounts()
20
+ }
21
+
22
+ async getAccounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]> {
23
+ let accounts = await globalThis.walletStore.get('accounts')
24
+ accounts = new TextDecoder().decode(accounts)
25
+ return JSON.parse(accounts)
26
+ }
27
+
28
+ async load(password?: string): Promise<void> {
29
+ if (password && password.includes('.txt')) {
30
+ const { readFile } = await import('fs/promises')
31
+ try {
32
+ password = (await readFile(password)).toString()
33
+ } catch (error) {
34
+ console.error(error)
35
+ }
36
+ }
37
+ if (!password) {
38
+ // @ts-ignore
39
+ const importee: { default: () => Promise<string> } = await import('./prompts/password.js')
40
+ password = await importee.default()
41
+ }
42
+
43
+ const accountExists = await globalThis.accountStore.has('public')
44
+ if (accountExists) {
45
+ const pub = await globalThis.accountStore.get('public')
46
+ this.id = JSON.parse(new TextDecoder().decode(pub)).walletId
47
+ const selected = await globalThis.walletStore.get('selected-account')
48
+ this.selectedAccount = new TextDecoder().decode(selected)
49
+ } else {
50
+ const importee = await import(/* webpackChunkName: "generate-account" */ '@leofcoin/generate-account')
51
+ const { identity, accounts } = await importee.default(password, this.network)
52
+ await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }))
53
+
54
+ await globalThis.walletStore.put('version', String(1))
55
+ await globalThis.walletStore.put('accounts', JSON.stringify(accounts))
56
+ await globalThis.walletStore.put('selected-account', accounts[0][1])
57
+ await globalThis.walletStore.put('identity', JSON.stringify(identity))
58
+
59
+ this.selectedAccount = accounts[0][1]
60
+ this.id = identity.walletId
61
+ }
62
+ const identity = JSON.parse(new TextDecoder().decode(await globalThis.walletStore.get('identity')))
63
+ this.#wallet = new MultiWallet(this.network)
64
+ const multiWIF = await decrypt(password, base58.decode(identity.multiWIF))
65
+ await this.#wallet.fromMultiWif(multiWIF)
66
+ }
67
+
68
+ selectAccount(account: string) {
69
+ this.selectedAccount = account
70
+ return walletStore.put('selected-account', account)
71
+ }
72
+
73
+ sign(hash: Uint8Array) {
74
+ return this.#wallet.sign(hash.subarray(0, 32))
75
+ }
76
+
77
+ lock(password: string) {
78
+ this.#wallet.lock(password)
79
+ }
80
+
81
+ unlock(password: string) {
82
+ this.#wallet.unlock(password)
83
+ }
84
+
85
+ async export(password: string) {
86
+ return this.#wallet.export(password)
87
+ }
88
+
89
+ async import(password, encrypted: base58String) {
90
+ await this.#wallet.import(password, encrypted)
91
+ }
92
+
93
+ async exportQR(password: string) {
94
+ const exported = await this.export(password)
95
+ return globalThis.navigator
96
+ ? await qrcode.toDataURL(exported)
97
+ : await qrcode.toString(exported, { type: 'terminal' })
98
+ }
99
+
100
+ async importQR(image: File | Blob, password: string) {
101
+ const multiWIF = await QrScanner.default.scanImage(image)
102
+ return this.import(password, multiWIF)
103
+ }
104
+ }
@@ -1,13 +1,13 @@
1
- import proto from './../proto/chat-message.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class ChatMessage extends FormatInterface {
5
- get messageName() {
6
- return 'ChatMessage'
7
- }
8
-
9
- constructor(buffer) {
10
- const name = 'chat-message'
11
- super(buffer, proto, { name })
12
- }
13
- }
1
+ import proto from './../proto/chat-message.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
3
+
4
+ export default class ChatMessage extends FormatInterface {
5
+ get messageName() {
6
+ return 'ChatMessage'
7
+ }
8
+
9
+ constructor(buffer) {
10
+ const name = 'chat-message'
11
+ super(buffer, proto, { name })
12
+ }
13
+ }
@@ -1,13 +1,13 @@
1
- import proto from './../proto/data-response.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class DataMessageResponse extends FormatInterface {
5
- get messageName() {
6
- return 'PeernetDataMessageResponse'
7
- }
8
-
9
- constructor(data) {
10
- const name = 'peernet-data-response'
11
- super(data, proto, { name })
12
- }
13
- }
1
+ import proto from './../proto/data-response.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
3
+
4
+ export default class DataMessageResponse extends FormatInterface {
5
+ get messageName() {
6
+ return 'PeernetDataMessageResponse'
7
+ }
8
+
9
+ constructor(data) {
10
+ const name = 'peernet-data-response'
11
+ super(data, proto, { name })
12
+ }
13
+ }
@@ -1,17 +1,17 @@
1
- import proto from './../proto/data.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- /**
5
- * @extends {CodecFormat}
6
- */
7
- export default class DataMessage extends FormatInterface {
8
- get messageName() {
9
- return 'PeernetDataMessage'
10
- }
11
- /**
12
- * @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
13
- */
14
- constructor(data) {
15
- super(data, proto, { name: 'peernet-data' })
16
- }
17
- }
1
+ import proto from './../proto/data.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
3
+
4
+ /**
5
+ * @extends {CodecFormat}
6
+ */
7
+ export default class DataMessage extends FormatInterface {
8
+ get messageName() {
9
+ return 'PeernetDataMessage'
10
+ }
11
+ /**
12
+ * @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
13
+ */
14
+ constructor(data) {
15
+ super(data, proto, { name: 'peernet-data' })
16
+ }
17
+ }
@@ -1,13 +1,13 @@
1
- import proto from './../proto/dht-response.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class DHTMessageResponse extends FormatInterface {
5
- get messageName() {
6
- return 'PeernetDHTMessageResponse'
7
- }
8
-
9
- constructor(data) {
10
- const name = 'peernet-dht-response'
11
- super(data, proto, { name })
12
- }
13
- }
1
+ import proto from './../proto/dht-response.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
3
+
4
+ export default class DHTMessageResponse extends FormatInterface {
5
+ get messageName() {
6
+ return 'PeernetDHTMessageResponse'
7
+ }
8
+
9
+ constructor(data) {
10
+ const name = 'peernet-dht-response'
11
+ super(data, proto, { name })
12
+ }
13
+ }
@@ -1,21 +1,21 @@
1
- import proto from './../proto/dht.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- /**
5
- * @example `
6
- new DHTMessage(hash, store)
7
- // store = optional if not set, peernet checks every store
8
- let message = new DHTMessage('hashmvbs124xcfd...', 'transaction')
9
- message = new DHTMessage('hashmvbs124xcfd...', 'block')
10
- `
11
- */
12
- export default class DHTMessage extends FormatInterface {
13
- get messageName() {
14
- return 'PeernetDHTMessage'
15
- }
16
-
17
- constructor(data) {
18
- const name = 'peernet-dht'
19
- super(data, proto, { name })
20
- }
21
- }
1
+ import proto from './../proto/dht.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
3
+
4
+ /**
5
+ * @example `
6
+ new DHTMessage(hash, store)
7
+ // store = optional if not set, peernet checks every store
8
+ let message = new DHTMessage('hashmvbs124xcfd...', 'transaction')
9
+ message = new DHTMessage('hashmvbs124xcfd...', 'block')
10
+ `
11
+ */
12
+ export default class DHTMessage extends FormatInterface {
13
+ get messageName() {
14
+ return 'PeernetDHTMessage'
15
+ }
16
+
17
+ constructor(data) {
18
+ const name = 'peernet-dht'
19
+ super(data, proto, { name })
20
+ }
21
+ }
@@ -1,17 +1,17 @@
1
- import proto from '../proto/file-link.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- /**
5
- * @extends {CodecFormat}
6
- */
7
- export default class PeernetFileLink extends FormatInterface {
8
- get messageName() {
9
- return 'PeernetFileLink'
10
- }
11
- /**
12
- * @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
13
- */
14
- constructor(data) {
15
- super(data, proto, { name: 'peernet-file-link' })
16
- }
17
- }
1
+ import proto from '../proto/file-link.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
3
+
4
+ /**
5
+ * @extends {CodecFormat}
6
+ */
7
+ export default class PeernetFileLink extends FormatInterface {
8
+ get messageName() {
9
+ return 'PeernetFileLink'
10
+ }
11
+ /**
12
+ * @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
13
+ */
14
+ constructor(data) {
15
+ super(data, proto, { name: 'peernet-file-link' })
16
+ }
17
+ }
@@ -1,17 +1,17 @@
1
- import proto from './../proto/file.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- /**
5
- * @extends {CodecFormat}
6
- */
7
- export default class PeernetFile extends FormatInterface {
8
- get messageName() {
9
- return 'PeernetFile'
10
- }
11
- /**
12
- * @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
13
- */
14
- constructor(data) {
15
- super(data, proto, { name: 'peernet-file' })
16
- }
17
- }
1
+ import proto from './../proto/file.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
3
+
4
+ /**
5
+ * @extends {CodecFormat}
6
+ */
7
+ export default class PeernetFile extends FormatInterface {
8
+ get messageName() {
9
+ return 'PeernetFile'
10
+ }
11
+ /**
12
+ * @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
13
+ */
14
+ constructor(data) {
15
+ super(data, proto, { name: 'peernet-file' })
16
+ }
17
+ }
@@ -1,13 +1,13 @@
1
- import proto from './../proto/peer-response.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class PeerMessageResponse extends FormatInterface {
5
- get messageName() {
6
- return 'PeernetPeerMessageResponse'
7
- }
8
-
9
- constructor(data) {
10
- const name = 'peernet-peer-response'
11
- super(data, proto, { name })
12
- }
13
- }
1
+ import proto from './../proto/peer-response.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
3
+
4
+ export default class PeerMessageResponse extends FormatInterface {
5
+ get messageName() {
6
+ return 'PeernetPeerMessageResponse'
7
+ }
8
+
9
+ constructor(data) {
10
+ const name = 'peernet-peer-response'
11
+ super(data, proto, { name })
12
+ }
13
+ }
@@ -1,13 +1,13 @@
1
- import proto from './../proto/peer.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class PeerMessage extends FormatInterface {
5
- get messageName() {
6
- return 'PeernetPeerMessage'
7
- }
8
-
9
- constructor(data) {
10
- const name = 'peernet-peer'
11
- super(data, proto, { name })
12
- }
13
- }
1
+ import proto from './../proto/peer.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
3
+
4
+ export default class PeerMessage extends FormatInterface {
5
+ get messageName() {
6
+ return 'PeernetPeerMessage'
7
+ }
8
+
9
+ constructor(data) {
10
+ const name = 'peernet-peer'
11
+ super(data, proto, { name })
12
+ }
13
+ }
@@ -1,13 +1,13 @@
1
- import proto from './../proto/peernet.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class PeernetMessage extends FormatInterface {
5
- get messageName() {
6
- return 'PeernetMessage'
7
- }
8
-
9
- constructor(buffer) {
10
- const name = 'peernet-message'
11
- super(buffer, proto, { name })
12
- }
13
- }
1
+ import proto from './../proto/peernet.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
3
+
4
+ export default class PeernetMessage extends FormatInterface {
5
+ get messageName() {
6
+ return 'PeernetMessage'
7
+ }
8
+
9
+ constructor(buffer) {
10
+ const name = 'peernet-message'
11
+ super(buffer, proto, { name })
12
+ }
13
+ }
@@ -1,13 +1,13 @@
1
- import proto from './../proto/ps.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class PsMessage extends FormatInterface {
5
- get messageName() {
6
- return 'PsMessage'
7
- }
8
-
9
- constructor(buffer) {
10
- const name = 'peernet-ps'
11
- super(buffer, proto, { name })
12
- }
13
- }
1
+ import proto from './../proto/ps.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
3
+
4
+ export default class PsMessage extends FormatInterface {
5
+ get messageName() {
6
+ return 'PsMessage'
7
+ }
8
+
9
+ constructor(buffer) {
10
+ const name = 'peernet-ps'
11
+ super(buffer, proto, { name })
12
+ }
13
+ }
@@ -1,13 +1,13 @@
1
- import proto from './../proto/request.proto.js'
2
- import { FormatInterface } from '@leofcoin/codec-format-interface'
3
-
4
- export default class RequestMessage extends FormatInterface {
5
- get messageName() {
6
- return 'PeernetRequestMessage'
7
- }
8
-
9
- constructor(data) {
10
- const name = 'peernet-request'
11
- super(data, proto, { name })
12
- }
13
- }
1
+ import proto from './../proto/request.proto.js'
2
+ import { FormatInterface } from '@leofcoin/codec-format-interface'
3
+
4
+ export default class RequestMessage extends FormatInterface {
5
+ get messageName() {
6
+ return 'PeernetRequestMessage'
7
+ }
8
+
9
+ constructor(data) {
10
+ const name = 'peernet-request'
11
+ super(data, proto, { name })
12
+ }
13
+ }