@optimystic/db-p2p 0.0.1
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/dist/index.min.js +52 -0
- package/dist/index.min.js.map +7 -0
- package/dist/src/cluster/client.d.ts +12 -0
- package/dist/src/cluster/client.d.ts.map +1 -0
- package/dist/src/cluster/client.js +65 -0
- package/dist/src/cluster/client.js.map +1 -0
- package/dist/src/cluster/cluster-repo.d.ts +79 -0
- package/dist/src/cluster/cluster-repo.d.ts.map +1 -0
- package/dist/src/cluster/cluster-repo.js +613 -0
- package/dist/src/cluster/cluster-repo.js.map +1 -0
- package/dist/src/cluster/partition-detector.d.ts +59 -0
- package/dist/src/cluster/partition-detector.d.ts.map +1 -0
- package/dist/src/cluster/partition-detector.js +129 -0
- package/dist/src/cluster/partition-detector.js.map +1 -0
- package/dist/src/cluster/service.d.ts +49 -0
- package/dist/src/cluster/service.d.ts.map +1 -0
- package/dist/src/cluster/service.js +107 -0
- package/dist/src/cluster/service.js.map +1 -0
- package/dist/src/index.d.ts +29 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +29 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/it-utility.d.ts +4 -0
- package/dist/src/it-utility.d.ts.map +1 -0
- package/dist/src/it-utility.js +32 -0
- package/dist/src/it-utility.js.map +1 -0
- package/dist/src/libp2p-key-network.d.ts +59 -0
- package/dist/src/libp2p-key-network.d.ts.map +1 -0
- package/dist/src/libp2p-key-network.js +278 -0
- package/dist/src/libp2p-key-network.js.map +1 -0
- package/dist/src/libp2p-node.d.ts +28 -0
- package/dist/src/libp2p-node.d.ts.map +1 -0
- package/dist/src/libp2p-node.js +270 -0
- package/dist/src/libp2p-node.js.map +1 -0
- package/dist/src/logger.d.ts +3 -0
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/src/logger.js +6 -0
- package/dist/src/logger.js.map +1 -0
- package/dist/src/network/get-network-manager.d.ts +4 -0
- package/dist/src/network/get-network-manager.d.ts.map +1 -0
- package/dist/src/network/get-network-manager.js +17 -0
- package/dist/src/network/get-network-manager.js.map +1 -0
- package/dist/src/network/network-manager-service.d.ts +82 -0
- package/dist/src/network/network-manager-service.d.ts.map +1 -0
- package/dist/src/network/network-manager-service.js +283 -0
- package/dist/src/network/network-manager-service.js.map +1 -0
- package/dist/src/peer-utils.d.ts +2 -0
- package/dist/src/peer-utils.d.ts.map +1 -0
- package/dist/src/peer-utils.js +28 -0
- package/dist/src/peer-utils.js.map +1 -0
- package/dist/src/protocol-client.d.ts +12 -0
- package/dist/src/protocol-client.d.ts.map +1 -0
- package/dist/src/protocol-client.js +34 -0
- package/dist/src/protocol-client.js.map +1 -0
- package/dist/src/repo/client.d.ts +17 -0
- package/dist/src/repo/client.d.ts.map +1 -0
- package/dist/src/repo/client.js +82 -0
- package/dist/src/repo/client.js.map +1 -0
- package/dist/src/repo/cluster-coordinator.d.ts +59 -0
- package/dist/src/repo/cluster-coordinator.d.ts.map +1 -0
- package/dist/src/repo/cluster-coordinator.js +539 -0
- package/dist/src/repo/cluster-coordinator.js.map +1 -0
- package/dist/src/repo/coordinator-repo.d.ts +29 -0
- package/dist/src/repo/coordinator-repo.d.ts.map +1 -0
- package/dist/src/repo/coordinator-repo.js +102 -0
- package/dist/src/repo/coordinator-repo.js.map +1 -0
- package/dist/src/repo/redirect.d.ts +14 -0
- package/dist/src/repo/redirect.d.ts.map +1 -0
- package/dist/src/repo/redirect.js +9 -0
- package/dist/src/repo/redirect.js.map +1 -0
- package/dist/src/repo/service.d.ts +52 -0
- package/dist/src/repo/service.d.ts.map +1 -0
- package/dist/src/repo/service.js +181 -0
- package/dist/src/repo/service.js.map +1 -0
- package/dist/src/repo/types.d.ts +7 -0
- package/dist/src/repo/types.d.ts.map +1 -0
- package/dist/src/repo/types.js +2 -0
- package/dist/src/repo/types.js.map +1 -0
- package/dist/src/routing/libp2p-known-peers.d.ts +4 -0
- package/dist/src/routing/libp2p-known-peers.d.ts.map +1 -0
- package/dist/src/routing/libp2p-known-peers.js +19 -0
- package/dist/src/routing/libp2p-known-peers.js.map +1 -0
- package/dist/src/routing/responsibility.d.ts +14 -0
- package/dist/src/routing/responsibility.d.ts.map +1 -0
- package/dist/src/routing/responsibility.js +45 -0
- package/dist/src/routing/responsibility.js.map +1 -0
- package/dist/src/routing/simple-cluster-coordinator.d.ts +23 -0
- package/dist/src/routing/simple-cluster-coordinator.d.ts.map +1 -0
- package/dist/src/routing/simple-cluster-coordinator.js +59 -0
- package/dist/src/routing/simple-cluster-coordinator.js.map +1 -0
- package/dist/src/storage/arachnode-fret-adapter.d.ts +65 -0
- package/dist/src/storage/arachnode-fret-adapter.d.ts.map +1 -0
- package/dist/src/storage/arachnode-fret-adapter.js +93 -0
- package/dist/src/storage/arachnode-fret-adapter.js.map +1 -0
- package/dist/src/storage/block-storage.d.ts +31 -0
- package/dist/src/storage/block-storage.d.ts.map +1 -0
- package/dist/src/storage/block-storage.js +154 -0
- package/dist/src/storage/block-storage.js.map +1 -0
- package/dist/src/storage/file-storage.d.ts +30 -0
- package/dist/src/storage/file-storage.d.ts.map +1 -0
- package/dist/src/storage/file-storage.js +127 -0
- package/dist/src/storage/file-storage.js.map +1 -0
- package/dist/src/storage/helpers.d.ts +3 -0
- package/dist/src/storage/helpers.d.ts.map +1 -0
- package/dist/src/storage/helpers.js +28 -0
- package/dist/src/storage/helpers.js.map +1 -0
- package/dist/src/storage/i-block-storage.d.ts +32 -0
- package/dist/src/storage/i-block-storage.d.ts.map +1 -0
- package/dist/src/storage/i-block-storage.js +2 -0
- package/dist/src/storage/i-block-storage.js.map +1 -0
- package/dist/src/storage/i-raw-storage.d.ts +20 -0
- package/dist/src/storage/i-raw-storage.d.ts.map +1 -0
- package/dist/src/storage/i-raw-storage.js +2 -0
- package/dist/src/storage/i-raw-storage.js.map +1 -0
- package/dist/src/storage/memory-storage.d.ts +27 -0
- package/dist/src/storage/memory-storage.d.ts.map +1 -0
- package/dist/src/storage/memory-storage.js +87 -0
- package/dist/src/storage/memory-storage.js.map +1 -0
- package/dist/src/storage/restoration-coordinator-v2.d.ts +63 -0
- package/dist/src/storage/restoration-coordinator-v2.d.ts.map +1 -0
- package/dist/src/storage/restoration-coordinator-v2.js +157 -0
- package/dist/src/storage/restoration-coordinator-v2.js.map +1 -0
- package/dist/src/storage/ring-selector.d.ts +56 -0
- package/dist/src/storage/ring-selector.d.ts.map +1 -0
- package/dist/src/storage/ring-selector.js +118 -0
- package/dist/src/storage/ring-selector.js.map +1 -0
- package/dist/src/storage/storage-monitor.d.ts +23 -0
- package/dist/src/storage/storage-monitor.d.ts.map +1 -0
- package/dist/src/storage/storage-monitor.js +40 -0
- package/dist/src/storage/storage-monitor.js.map +1 -0
- package/dist/src/storage/storage-repo.d.ts +17 -0
- package/dist/src/storage/storage-repo.d.ts.map +1 -0
- package/dist/src/storage/storage-repo.js +267 -0
- package/dist/src/storage/storage-repo.js.map +1 -0
- package/dist/src/storage/struct.d.ts +29 -0
- package/dist/src/storage/struct.d.ts.map +1 -0
- package/dist/src/storage/struct.js +2 -0
- package/dist/src/storage/struct.js.map +1 -0
- package/dist/src/sync/client.d.ts +27 -0
- package/dist/src/sync/client.d.ts.map +1 -0
- package/dist/src/sync/client.js +32 -0
- package/dist/src/sync/client.js.map +1 -0
- package/dist/src/sync/protocol.d.ts +58 -0
- package/dist/src/sync/protocol.d.ts.map +1 -0
- package/dist/src/sync/protocol.js +12 -0
- package/dist/src/sync/protocol.js.map +1 -0
- package/dist/src/sync/service.d.ts +62 -0
- package/dist/src/sync/service.d.ts.map +1 -0
- package/dist/src/sync/service.js +168 -0
- package/dist/src/sync/service.js.map +1 -0
- package/package.json +73 -0
- package/readme.md +497 -0
- package/src/cluster/client.ts +63 -0
- package/src/cluster/cluster-repo.ts +711 -0
- package/src/cluster/partition-detector.ts +158 -0
- package/src/cluster/service.ts +156 -0
- package/src/index.ts +30 -0
- package/src/it-utility.ts +36 -0
- package/src/libp2p-key-network.ts +334 -0
- package/src/libp2p-node.ts +335 -0
- package/src/logger.ts +9 -0
- package/src/network/get-network-manager.ts +17 -0
- package/src/network/network-manager-service.ts +334 -0
- package/src/peer-utils.ts +24 -0
- package/src/protocol-client.ts +54 -0
- package/src/repo/client.ts +112 -0
- package/src/repo/cluster-coordinator.ts +592 -0
- package/src/repo/coordinator-repo.ts +137 -0
- package/src/repo/redirect.ts +17 -0
- package/src/repo/service.ts +219 -0
- package/src/repo/types.ts +7 -0
- package/src/routing/libp2p-known-peers.ts +26 -0
- package/src/routing/responsibility.ts +63 -0
- package/src/routing/simple-cluster-coordinator.ts +70 -0
- package/src/storage/arachnode-fret-adapter.ts +128 -0
- package/src/storage/block-storage.ts +182 -0
- package/src/storage/file-storage.ts +163 -0
- package/src/storage/helpers.ts +29 -0
- package/src/storage/i-block-storage.ts +40 -0
- package/src/storage/i-raw-storage.ts +30 -0
- package/src/storage/memory-storage.ts +108 -0
- package/src/storage/restoration-coordinator-v2.ts +191 -0
- package/src/storage/ring-selector.ts +155 -0
- package/src/storage/storage-monitor.ts +59 -0
- package/src/storage/storage-repo.ts +320 -0
- package/src/storage/struct.ts +34 -0
- package/src/sync/client.ts +42 -0
- package/src/sync/protocol.ts +71 -0
- package/src/sync/service.ts +229 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { buildSyncProtocol } from './protocol.js';
|
|
2
|
+
import { pipe } from 'it-pipe';
|
|
3
|
+
import { fromString as u8FromString } from 'uint8arrays/from-string';
|
|
4
|
+
import { toString as u8ToString } from 'uint8arrays/to-string';
|
|
5
|
+
import * as lp from 'it-length-prefixed';
|
|
6
|
+
/**
|
|
7
|
+
* Service for handling incoming sync requests from other cluster peers.
|
|
8
|
+
*
|
|
9
|
+
* Listens on the sync protocol and responds to block requests by:
|
|
10
|
+
* 1. Extracting the block from local storage
|
|
11
|
+
* 2. Building a BlockArchive with requested revisions
|
|
12
|
+
* 3. Sending the response back to the requester
|
|
13
|
+
*
|
|
14
|
+
* This is the server-side of the block restoration mechanism.
|
|
15
|
+
*/
|
|
16
|
+
export class SyncService {
|
|
17
|
+
components;
|
|
18
|
+
running = false;
|
|
19
|
+
log;
|
|
20
|
+
protocol;
|
|
21
|
+
repo;
|
|
22
|
+
registrar;
|
|
23
|
+
constructor(components, init = {}) {
|
|
24
|
+
this.components = components;
|
|
25
|
+
this.log = components.logger.forComponent('db-p2p:sync-service');
|
|
26
|
+
this.protocol = buildSyncProtocol(init.protocolPrefix ?? '');
|
|
27
|
+
this.repo = components.repo;
|
|
28
|
+
this.registrar = components.registrar;
|
|
29
|
+
}
|
|
30
|
+
async start() {
|
|
31
|
+
if (this.running)
|
|
32
|
+
return;
|
|
33
|
+
await this.registrar.handle(this.protocol, async (data) => {
|
|
34
|
+
await this.handleSyncRequest(data.stream);
|
|
35
|
+
});
|
|
36
|
+
this.running = true;
|
|
37
|
+
this.log('Sync service started on protocol %s', this.protocol);
|
|
38
|
+
}
|
|
39
|
+
async stop() {
|
|
40
|
+
if (!this.running)
|
|
41
|
+
return;
|
|
42
|
+
await this.registrar.unhandle(this.protocol);
|
|
43
|
+
this.running = false;
|
|
44
|
+
this.log('Sync service stopped');
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Handle an incoming sync request stream.
|
|
48
|
+
*/
|
|
49
|
+
async handleSyncRequest(stream) {
|
|
50
|
+
try {
|
|
51
|
+
// Read request using length-prefixed protocol
|
|
52
|
+
const request = await this.readRequest(stream);
|
|
53
|
+
this.log('[Ring Zulu] Received sync request for block %s revision %s', request.blockId, request.rev ?? 'latest');
|
|
54
|
+
// Build archive from local storage
|
|
55
|
+
const archive = await this.buildArchive(request.blockId, request.rev, request.includePending, request.maxRevisions);
|
|
56
|
+
// Send response
|
|
57
|
+
const response = archive
|
|
58
|
+
? {
|
|
59
|
+
success: true,
|
|
60
|
+
archive,
|
|
61
|
+
responderId: stream.id
|
|
62
|
+
}
|
|
63
|
+
: {
|
|
64
|
+
success: false,
|
|
65
|
+
error: 'Block not found in local storage'
|
|
66
|
+
};
|
|
67
|
+
await this.sendResponse(stream, response);
|
|
68
|
+
this.log('[Ring Zulu] %s sync request for block %s', response.success ? 'Fulfilled' : 'Failed', request.blockId);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
this.log.error('Error handling sync request:', error);
|
|
72
|
+
// Try to send error response
|
|
73
|
+
try {
|
|
74
|
+
const errorResponse = {
|
|
75
|
+
success: false,
|
|
76
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
77
|
+
};
|
|
78
|
+
await this.sendResponse(stream, errorResponse);
|
|
79
|
+
}
|
|
80
|
+
catch (sendError) {
|
|
81
|
+
this.log.error('Failed to send error response:', sendError);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
try {
|
|
86
|
+
await stream.close();
|
|
87
|
+
}
|
|
88
|
+
catch (closeError) {
|
|
89
|
+
// Ignore close errors
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Read and parse a sync request from the stream.
|
|
95
|
+
*/
|
|
96
|
+
async readRequest(stream) {
|
|
97
|
+
const messages = [];
|
|
98
|
+
await pipe(stream.source, lp.decode, async (source) => {
|
|
99
|
+
for await (const msg of source) {
|
|
100
|
+
messages.push(msg.subarray());
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
if (messages.length === 0) {
|
|
104
|
+
throw new Error('No request received');
|
|
105
|
+
}
|
|
106
|
+
const json = u8ToString(messages[0], 'utf8');
|
|
107
|
+
return JSON.parse(json);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Send a sync response to the stream.
|
|
111
|
+
*/
|
|
112
|
+
async sendResponse(stream, response) {
|
|
113
|
+
const json = JSON.stringify(response);
|
|
114
|
+
const bytes = u8FromString(json, 'utf8');
|
|
115
|
+
await pipe([bytes], lp.encode, stream.sink);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Build a block archive from local storage.
|
|
119
|
+
*
|
|
120
|
+
* @param blockId - Block to retrieve
|
|
121
|
+
* @param rev - Optional specific revision
|
|
122
|
+
* @param includePending - Whether to include pending transactions
|
|
123
|
+
* @param maxRevisions - Maximum number of revisions to include
|
|
124
|
+
* @returns BlockArchive if found, undefined otherwise
|
|
125
|
+
*/
|
|
126
|
+
async buildArchive(blockId, rev, _includePending, _maxRevisions) {
|
|
127
|
+
try {
|
|
128
|
+
// Get the block from local storage
|
|
129
|
+
const context = rev !== undefined
|
|
130
|
+
? { rev, committed: [], pending: [] }
|
|
131
|
+
: undefined;
|
|
132
|
+
const result = await this.repo.get({
|
|
133
|
+
blockIds: [blockId],
|
|
134
|
+
context
|
|
135
|
+
});
|
|
136
|
+
const blockResult = result[blockId];
|
|
137
|
+
if (!blockResult || !blockResult.state.latest) {
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
const latest = blockResult.state.latest;
|
|
141
|
+
// Return minimal archive with just the requested block
|
|
142
|
+
const archive = {
|
|
143
|
+
blockId,
|
|
144
|
+
revisions: {
|
|
145
|
+
[latest.rev]: {
|
|
146
|
+
action: {
|
|
147
|
+
actionId: latest.actionId,
|
|
148
|
+
transform: { insert: blockResult.block }
|
|
149
|
+
},
|
|
150
|
+
block: blockResult.block
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
range: [latest.rev, latest.rev + 1]
|
|
154
|
+
};
|
|
155
|
+
return archive;
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
this.log.error('Error building archive for block %s:', blockId, error);
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Factory function for creating a SyncService.
|
|
165
|
+
* Follows the libp2p service pattern.
|
|
166
|
+
*/
|
|
167
|
+
export const syncService = (init = {}) => (components) => new SyncService(components, init);
|
|
168
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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qBACxB;iBACD;gBACD,KAAK,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC;aACnC,CAAC;YAEF,OAAO,OAAO,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,sCAAsC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;YACvE,OAAO,SAAS,CAAC;QAClB,CAAC;IACF,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAwB,EAAE,EAAE,EAAE,CACzD,CAAC,UAAiC,EAAE,EAAE,CAAC,IAAI,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@optimystic/db-p2p",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "P2P database functionality for Optimystic",
|
|
6
|
+
"main": "dist/src/index.js",
|
|
7
|
+
"types": "./dist/src/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"src",
|
|
10
|
+
"dist",
|
|
11
|
+
"!dist/test",
|
|
12
|
+
"!**/*.tsbuildinfo"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/src/index.d.ts",
|
|
17
|
+
"import": "./dist/src/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/gotchoices/optimystic.git",
|
|
23
|
+
"directory": "packages/db-p2p"
|
|
24
|
+
},
|
|
25
|
+
"author": "Got Choices Foundation",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"keywords": [
|
|
28
|
+
"optimystic",
|
|
29
|
+
"database",
|
|
30
|
+
"p2p",
|
|
31
|
+
"peer-to-peer",
|
|
32
|
+
"libp2p",
|
|
33
|
+
"distributed",
|
|
34
|
+
"dht",
|
|
35
|
+
"gossipsub"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"clean": "aegir clean",
|
|
39
|
+
"build": "aegir build --env node",
|
|
40
|
+
"lint": "aegir lint",
|
|
41
|
+
"test": "aegir test",
|
|
42
|
+
"test:node": "aegir test -t node",
|
|
43
|
+
"dep-check": "aegir dep-check"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^24.0.12",
|
|
47
|
+
"aegir": "^47.0.20",
|
|
48
|
+
"typescript": "^5.8.3"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@chainsafe/libp2p-gossipsub": "^14.1.1",
|
|
52
|
+
"@chainsafe/libp2p-noise": "^16.1.4",
|
|
53
|
+
"@chainsafe/libp2p-yamux": "^7.0.4",
|
|
54
|
+
"@libp2p/bootstrap": "^11.0.46",
|
|
55
|
+
"@libp2p/identify": "^3.0.38",
|
|
56
|
+
"@libp2p/interface": "^2.10.5",
|
|
57
|
+
"@libp2p/kad-dht": "^15.1.10",
|
|
58
|
+
"@libp2p/peer-id": "^5.1.8",
|
|
59
|
+
"@libp2p/ping": "^2.0.36",
|
|
60
|
+
"@libp2p/tcp": "^10.1.18",
|
|
61
|
+
"@libp2p/websockets": "^9.2.18",
|
|
62
|
+
"@optimystic/db-core": "^0.0.1",
|
|
63
|
+
"async-mutex": "^0.5.0",
|
|
64
|
+
"debug": "^4.4.1",
|
|
65
|
+
"it-all": "^3.0.7",
|
|
66
|
+
"it-length-prefixed": "^10.0.1",
|
|
67
|
+
"it-pipe": "^3.0.1",
|
|
68
|
+
"libp2p": "^2.9.0",
|
|
69
|
+
"multiformats": "^13.3.2",
|
|
70
|
+
"p2p-fret": "^0.1.0",
|
|
71
|
+
"uint8arrays": "^5.1.0"
|
|
72
|
+
}
|
|
73
|
+
}
|