@brown-ds/distribution 0.2.18 → 0.2.20

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
@@ -1,9 +1,16 @@
1
1
  # distribution
2
2
 
3
- This is the distribution library. When loaded, distribution introduces functionality supporting the distributed execution of programs. To download it:
3
+ This is the distribution library.
4
+
5
+ ## Environment Setup
6
+
7
+ We recommend using the prepared [container image](https://github.com/brown-cs1380/container).
4
8
 
5
9
  ## Installation
6
10
 
11
+ After you have setup your environment, you can start using the distribution library.
12
+ When loaded, distribution introduces functionality supporting the distributed execution of programs. To download it:
13
+
7
14
  ```sh
8
15
  $ npm i '@brown-ds/distribution'
9
16
  ```
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
6
6
 
7
7
  If you notice any issues with using this file, please contact the TAs.
8
8
  */
9
- const log=require('../util/lo'+'g.js'),id=require('../util/id'+'.js');function normalize(_0x591c23,_0x20082e){if(_0x591c23===null)return{'key':null,'gid':_0x20082e,'action':'put'};else return typeof _0x591c23==='string'?{'key':_0x591c23,'gid':_0x20082e,'action':'put'}:_0x591c23;}function mem(_0x356653){const _0x196bbd={};_0x196bbd['gid']=_0x356653['gid']||'all',_0x196bbd['hash']=_0x356653['hash']||id['naiveHash'];function _0x5b04f0(_0x23d0a8,_0x4ad4d1){log('[all.mem.g'+'et]\x20config'+'uration:\x20'+JSON['stringify'](_0x23d0a8)+'\x20context:\x20'+JSON['stringify'](_0x196bbd)),_0x23d0a8=normalize(_0x23d0a8,_0x196bbd['gid']),_0x23d0a8['gid']=_0x23d0a8['gid']||_0x196bbd['gid'];const _0x119b8a={'service':'mem','method':'get'},_0x577f36=[_0x23d0a8];if(!_0x23d0a8['key']){globalThis['distributi'+'on'][_0x196bbd['gid']]['comm']['send'](_0x577f36,_0x119b8a,(_0x22554e,_0x1f7e60)=>{const _0x1b51ed=Object['values'](_0x1f7e60)['reduce']((_0x1bd2fe,_0x39aa0c)=>_0x1bd2fe['concat'](_0x39aa0c),[]);_0x4ad4d1(_0x22554e,_0x1b51ed);});return;}const _0x288021=_0x23d0a8['key'];if(_0x288021===null){_0x4ad4d1(new TypeError('Configurat'+'ion\x20is\x20nul'+'l'));return;}globalThis['distributi'+'on']['util']['wire']['dispatchMe'+'ssage'](_0x577f36,_0x119b8a,{'key':_0x288021},_0x196bbd,_0x4ad4d1);}function _0x2728a8(_0x254a67,_0x154f9e,_0x33d4d4){log('[all.mem.p'+'ut]\x20state:'+'\x20'+JSON['stringify'](_0x254a67)+('\x20configura'+'tion:\x20')+JSON['stringify'](_0x154f9e)),_0x154f9e=_0x154f9e||globalThis['distributi'+'on']['util']['id']['getID'](_0x254a67),_0x154f9e=normalize(_0x154f9e,_0x196bbd['gid']),_0x154f9e['gid']=_0x154f9e['gid']||_0x196bbd['gid'];const _0x3519e7={'service':'mem','method':'put'},_0x415567=[_0x254a67,_0x154f9e],_0x303888=_0x154f9e['key'];if(_0x303888===null){_0x33d4d4(new TypeError('Configurat'+'ion\x20is\x20nul'+'l'));return;}globalThis['distributi'+'on']['util']['wire']['dispatchMe'+'ssage'](_0x415567,_0x3519e7,{'key':_0x303888},_0x196bbd,_0x33d4d4);}function _0x4adf94(_0x2aede1,_0x3c4fb6){log('[all.mem.d'+'el]\x20config'+'uration:\x20'+JSON['stringify'](_0x2aede1)),_0x2aede1=normalize(_0x2aede1,_0x196bbd['gid']),_0x2aede1['gid']=_0x2aede1['gid']||_0x196bbd['gid'];const _0x2bb8f7={'service':'mem','method':'del'},_0x5e54fe=[_0x2aede1],_0x21dee8=_0x2aede1['key'];if(_0x21dee8===null){_0x3c4fb6(new TypeError('Configurat'+'ion\x20is\x20nul'+'l'));return;}globalThis['distributi'+'on']['util']['wire']['dispatchMe'+'ssage'](_0x5e54fe,_0x2bb8f7,{'key':_0x21dee8},_0x196bbd,_0x3c4fb6);}function _0x22bb56(_0x572579,_0x3b7c89){log('[mem.recon'+'f]\x20configu'+'ration:\x20'+JSON['stringify'](_0x572579)+'\x20gid:\x20'+_0x196bbd['gid']),globalThis['distributi'+'on']['local']['groups']['get'](_0x196bbd['gid'],(_0x4120d2,_0x2bc999)=>{if(!_0x2bc999){_0x3b7c89(_0x4120d2);return;}globalThis['distributi'+'on']['local']['groups']['put'](_0x196bbd['gid'],_0x572579,(_0x2194b0,_0x411fcc)=>{globalThis['distributi'+'on'][_0x196bbd['gid']]['mem']['get'](null,(_0x6ee088,_0x24f514)=>{globalThis['distributi'+'on']['local']['groups']['put'](_0x196bbd['gid'],_0x2bc999,(_0x3f0344,_0x2d8cf0)=>{globalThis['distributi'+'on'][_0x196bbd['gid']]['status']['get']('nid',(_0xb514ce,_0x96f40f)=>{const _0x2ee36e=Object['values'](_0x96f40f),_0xc4b120=Object['values'](_0x572579)['map'](_0x107508=>globalThis['distributi'+'on']['util']['id']['getNID'](_0x107508));log('[mem.recon'+'f\x20received'+'\x20'+_0x24f514['length']+('\x20keys\x20from'+'\x20')+_0x96f40f['length']+'\x20nodes');let _0x1e85c2=0x2134+0x1701+-0x3835*0x1;const _0x3b61f0=()=>{if(_0x1e85c2===_0x24f514['length'])return _0x3b7c89(null);};if(_0x24f514['length']===0x1878+0x50*-0x5f+0x2*0x29c)return _0x3b7c89(null);for(const _0x250562 of _0x24f514){const _0x25d18a=globalThis['distributi'+'on']['util']['id']['getID'](_0x250562),_0x3514a1=_0x196bbd['hash'](_0x25d18a,_0xc4b120),_0x392cbf=_0x196bbd['hash'](_0x25d18a,_0x2ee36e);log('[mem.recon'+'f]\x20old\x20nid'+':\x20'+_0x3514a1+'\x20new\x20nid:\x20'+_0x392cbf);if(_0x3514a1===_0x392cbf){_0x1e85c2++,_0x3b61f0();continue;}const _0x54967f=_0x572579[_0x3514a1['substring'](-0x1*-0x7a+0x1*0x1861+-0x18db,0x92f+0x13c5+0x9*-0x337)],_0x401ab4=[{'key':_0x250562,'gid':_0x196bbd['gid']}],_0x4a9164={'service':'mem','method':'del','node':_0x54967f};log('[mem.recon'+'f]\x20deletin'+'g\x20key\x20'+_0x250562+'\x20from\x20'+JSON['stringify'](_0x4a9164)),globalThis['distributi'+'on']['local']['comm']['send'](_0x401ab4,_0x4a9164,(_0x3ca5e3,_0x5338c0)=>{globalThis['distributi'+'on'][_0x196bbd['gid']]['mem']['put'](_0x5338c0,_0x250562,(_0x526b36,_0x356fa2)=>{_0x1e85c2++,_0x3b61f0();});});}});});});});});}return{'get':_0x5b04f0,'put':_0x2728a8,'del':_0x4adf94,'reconf':_0x22bb56};}module['exports']=mem;
9
+ const log=require('../util/lo'+'g.js');function normalize(_0x560984,_0x5cacc3){if(_0x560984===null)return{'key':null,'gid':_0x5cacc3,'action':'put'};else return typeof _0x560984==='string'?{'key':_0x560984,'gid':_0x5cacc3,'action':'put'}:_0x560984;}function mem(_0x5840f0){const _0x34312a={};_0x34312a['gid']=_0x5840f0['gid']||'all',_0x34312a['hash']=_0x5840f0['hash']||globalThis['distributi'+'on']['util']['id']['naiveHash'];function _0x2be59e(_0x2039c8,_0x347ba2){log('[all.mem.g'+'et]\x20config'+'uration:\x20'+JSON['stringify'](_0x2039c8)+'\x20context:\x20'+JSON['stringify'](_0x34312a)),_0x2039c8=normalize(_0x2039c8,_0x34312a['gid']),_0x2039c8['gid']=_0x2039c8['gid']||_0x34312a['gid'];const _0x28bf53={'service':'mem','method':'get'},_0x2e7334=[_0x2039c8];if(!_0x2039c8['key']){globalThis['distributi'+'on'][_0x34312a['gid']]['comm']['send'](_0x2e7334,_0x28bf53,(_0x348596,_0x5e2f1f)=>{const _0x127db8=Object['values'](_0x5e2f1f)['reduce']((_0xddd93,_0x17700f)=>_0xddd93['concat'](_0x17700f),[]);_0x347ba2(_0x348596,_0x127db8);});return;}const _0x5015ea=_0x2039c8['key'];if(_0x5015ea===null){_0x347ba2(new TypeError('Configurat'+'ion\x20is\x20nul'+'l'));return;}globalThis['distributi'+'on']['util']['wire']['dispatchMe'+'ssage'](_0x2e7334,_0x28bf53,{'key':_0x5015ea},_0x34312a,_0x347ba2);}function _0x523325(_0x3f107f,_0x323cc5,_0x227bac){log('[all.mem.p'+'ut]\x20state:'+'\x20'+JSON['stringify'](_0x3f107f)+('\x20configura'+'tion:\x20')+JSON['stringify'](_0x323cc5)),_0x323cc5=_0x323cc5||globalThis['distributi'+'on']['util']['id']['getID'](_0x3f107f),_0x323cc5=normalize(_0x323cc5,_0x34312a['gid']),_0x323cc5['gid']=_0x323cc5['gid']||_0x34312a['gid'];const _0x25ae8a={'service':'mem','method':'put'},_0x4e373e=[_0x3f107f,_0x323cc5],_0x336792=_0x323cc5['key'];if(_0x336792===null){_0x227bac(new TypeError('Configurat'+'ion\x20is\x20nul'+'l'));return;}globalThis['distributi'+'on']['util']['wire']['dispatchMe'+'ssage'](_0x4e373e,_0x25ae8a,{'key':_0x336792},_0x34312a,_0x227bac);}function _0x3ba487(_0x5e9fea,_0x272b53){log('[all.mem.d'+'el]\x20config'+'uration:\x20'+JSON['stringify'](_0x5e9fea)),_0x5e9fea=normalize(_0x5e9fea,_0x34312a['gid']),_0x5e9fea['gid']=_0x5e9fea['gid']||_0x34312a['gid'];const _0x3614bd={'service':'mem','method':'del'},_0x65432c=[_0x5e9fea],_0x3b7baf=_0x5e9fea['key'];if(_0x3b7baf===null){_0x272b53(new TypeError('Configurat'+'ion\x20is\x20nul'+'l'));return;}globalThis['distributi'+'on']['util']['wire']['dispatchMe'+'ssage'](_0x65432c,_0x3614bd,{'key':_0x3b7baf},_0x34312a,_0x272b53);}function _0x465dd2(_0x2d4472,_0x12289b){log('[mem.recon'+'f]\x20configu'+'ration:\x20'+JSON['stringify'](_0x2d4472)+'\x20gid:\x20'+_0x34312a['gid']),globalThis['distributi'+'on']['local']['groups']['get'](_0x34312a['gid'],(_0x554c1e,_0x1831bb)=>{if(!_0x1831bb){_0x12289b(_0x554c1e);return;}globalThis['distributi'+'on']['local']['groups']['put'](_0x34312a['gid'],_0x2d4472,(_0x4821fe,_0x44d12c)=>{globalThis['distributi'+'on'][_0x34312a['gid']]['mem']['get'](null,(_0x56ff65,_0x347fde)=>{globalThis['distributi'+'on']['local']['groups']['put'](_0x34312a['gid'],_0x1831bb,(_0x5d891d,_0x5de5f6)=>{globalThis['distributi'+'on'][_0x34312a['gid']]['status']['get']('nid',(_0x3e4d48,_0x33f368)=>{const _0x5069ff=Object['values'](_0x33f368),_0x1122aa=Object['values'](_0x2d4472)['map'](_0x1dd7d4=>globalThis['distributi'+'on']['util']['id']['getNID'](_0x1dd7d4));log('[mem.recon'+'f\x20received'+'\x20'+_0x347fde['length']+('\x20keys\x20from'+'\x20')+_0x33f368['length']+'\x20nodes');let _0x4e8293=-0xa8e*-0x3+0x454+-0x23fe;const _0x3d4b05=()=>{if(_0x4e8293===_0x347fde['length'])return _0x12289b(null);};if(_0x347fde['length']===-0x13*0x27+0x277*-0x2+0x7d3)return _0x12289b(null);for(const _0x222073 of _0x347fde){const _0x194011=globalThis['distributi'+'on']['util']['id']['getID'](_0x222073),_0x10d4c1=_0x34312a['hash'](_0x194011,_0x1122aa),_0x6e7bcd=_0x34312a['hash'](_0x194011,_0x5069ff);log('[mem.recon'+'f]\x20old\x20nid'+':\x20'+_0x10d4c1+'\x20new\x20nid:\x20'+_0x6e7bcd);if(_0x10d4c1===_0x6e7bcd){_0x4e8293++,_0x3d4b05();continue;}const _0x4aecac=_0x2d4472[_0x10d4c1['substring'](-0x7bb*-0x3+-0x7b2+-0xf7f,0x534*-0x6+-0xaab+0x29e8)],_0x514569=[{'key':_0x222073,'gid':_0x34312a['gid']}],_0x50f474={'service':'mem','method':'del','node':_0x4aecac};log('[mem.recon'+'f]\x20deletin'+'g\x20key\x20'+_0x222073+'\x20from\x20'+JSON['stringify'](_0x50f474)),globalThis['distributi'+'on']['local']['comm']['send'](_0x514569,_0x50f474,(_0x3bff3d,_0x38fb08)=>{globalThis['distributi'+'on'][_0x34312a['gid']]['mem']['put'](_0x38fb08,_0x222073,(_0x534572,_0x35f75c)=>{_0x4e8293++,_0x3d4b05();});});}});});});});});}return{'get':_0x2be59e,'put':_0x523325,'del':_0x3ba487,'reconf':_0x465dd2};}module['exports']=mem;
10
10
  /* eslint-enable */
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
6
6
 
7
7
  If you notice any issues with using this file, please contact the TAs.
8
8
  */
9
- function status(_0x543e8f){const _0x30aea1={};_0x30aea1['gid']=_0x543e8f['gid']||'all';function _0x4657fd(_0x81d5fe,_0x39c5e3){const _0x202a65=[_0x81d5fe],_0x1b1a26={'service':'status','method':'get'};globalThis['distributi'+'on'][_0x30aea1['gid']]['comm']['send'](_0x202a65,_0x1b1a26,(_0xef2e3e,_0x27ae26)=>{switch(_0x81d5fe){case'heapTotal':const _0x53e3d1=Object['values'](_0x27ae26)['reduce']((_0x46c7b4,_0x56cc4b)=>{return _0x46c7b4+_0x56cc4b;},-0x24*-0x68+-0x165c+0x7bc);return _0x39c5e3(_0xef2e3e,_0x53e3d1);break;case'nid':const _0x1bb02d=Object['values'](_0x27ae26)['reduce']((_0x2eff33,_0x5ce96f)=>{return _0x2eff33['concat'](_0x5ce96f);},[]);return _0x39c5e3(_0xef2e3e,_0x1bb02d);break;default:return _0x39c5e3(_0xef2e3e,_0x27ae26);break;}});}function _0x1575b2(_0x1fdcdc,_0x535956){globalThis['distributi'+'on']['local']['status']['spawn'](_0x1fdcdc,(_0x5a2284,_0x89795f)=>{globalThis['distributi'+'on'][_0x30aea1['gid']]['comm']['send']([_0x30aea1['gid'],_0x1fdcdc],{'service':'groups','method':'add'},()=>{});if(_0x5a2284)return _0x535956(_0x5a2284);globalThis['distributi'+'on']['local']['groups']['add'](_0x30aea1['gid'],_0x1fdcdc,()=>{return _0x535956(null,_0x89795f);});});}function _0x5ee009(_0x1354c7){globalThis['distributi'+'on'][_0x30aea1['gid']]['comm']['send']([],{'service':'status','method':'stop'},()=>{globalThis['distributi'+'on']['local']['status']['stop'](_0x1354c7);});}return{'get':_0x4657fd,'stop':_0x5ee009,'spawn':_0x1575b2};}module['exports']=status;
9
+ function status(_0xe569d2){const _0x2b7dcc={};_0x2b7dcc['gid']=_0xe569d2['gid']||'all';function _0x502cb(_0x1e3422,_0x5d23ae){const _0x5c5355=[_0x1e3422],_0x2b2161={'service':'status','method':'get'};globalThis['distributi'+'on'][_0x2b7dcc['gid']]['comm']['send'](_0x5c5355,_0x2b2161,(_0x466833,_0xe860e9)=>{switch(_0x1e3422){case'heapTotal':const _0x2b6d9a=Object['values'](_0xe860e9)['reduce']((_0x22e7fd,_0x129ddc)=>{return _0x22e7fd+_0x129ddc;},-0x122d+-0x1*0x235d+0x358a);return _0x5d23ae(_0x466833,_0x2b6d9a);break;case'nid':const _0x3bc516=Object['values'](_0xe860e9)['reduce']((_0x41c188,_0x302416)=>{return _0x41c188['concat'](_0x302416);},[]);return _0x5d23ae(_0x466833,_0x3bc516);break;default:return _0x5d23ae(_0x466833,_0xe860e9);break;}});}function _0x5076fe(_0x6ee9a0,_0xc6f21d){globalThis['distributi'+'on']['local']['status']['spawn'](_0x6ee9a0,(_0x2fadf6,_0x459797)=>{globalThis['distributi'+'on'][_0x2b7dcc['gid']]['comm']['send']([_0x2b7dcc['gid'],_0x6ee9a0],{'service':'groups','method':'add'},()=>{});if(_0x2fadf6)return _0xc6f21d(_0x2fadf6);globalThis['distributi'+'on']['local']['groups']['add'](_0x2b7dcc['gid'],_0x6ee9a0,()=>{return _0xc6f21d(null,_0x459797);});});return;_0xc6f21d(new Error('status.spa'+'wn\x20not\x20imp'+'lemented'));}function _0x5cfcfa(_0x5397c5){globalThis['distributi'+'on'][_0x2b7dcc['gid']]['comm']['send']([],{'service':'status','method':'stop'},()=>{globalThis['distributi'+'on']['local']['status']['stop'](_0x5397c5);});return;_0x5397c5(new Error('status.sto'+'p\x20not\x20impl'+'emented'));}return{'get':_0x502cb,'stop':_0x5cfcfa,'spawn':_0x5076fe};}module['exports']=status;
10
10
  /* eslint-enable */
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
6
6
 
7
7
  If you notice any issues with using this file, please contact the TAs.
8
8
  */
9
- const log=require('../util/lo'+'g.js'),id=require('../util/id'+'.js');function getNode(_0x54f2ab,_0x104310,_0x417e49){const _0x286a0c=_0x104310&&typeof _0x104310==='object'?_0x104310['key']:_0x104310;globalThis['distributi'+'on'][_0x54f2ab['gid']]['status']['get']('nid',(_0x1bb184,_0x1094d6)=>{const _0x4ce8c6=Object['values'](_0x1094d6),_0x170a06=globalThis['distributi'+'on']['util']['id']['getID'](_0x286a0c),_0x884c49=_0x54f2ab['hash'](_0x170a06,_0x4ce8c6),_0x3b2660=_0x884c49['substring'](0x756+0xf51+0x16a7*-0x1,0x2*-0xe35+0x674+0x15fb);globalThis['distributi'+'on']['local']['groups']['get'](_0x54f2ab['gid'],(_0x417d10,_0x1e541a)=>{if(!_0x1e541a)return _0x417e49(_0x417d10);else{const _0x5a6480=_0x1e541a[_0x3b2660];return log('[store\x20(ge'+'tNode)]\x20co'+'nfiguratio'+'n:\x20'+JSON['stringify'](_0x104310)+'group:\x20'+JSON['stringify'](_0x1e541a)+'\x20node:\x20'+JSON['stringify'](_0x5a6480)+'nid:\x20'+JSON['stringify'](_0x884c49)+'\x20sid:\x20'+JSON['stringify'](_0x3b2660)),_0x417e49(null,_0x5a6480);}});});}function normalize(_0x58ddde,_0x2fc7b5){if(_0x58ddde===null)return{'key':null,'gid':_0x2fc7b5,'action':'put'};else return typeof _0x58ddde==='string'?{'key':_0x58ddde,'gid':_0x2fc7b5,'action':'put'}:_0x58ddde;}function store(_0x4ce0c4){const _0x342ef9={'gid':_0x4ce0c4['gid']||'all','hash':_0x4ce0c4['hash']||id['naiveHash'],'subset':_0x4ce0c4['subset']};function _0x5eee3b(_0x31d5d4,_0x45697f){if(!_0x31d5d4){const _0x4f822c=[{'key':null,'gid':_0x342ef9['gid']}];globalThis['distributi'+'on'][_0x342ef9['gid']]['comm']['send'](_0x4f822c,{'service':'store','method':'get'},(_0x24701d,_0x59d7ae)=>{const _0x27749b=Object['values'](_0x59d7ae)['reduce']((_0x3ffffc,_0x80eed9)=>_0x3ffffc['concat'](_0x80eed9),[]);_0x45697f(_0x24701d,_0x27749b);});return;}_0x31d5d4=normalize(_0x31d5d4,_0x342ef9['gid']),getNode(_0x342ef9,_0x31d5d4,(_0x4b8867,_0x524904)=>{if(!_0x524904){_0x45697f(_0x4b8867);return;}const _0x3578bd=[_0x31d5d4],_0x3061cf={'service':'store','method':'get','node':_0x524904};log('[all.store'+'.get]confi'+'guration:\x20'+JSON['stringify'](_0x31d5d4)+'node:\x20'+JSON['stringify'](globalThis['distributi'+'on']['node']['config'])+('\x20target\x20no'+'de:\x20')+JSON['stringify'](_0x524904)),globalThis['distributi'+'on']['local']['comm']['send'](_0x3578bd,_0x3061cf,_0x45697f);});}function _0x258e41(_0x2d3ff1,_0x469b5e,_0x41fd2b){_0x469b5e=_0x469b5e||globalThis['distributi'+'on']['util']['id']['getID'](_0x2d3ff1),_0x469b5e=normalize(_0x469b5e,_0x342ef9['gid']),getNode(_0x342ef9,_0x469b5e,(_0x15be48,_0x14b088)=>{if(!_0x14b088){_0x41fd2b(_0x15be48);return;}const _0x2e5ef8=[_0x2d3ff1,_0x469b5e],_0x4a465f={'service':'store','method':'put','node':_0x14b088};log('[all.store'+'.put]\x20stat'+'e:\x20'+JSON['stringify'](_0x2d3ff1)+('configurat'+'ion:\x20')+JSON['stringify'](_0x469b5e)+('target\x20nod'+'e:\x20')+JSON['stringify'](_0x14b088)),globalThis['distributi'+'on']['local']['comm']['send'](_0x2e5ef8,_0x4a465f,_0x41fd2b);});}function _0x43d7ee(_0x5e4181,_0x599c54){getNode(_0x342ef9,_0x5e4181,(_0x3e7c40,_0x2e63a2)=>{if(!_0x2e63a2){_0x599c54(_0x3e7c40);return;}const _0x3af5a1=[{'key':_0x5e4181,'gid':_0x342ef9['gid']}],_0x1dc4d1={'service':'store','method':'del','node':_0x2e63a2};globalThis['distributi'+'on']['local']['comm']['send'](_0x3af5a1,_0x1dc4d1,_0x599c54);});}function _0x125e7f(_0x24a30c,_0xa57bbb){log('[store.rec'+'onf]\x20confi'+'guration:\x20'+JSON['stringify'](_0x24a30c)+'\x20gid:\x20'+_0x342ef9['gid']),globalThis['distributi'+'on']['local']['groups']['get'](_0x342ef9['gid'],(_0x3617a4,_0x16ec7c)=>{if(!_0x16ec7c){_0xa57bbb(_0x3617a4);return;}globalThis['distributi'+'on']['local']['groups']['put'](_0x342ef9['gid'],_0x24a30c,(_0x3b0ae4,_0x30e7ab)=>{globalThis['distributi'+'on'][_0x342ef9['gid']]['store']['get'](null,(_0x14b1ba,_0x731a19)=>{globalThis['distributi'+'on']['local']['groups']['put'](_0x342ef9['gid'],_0x16ec7c,(_0x148482,_0xe6899f)=>{globalThis['distributi'+'on'][_0x342ef9['gid']]['status']['get']('nid',(_0xa49683,_0x25087d)=>{const _0x1c4cfb=Object['values'](_0x25087d),_0x47f47e=Object['values'](_0x24a30c)['map'](_0xc416e7=>globalThis['distributi'+'on']['util']['id']['getNID'](_0xc416e7));log('[store.rec'+'onf\x20receiv'+'ed\x20'+_0x731a19['length']+('\x20keys\x20from'+'\x20')+_0x25087d['length']+'\x20nodes');let _0xa392ee=-0x657+-0x26b*0x4+-0x1003*-0x1;const _0x43432d=()=>{if(_0xa392ee===_0x731a19['length'])return _0xa57bbb(null);};if(_0x731a19['length']===-0xb43*-0x1+-0x12da*-0x1+0x1e1d*-0x1)return _0xa57bbb(null);for(const _0x4cda3e of _0x731a19){const _0x18d567=globalThis['distributi'+'on']['util']['id']['getID'](_0x4cda3e),_0x138fb2=_0x342ef9['hash'](_0x18d567,_0x47f47e),_0x9791cf=_0x342ef9['hash'](_0x18d567,_0x1c4cfb);log('[store.rec'+'onf]\x20old\x20n'+'id:\x20'+_0x138fb2+'\x20new\x20nid:\x20'+_0x9791cf);if(_0x138fb2===_0x9791cf){_0xa392ee++,_0x43432d();continue;}const _0x48e3af=_0x24a30c[_0x138fb2['substring'](0x1b5*0x14+-0x17*-0x65+-0x2b37,0x324+-0x1*-0x18c5+0x4*-0x6f9)],_0x2a66f7=[{'key':_0x4cda3e,'gid':_0x342ef9['gid']}],_0x465828={'service':'store','method':'del','node':_0x48e3af};log('[store.rec'+'onf]\x20delet'+'ing\x20key\x20'+_0x4cda3e+'\x20from\x20'+JSON['stringify'](_0x465828)),globalThis['distributi'+'on']['local']['comm']['send'](_0x2a66f7,_0x465828,(_0x4628e6,_0x3ef34a)=>{globalThis['distributi'+'on'][_0x342ef9['gid']]['store']['put'](_0x3ef34a,_0x4cda3e,(_0x2dd16d,_0x53a8b6)=>{_0xa392ee++,_0x43432d();});});}});});});});});}return{'get':_0x5eee3b,'put':_0x258e41,'del':_0x43d7ee,'reconf':_0x125e7f};}module['exports']=store;
9
+ const log=require('../util/lo'+'g.js');function getNode(_0x45a080,_0x4b8540,_0x679cda){const _0x59d3db=_0x4b8540&&typeof _0x4b8540==='object'?_0x4b8540['key']:_0x4b8540;globalThis['distributi'+'on'][_0x45a080['gid']]['status']['get']('nid',(_0x14eec2,_0x2061c3)=>{const _0x5eee70=Object['values'](_0x2061c3),_0x14e92a=globalThis['distributi'+'on']['util']['id']['getID'](_0x59d3db),_0x1c4735=_0x45a080['hash'](_0x14e92a,_0x5eee70),_0x3effa9=_0x1c4735['substring'](-0xe7e+-0x1a3c+0x28ba,0x4a3*0x4+0x1*-0x4f3+-0xd94);globalThis['distributi'+'on']['local']['groups']['get'](_0x45a080['gid'],(_0x514532,_0x5e180c)=>{if(!_0x5e180c)return _0x679cda(_0x514532);else{const _0x2794e1=_0x5e180c[_0x3effa9];return log('[store\x20(ge'+'tNode)]\x20co'+'nfiguratio'+'n:\x20'+JSON['stringify'](_0x4b8540)+'group:\x20'+JSON['stringify'](_0x5e180c)+'\x20node:\x20'+JSON['stringify'](_0x2794e1)+'nid:\x20'+JSON['stringify'](_0x1c4735)+'\x20sid:\x20'+JSON['stringify'](_0x3effa9)),_0x679cda(null,_0x2794e1);}});});}function normalize(_0x2d26dc,_0x23b192){if(_0x2d26dc===null)return{'key':null,'gid':_0x23b192,'action':'put'};else return typeof _0x2d26dc==='string'?{'key':_0x2d26dc,'gid':_0x23b192,'action':'put'}:_0x2d26dc;}function store(_0x2a6966){const _0x13beb6={'gid':_0x2a6966['gid']||'all','hash':_0x2a6966['hash']||globalThis['distributi'+'on']['util']['id']['naiveHash'],'subset':_0x2a6966['subset']};function _0xa7d797(_0x29d2cc,_0x2ac71c){if(!_0x29d2cc){const _0x2d2e8f=[{'key':null,'gid':_0x13beb6['gid']}];globalThis['distributi'+'on'][_0x13beb6['gid']]['comm']['send'](_0x2d2e8f,{'service':'store','method':'get'},(_0x2948b2,_0x2f9d59)=>{const _0x5b44bc=Object['values'](_0x2f9d59)['reduce']((_0x50bde0,_0x13f996)=>_0x50bde0['concat'](_0x13f996),[]);_0x2ac71c(_0x2948b2,_0x5b44bc);});return;}_0x29d2cc=normalize(_0x29d2cc,_0x13beb6['gid']),getNode(_0x13beb6,_0x29d2cc,(_0x5f08f7,_0x2f16f5)=>{if(!_0x2f16f5){_0x2ac71c(_0x5f08f7);return;}const _0x1897fe=[_0x29d2cc],_0x1b1e30={'service':'store','method':'get','node':_0x2f16f5};log('[all.store'+'.get]confi'+'guration:\x20'+JSON['stringify'](_0x29d2cc)+'node:\x20'+JSON['stringify'](globalThis['distributi'+'on']['node']['config'])+('\x20target\x20no'+'de:\x20')+JSON['stringify'](_0x2f16f5)),globalThis['distributi'+'on']['local']['comm']['send'](_0x1897fe,_0x1b1e30,_0x2ac71c);});}function _0x41f07b(_0x59a77e,_0xc4037a,_0x413b5d){_0xc4037a=_0xc4037a||globalThis['distributi'+'on']['util']['id']['getID'](_0x59a77e),_0xc4037a=normalize(_0xc4037a,_0x13beb6['gid']),getNode(_0x13beb6,_0xc4037a,(_0x4a3677,_0x38a38b)=>{if(!_0x38a38b){_0x413b5d(_0x4a3677);return;}const _0x236507=[_0x59a77e,_0xc4037a],_0xd3748f={'service':'store','method':'put','node':_0x38a38b};log('[all.store'+'.put]\x20stat'+'e:\x20'+JSON['stringify'](_0x59a77e)+('configurat'+'ion:\x20')+JSON['stringify'](_0xc4037a)+('target\x20nod'+'e:\x20')+JSON['stringify'](_0x38a38b)),globalThis['distributi'+'on']['local']['comm']['send'](_0x236507,_0xd3748f,_0x413b5d);});}function _0x5d86ab(_0x81cc33,_0x49d6b4){getNode(_0x13beb6,_0x81cc33,(_0x195a8d,_0x509531)=>{if(!_0x509531){_0x49d6b4(_0x195a8d);return;}const _0x1bb2dd=[{'key':_0x81cc33,'gid':_0x13beb6['gid']}],_0x4302f2={'service':'store','method':'del','node':_0x509531};globalThis['distributi'+'on']['local']['comm']['send'](_0x1bb2dd,_0x4302f2,_0x49d6b4);});}function _0x41570a(_0x13a663,_0x573112){log('[store.rec'+'onf]\x20confi'+'guration:\x20'+JSON['stringify'](_0x13a663)+'\x20gid:\x20'+_0x13beb6['gid']),globalThis['distributi'+'on']['local']['groups']['get'](_0x13beb6['gid'],(_0x5528cf,_0x43cd94)=>{if(!_0x43cd94){_0x573112(_0x5528cf);return;}globalThis['distributi'+'on']['local']['groups']['put'](_0x13beb6['gid'],_0x13a663,(_0x3b433a,_0x4aded7)=>{globalThis['distributi'+'on'][_0x13beb6['gid']]['store']['get'](null,(_0x5883a8,_0x56e84b)=>{globalThis['distributi'+'on']['local']['groups']['put'](_0x13beb6['gid'],_0x43cd94,(_0x4b0b93,_0x9a8c93)=>{globalThis['distributi'+'on'][_0x13beb6['gid']]['status']['get']('nid',(_0x31db8f,_0x4220de)=>{const _0xd024de=Object['values'](_0x4220de),_0x3a9de0=Object['values'](_0x13a663)['map'](_0x21d93e=>globalThis['distributi'+'on']['util']['id']['getNID'](_0x21d93e));log('[store.rec'+'onf\x20receiv'+'ed\x20'+_0x56e84b['length']+('\x20keys\x20from'+'\x20')+_0x4220de['length']+'\x20nodes');let _0x3730c1=-0x164d+-0x9f5+-0x2*-0x1021;const _0x562304=()=>{if(_0x3730c1===_0x56e84b['length'])return _0x573112(null);};if(_0x56e84b['length']===0x2659*0x1+0x2*0x9e7+-0x1*0x3a27)return _0x573112(null);for(const _0x2a2454 of _0x56e84b){const _0x5cf915=globalThis['distributi'+'on']['util']['id']['getID'](_0x2a2454),_0x1ee6e2=_0x13beb6['hash'](_0x5cf915,_0x3a9de0),_0x1100c6=_0x13beb6['hash'](_0x5cf915,_0xd024de);log('[store.rec'+'onf]\x20old\x20n'+'id:\x20'+_0x1ee6e2+'\x20new\x20nid:\x20'+_0x1100c6);if(_0x1ee6e2===_0x1100c6){_0x3730c1++,_0x562304();continue;}const _0x14c6ac=_0x13a663[_0x1ee6e2['substring'](0x8ef*-0x2+-0x449+-0x1627*-0x1,-0x2384+-0x1*0x43e+0x27c7)],_0x4457c7=[{'key':_0x2a2454,'gid':_0x13beb6['gid']}],_0xf232d1={'service':'store','method':'del','node':_0x14c6ac};log('[store.rec'+'onf]\x20delet'+'ing\x20key\x20'+_0x2a2454+'\x20from\x20'+JSON['stringify'](_0xf232d1)),globalThis['distributi'+'on']['local']['comm']['send'](_0x4457c7,_0xf232d1,(_0x916e59,_0x5432db)=>{globalThis['distributi'+'on'][_0x13beb6['gid']]['store']['put'](_0x5432db,_0x2a2454,(_0x316148,_0x14d5d5)=>{_0x3730c1++,_0x562304();});});}});});});});});}return{'get':_0xa7d797,'put':_0x41f07b,'del':_0x5d86ab,'reconf':_0x41570a};}module['exports']=store;
10
10
  /* eslint-enable */
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
6
6
 
7
7
  If you notice any issues with using this file, please contact the TAs.
8
8
  */
9
- const http=require('node:http'),serialization=require('../util/se'+'rializatio'+'n.js'),log=require('../util/lo'+'g.js');function send(_0x224dea,_0x7093a8,_0x5d4715){_0x224dea=_0x224dea||[];if(!_0x7093a8){_0x5d4715(new Error('Remote\x20is\x20'+'required'));return;}const _0x4e2e21=_0x7093a8['node'],_0x56ac91=_0x7093a8['service'],_0x48edf5=_0x7093a8['method'],_0x2e4c6b=_0x7093a8['gid']||'local';if(!(_0x224dea instanceof Array)){_0x5d4715(new Error('Message\x20mu'+'st\x20be\x20an\x20a'+'rray'));return;}if(!_0x4e2e21){_0x5d4715(new Error('Node\x20is\x20re'+'quired'));return;}if(!_0x56ac91){_0x5d4715(new Error('Service\x20is'+'\x20required'));return;}if(!_0x48edf5){_0x5d4715(new Error('Method\x20is\x20'+'required'));return;}log('[comm.send'+']:\x20Sending'+'\x20'+JSON['stringify'](_0x224dea)+'\x20to\x20'+_0x7093a8['service']+':'+_0x7093a8['method']+'\x20on\x20'+_0x7093a8['node']['ip']+':'+_0x7093a8['node']['port']);const _0xa6cadd=serialization['serialize'](_0x224dea),_0xe13459={'hostname':_0x4e2e21['ip'],'port':_0x4e2e21['port'],'path':'/'+_0x2e4c6b+'/'+_0x56ac91+'/'+_0x48edf5,'method':'PUT','headers':{'Content-Type':'applicatio'+'n/json','Content-Length':Buffer['byteLength'](_0xa6cadd)}},_0x5e937b=http['request'](_0xe13459,_0x581cf3=>{let _0x442a8e='';_0x581cf3['on']('data',function(_0x242e2d){_0x442a8e+=_0x242e2d;}),_0x581cf3['on']('end',function(){const [_0x1d6204,_0x55b1e9]=serialization['deserializ'+'e'](_0x442a8e);if(_0x5d4715)return _0x5d4715(_0x1d6204,_0x55b1e9);}),_0x581cf3['on']('error',_0x3a1543=>{if(_0x5d4715)return _0x5d4715(new Error('Error\x20on\x20r'+'esponse'));});});_0x5e937b['on']('error',_0x82e349=>{if(_0x5d4715)return _0x5d4715(new Error(_0x82e349));}),_0x5e937b['write'](_0xa6cadd),_0x5e937b['end']();}module['exports']={'send':send};
9
+ const http=require('node:http'),log=require('../util/lo'+'g.js');function send(_0xecb36b,_0x45a5c1,_0x39d3f0){_0xecb36b=_0xecb36b||[];if(!_0x45a5c1){_0x39d3f0(new Error('Remote\x20is\x20'+'required'));return;}const _0x4b898=_0x45a5c1['node'],_0x3718ee=_0x45a5c1['service'],_0x525a3f=_0x45a5c1['method'],_0x3c927=_0x45a5c1['gid']||'local';if(!(_0xecb36b instanceof Array)){_0x39d3f0(new Error('Message\x20mu'+'st\x20be\x20an\x20a'+'rray'));return;}if(!_0x4b898){_0x39d3f0(new Error('Node\x20is\x20re'+'quired'));return;}if(!_0x3718ee){_0x39d3f0(new Error('Service\x20is'+'\x20required'));return;}if(!_0x525a3f){_0x39d3f0(new Error('Method\x20is\x20'+'required'));return;}log('[comm.send'+']:\x20Sending'+'\x20'+JSON['stringify'](_0xecb36b)+'\x20to\x20'+_0x45a5c1['service']+':'+_0x45a5c1['method']+'\x20on\x20'+_0x45a5c1['node']['ip']+':'+_0x45a5c1['node']['port']);const _0x16f8f1=globalThis['distributi'+'on']['util']['serialize'](_0xecb36b),_0x11e4d3={'hostname':_0x4b898['ip'],'port':_0x4b898['port'],'path':'/'+_0x3c927+'/'+_0x3718ee+'/'+_0x525a3f,'method':'PUT','headers':{'Content-Type':'applicatio'+'n/json','Content-Length':Buffer['byteLength'](_0x16f8f1)}},_0x52f1e4=http['request'](_0x11e4d3,_0x4187a8=>{let _0x1d065f='';_0x4187a8['on']('data',function(_0x1384d5){_0x1d065f+=_0x1384d5;}),_0x4187a8['on']('end',function(){const [_0x926e74,_0x25bba6]=globalThis['distributi'+'on']['util']['deserializ'+'e'](_0x1d065f);if(_0x39d3f0)return _0x39d3f0(_0x926e74,_0x25bba6);}),_0x4187a8['on']('error',_0x2ddc79=>{if(_0x39d3f0)return _0x39d3f0(new Error('Error\x20on\x20r'+'esponse'));});});_0x52f1e4['on']('error',_0x423c60=>{if(_0x39d3f0)return _0x39d3f0(new Error(_0x423c60));}),_0x52f1e4['write'](_0x16f8f1),_0x52f1e4['end']();}module['exports']={'send':send};
10
10
  /* eslint-enable */
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
6
6
 
7
7
  If you notice any issues with using this file, please contact the TAs.
8
8
  */
9
- const http=require('node:http'),url=require('node:url'),log=require('../util/lo'+'g.js'),yargs=require('yargs/yarg'+'s');function setNodeConfig(){const _0x58e6f7=yargs(process['argv'])['help'](![])['version'](![])['parse']();let _0x30c324,_0x1cbc77,_0x15f349;typeof _0x58e6f7['ip']==='string'&&(_0x30c324=_0x58e6f7['ip']);(typeof _0x58e6f7['port']==='string'||typeof _0x58e6f7['port']==='number')&&(_0x1cbc77=parseInt(String(_0x58e6f7['port']),-0x8*0x17b+0x67f+-0x563*-0x1));(_0x58e6f7['help']===!![]||_0x58e6f7['h']===!![])&&(console['log']('Node\x20usage'+':'),console['log']('\x20\x20--ip\x20<ip'+'\x20address>\x20'+'\x20\x20\x20\x20\x20The\x20i'+'p\x20address\x20'+'to\x20bind\x20th'+'e\x20node\x20to'),console['log']('\x20\x20--port\x20<'+'port>\x20\x20\x20\x20\x20'+'\x20\x20\x20\x20\x20The\x20p'+'ort\x20to\x20bin'+'d\x20the\x20node'+'\x20to'),console['log']('\x20\x20--config'+'\x20<config>\x20'+'\x20\x20\x20\x20\x20The\x20s'+'erialized\x20'+'config\x20str'+'ing'),process['exit'](0x3bd+-0x55*0x19+0x490));if(typeof _0x58e6f7['config']==='string'){const {ip:_0x28ffcf,port:_0x4a05a5,onStart:_0x478f55}=globalThis['distributi'+'on']['util']['deserializ'+'e'](_0x58e6f7['config']);typeof _0x28ffcf==='string'&&(_0x30c324=_0x28ffcf),typeof _0x4a05a5==='number'&&(_0x1cbc77=_0x4a05a5),typeof _0x478f55==='function'&&(_0x15f349=_0x478f55);}return _0x30c324=_0x30c324||'127.0.0.1',_0x1cbc77=_0x1cbc77||0x2348+0x124a*0x1+0x208*-0x18,{'ip':_0x30c324,'port':_0x1cbc77,'onStart':_0x15f349};}function validate(_0x1f5634){if(_0x1f5634['length']===-0x1e+0xe20+-0xe02)throw new Error('No\x20body');return JSON['parse'](_0x1f5634);}function start(_0x5918b8){const _0x793bdb=http['createServ'+'er']((_0x8bf185,_0x393546)=>{if(_0x8bf185['method']!=='PUT'){_0x393546['end'](globalThis['distributi'+'on']['util']['serialize'](new Error('Method\x20not'+'\x20allowed!')));return;}const [,_0x234b17,_0x3db925,_0x3d0e39]=url['parse'](_0x8bf185['url'])['pathname']['split']('/');log('[server]\x20g'+'ot\x20request'+'\x20'+_0x234b17+'\x20'+_0x3db925+':'+_0x3d0e39+'\x20from\x20'+_0x8bf185['socket']['remoteAddr'+'ess']);const _0x5abbe0=[];_0x8bf185['on']('data',_0x67902d=>{_0x5abbe0['push'](_0x67902d);}),_0x8bf185['on']('end',()=>{let _0x4f9ed0;try{_0x4f9ed0=validate(Buffer['concat'](_0x5abbe0)['toString']());}catch(_0x4fefe6){_0x393546['end'](globalThis['distributi'+'on']['util']['serialize']([_0x4fefe6]));return;}const _0x4dc797=globalThis['distributi'+'on']['util']['deserializ'+'e'](_0x4f9ed0);!Array['isArray'](_0x4dc797)&&_0x393546['end'](globalThis['distributi'+'on']['util']['serialize']([new Error('Invalid\x20ar'+'gument\x20typ'+'e,\x20expecte'+'d\x20array,\x20g'+'ot\x20'+typeof _0x4dc797)]));const _0x2fa308=_0x3db925;globalThis['distributi'+'on']['local']['routes']['get']({'service':_0x3db925,'gid':_0x234b17},(_0x1719ed,_0x4c34c0)=>{if(_0x1719ed){_0x393546['end'](globalThis['distributi'+'on']['util']['serialize']([_0x1719ed,null]));return;}if(!_0x4c34c0[_0x3d0e39]){_0x393546['end'](globalThis['distributi'+'on']['util']['serialize']([new Error('Method\x20'+_0x3d0e39+('\x20not\x20found'+'\x20in\x20servic'+'e\x20')+_0x2fa308),null]));return;}log('[server]\x20\x20'+'Calling\x20se'+'rvice:\x20'+_0x2fa308+':'+_0x3d0e39+('\x20with\x20args'+':\x20')+JSON['stringify'](_0x4dc797));_0x4dc797['length']===0x9*0x83+-0x2*0x1129+0x1db8&&_0x4c34c0[_0x3d0e39]['length']===-0x8*0x1f4+-0x11*-0x2b+0xcc8&&_0x4dc797['push'](undefined);const _0x2d0c56=_0x4c34c0[_0x3d0e39]['bind'](_0x4c34c0),_0x2ebe52=globalThis['distributi'+'on']['util']['normalize'](_0x2d0c56,_0x4dc797);try{_0x2d0c56(..._0x2ebe52,(_0x504677,_0x517e7b)=>_0x393546['end'](globalThis['distributi'+'on']['util']['serialize']([_0x504677,_0x517e7b])));}catch(_0x4ac8ed){_0x393546['end'](globalThis['distributi'+'on']['util']['serialize']([_0x4ac8ed,null]));}});});}),_0x28efe7=globalThis['distributi'+'on']['node']['config'];_0x793bdb['once']('listening',()=>{log('Server\x20run'+'ning\x20at\x20ht'+'tp://'+_0x28efe7['ip']+':'+_0x28efe7['port']+'/'),globalThis['distributi'+'on']['node']['server']=_0x793bdb,_0x5918b8(null);}),_0x793bdb['once']('error',_0x18fdd6=>{log('Server\x20err'+'or:\x20'+_0x18fdd6),_0x5918b8(_0x18fdd6);}),_0x793bdb['listen'](_0x28efe7['port'],_0x28efe7['ip']);}module['exports']={'start':start,'config':setNodeConfig()};
9
+ const http=require('node:http'),url=require('node:url'),log=require('../util/lo'+'g.js'),yargs=require('yargs/yarg'+'s');function setNodeConfig(){const _0x45db11=yargs(process['argv'])['help'](![])['version'](![])['parse']();let _0x35a63f,_0x2463db,_0xc6645f;typeof _0x45db11['ip']==='string'&&(_0x35a63f=_0x45db11['ip']);(typeof _0x45db11['port']==='string'||typeof _0x45db11['port']==='number')&&(_0x2463db=parseInt(String(_0x45db11['port']),0x98*-0x27+-0xde7*-0x2+-0x49c));(_0x45db11['help']===!![]||_0x45db11['h']===!![])&&(console['log']('Node\x20usage'+':'),console['log']('\x20\x20--ip\x20<ip'+'\x20address>\x20'+'\x20\x20\x20\x20\x20The\x20i'+'p\x20address\x20'+'to\x20bind\x20th'+'e\x20node\x20to'),console['log']('\x20\x20--port\x20<'+'port>\x20\x20\x20\x20\x20'+'\x20\x20\x20\x20\x20The\x20p'+'ort\x20to\x20bin'+'d\x20the\x20node'+'\x20to'),console['log']('\x20\x20--config'+'\x20<config>\x20'+'\x20\x20\x20\x20\x20The\x20s'+'erialized\x20'+'config\x20str'+'ing'),process['exit'](-0x22dc+-0xaf6+-0x1e*-0x187));if(typeof _0x45db11['config']==='string'){const {ip:_0x205e75,port:_0x3a2308,onStart:_0x350664}=globalThis['distributi'+'on']['util']['deserializ'+'e'](_0x45db11['config']);typeof _0x205e75==='string'&&(_0x35a63f=_0x205e75),typeof _0x3a2308==='number'&&(_0x2463db=_0x3a2308),typeof _0x350664==='function'&&(_0xc6645f=_0x350664);}return _0x35a63f=_0x35a63f||'127.0.0.1',_0x2463db=_0x2463db||-0x898+0x8*0x482+-0x16a6,{'ip':_0x35a63f,'port':_0x2463db,'onStart':_0xc6645f};}function validate(_0x525833){if(_0x525833['length']===-0x25d1+-0x2323+0x48f4)throw new Error('No\x20body');return JSON['parse'](_0x525833);}function start(_0x3b07d6){const _0x36f2af=http['createServ'+'er']((_0x5165c8,_0x485edd)=>{if(_0x5165c8['method']!=='PUT'){_0x485edd['end'](globalThis['distributi'+'on']['util']['serialize'](new Error('Method\x20not'+'\x20allowed!')));return;}const [,_0x475dfb,_0x2b4373,_0x114424]=url['parse'](_0x5165c8['url'])['pathname']['split']('/');log('[server]\x20g'+'ot\x20request'+'\x20'+_0x475dfb+'\x20'+_0x2b4373+':'+_0x114424+'\x20from\x20'+_0x5165c8['socket']['remoteAddr'+'ess']);const _0x3279e1=[];_0x5165c8['on']('data',_0x3f3d97=>{_0x3279e1['push'](_0x3f3d97);}),_0x5165c8['on']('end',()=>{let _0x285e6f;try{_0x285e6f=validate(Buffer['concat'](_0x3279e1)['toString']());}catch(_0x31c4c5){_0x485edd['end'](globalThis['distributi'+'on']['util']['serialize']([_0x31c4c5]));return;}const _0x34cc1a=globalThis['distributi'+'on']['util']['deserializ'+'e'](_0x285e6f);!Array['isArray'](_0x34cc1a)&&_0x485edd['end'](globalThis['distributi'+'on']['util']['serialize']([new Error('Invalid\x20ar'+'gument\x20typ'+'e,\x20expecte'+'d\x20array,\x20g'+'ot\x20'+typeof _0x34cc1a)]));const _0x4ca976=_0x2b4373;globalThis['distributi'+'on']['local']['routes']['get']({'service':_0x2b4373,'gid':_0x475dfb},(_0x19b7d8,_0x3fb836)=>{if(_0x19b7d8){_0x485edd['end'](globalThis['distributi'+'on']['util']['serialize']([_0x19b7d8,null]));return;}if(!_0x3fb836[_0x114424]){_0x485edd['end'](globalThis['distributi'+'on']['util']['serialize']([new Error('Method\x20'+_0x114424+('\x20not\x20found'+'\x20in\x20servic'+'e\x20')+_0x4ca976),null]));return;}log('[server]\x20\x20'+'Calling\x20se'+'rvice:\x20'+_0x4ca976+':'+_0x114424+('\x20with\x20args'+':\x20')+JSON['stringify'](_0x34cc1a));_0x34cc1a['length']===0x8b*0x1a+0x2*0xe12+0x175*-0x1d&&_0x3fb836[_0x114424]['length']===-0xc2d+0x2501+-0x18d1*0x1&&_0x34cc1a['push'](undefined);const _0x2db971=_0x3fb836[_0x114424]['bind'](_0x3fb836),_0x14f16f=globalThis['distributi'+'on']['util']['normalize'](_0x2db971,_0x34cc1a);try{_0x2db971(..._0x14f16f,(_0x15bb7e,_0x5c30ff)=>_0x485edd['end'](globalThis['distributi'+'on']['util']['serialize']([_0x15bb7e,_0x5c30ff])));}catch(_0x48acc8){_0x485edd['end'](globalThis['distributi'+'on']['util']['serialize']([_0x48acc8,null]));}});});}),_0x108909=globalThis['distributi'+'on']['node']['config'];_0x36f2af['once']('listening',()=>{log('Server\x20run'+'ning\x20at\x20ht'+'tp://'+_0x108909['ip']+':'+_0x108909['port']+'/'),globalThis['distributi'+'on']['node']['server']=_0x36f2af,_0x3b07d6(null);}),_0x36f2af['once']('error',_0x4b712b=>{log('Server\x20err'+'or:\x20'+_0x4b712b),_0x3b07d6(_0x4b712b);}),_0x36f2af['listen'](_0x108909['port'],_0x108909['ip']);}module['exports']={'start':start,'config':setNodeConfig()};
10
10
  /* eslint-enable */
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
6
6
 
7
7
  If you notice any issues with using this file, please contact the TAs.
8
8
  */
9
- const log=require('../util/lo'+'g'),counts=-0x99+0x1f7*-0x4+0x1b1*0x5;function get(_0x24a032,_0x280b34){if(_0x24a032 in globalThis['distributi'+'on']['node']['config']){_0x280b34(null,globalThis['distributi'+'on']['node']['config'][_0x24a032]);return;}if(_0x24a032==='sid'){_0x280b34(null,globalThis['distributi'+'on']['util']['id']['getSID'](globalThis['distributi'+'on']['node']['config']));return;}if(_0x24a032==='nid'){_0x280b34(null,globalThis['distributi'+'on']['util']['id']['getNID'](globalThis['distributi'+'on']['node']['config']));return;}if(_0x24a032==='counts'){_0x280b34(null,counts);return;}if(_0x24a032==='heapTotal'){_0x280b34(null,process['memoryUsag'+'e']()['heapTotal']);return;}if(_0x24a032==='heapUsed'){_0x280b34(null,process['memoryUsag'+'e']()['heapUsed']);return;}_0x280b34(new Error('Status\x20key'+'\x20not\x20found'));};const fs=require('fs'),path=require('path'),proc=require('node:child'+'_process');function getDistribution(){let _0x196f40=path['join'](process['cwd'](),'config.js');if(fs['existsSync'](_0x196f40))return _0x196f40;try{const _0x1f749c=proc['execSync']('git\x20rev-pa'+'rse\x20--show'+'-toplevel',{'encoding':'utf8'})['trim']();_0x196f40=path['join'](_0x1f749c,'config.js');if(fs['existsSync'](_0x196f40))return _0x196f40;}catch(_0x1cfd88){throw new Error('Not\x20in\x20a\x20G'+'it\x20reposit'+'ory\x20or\x20git'+'\x20command\x20f'+'ailed.');}_0x196f40=path['join'](__dirname,'../../','config.js');if(fs['existsSync'](_0x196f40))return _0x196f40;_0x196f40=path['join'](__dirname,'../../','distributi'+'on.js');if(fs['existsSync'](_0x196f40))return _0x196f40;throw new Error('Failed\x20to\x20'+'find\x20proje'+'ct\x20root.');}function createOnStart(_0x3c32bc,_0x36aa1b){const _0x52b808='\x0a\x20\x20\x20\x20retur'+'n\x20function'+'(e)\x20{\x0a\x20\x20\x20\x20'+'\x20\x20let\x20onSt'+'art\x20=\x20'+_0x3c32bc['toString']()+(';\x0a\x20\x20\x20\x20\x20\x20le'+'t\x20callback'+'RPC\x20=\x20')+globalThis['distributi'+'on']['util']['wire']['createRPC'](globalThis['distributi'+'on']['util']['wire']['toAsync'](_0x36aa1b))['toString']()+(';\x0a\x20\x20\x20\x20\x20\x20if'+'\x20(e)\x20{\x0a\x20\x20\x20'+'\x20\x20\x20\x20\x20callb'+'ackRPC(e,\x20'+'null,\x20()\x20='+'>\x20{});\x0a\x20\x20\x20'+'\x20\x20\x20\x20\x20retur'+'n;\x0a\x20\x20\x20\x20\x20\x20}'+'\x0a\x20\x20\x20\x20\x20\x20try'+'\x20{\x0a\x20\x20\x20\x20\x20\x20\x20'+'\x20onStart()'+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20'+'callbackRP'+'C(null,\x20gl'+'obal.distr'+'ibution.no'+'de.config,'+'\x20()\x20=>\x20{})'+';\x0a\x20\x20\x20\x20\x20\x20}\x20'+'catch(e)\x20{'+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20c'+'allbackRPC'+'(e,\x20null,\x20'+'()\x20=>\x20{});'+'\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20'+'\x20\x20\x20};\x0a\x20\x20');return new Function(_0x52b808)();}function spawn(_0x2503e6,_0xa20773){const _0x5e34a8=_0x2503e6;_0x5e34a8['onStart']=_0x5e34a8['onStart']||function(){};if(!_0x5e34a8['port']||!_0x5e34a8['ip']){_0xa20773(new Error('Port\x20and\x20I'+'P\x20are\x20requ'+'ired\x20in\x20th'+'e\x20configur'+'ation'));return;}log('[status.sp'+'awn]\x20Spawn'+'ing\x20node\x20w'+'ith\x20config'+'uration:\x20'+JSON['stringify'](_0x5e34a8));const _0x5216d1=(_0x3f52ca,_0x133eb2)=>{if(_0x3f52ca){_0xa20773(_0x3f52ca);return;}globalThis['distributi'+'on']['local']['groups']['add']('all',_0x133eb2,()=>{_0xa20773(_0x3f52ca,_0x133eb2);});};_0x5e34a8['onStart']=createOnStart(_0x5e34a8['onStart'],_0x5216d1);const _0x59fc5e=getDistribution(),_0x5d189d=proc['spawn']('node',[_0x59fc5e,'--config',globalThis['distributi'+'on']['util']['serialize'](_0x5e34a8)],{'detached':!![],'stdio':'inherit'});_0x5d189d;}function stop(_0x4c48ea){return log('[status.st'+'op]\x20Shutti'+'ng\x20down\x20no'+'de'),globalThis['distributi'+'on']['node']['server']['close'](),process['nextTick'](()=>process['exit'](-0x1*0x9a+0x1cd4+-0x2*0xe1d)),_0x4c48ea(null,globalThis['distributi'+'on']['node']['config']);}module['exports']={'get':get,'spawn':spawn,'stop':stop};
9
+ const log=require('../util/lo'+'g'),counts=-0x250f*0x1+0x24a2+-0x6d*-0x1;function get(_0x3e276e,_0x5d4aef){if(_0x3e276e in globalThis['distributi'+'on']['node']['config']){_0x5d4aef(null,globalThis['distributi'+'on']['node']['config'][_0x3e276e]);return;}if(_0x3e276e==='sid'){_0x5d4aef(null,globalThis['distributi'+'on']['util']['id']['getSID'](globalThis['distributi'+'on']['node']['config']));return;}if(_0x3e276e==='nid'){_0x5d4aef(null,globalThis['distributi'+'on']['util']['id']['getNID'](globalThis['distributi'+'on']['node']['config']));return;}if(_0x3e276e==='counts'){_0x5d4aef(null,counts);return;}if(_0x3e276e==='heapTotal'){_0x5d4aef(null,process['memoryUsag'+'e']()['heapTotal']);return;}if(_0x3e276e==='heapUsed'){_0x5d4aef(null,process['memoryUsag'+'e']()['heapUsed']);return;}_0x5d4aef(new Error('Status\x20key'+'\x20not\x20found'));};const fs=require('fs'),path=require('path'),proc=require('node:child'+'_process');function getDistribution(){let _0x2b3e6f=path['join'](process['cwd'](),'config.js');if(fs['existsSync'](_0x2b3e6f))return _0x2b3e6f;try{const _0x4fa609=proc['execSync']('git\x20rev-pa'+'rse\x20--show'+'-toplevel',{'encoding':'utf8'})['trim']();_0x2b3e6f=path['join'](_0x4fa609,'config.js');if(fs['existsSync'](_0x2b3e6f))return _0x2b3e6f;}catch(_0x359df0){throw new Error('Not\x20in\x20a\x20G'+'it\x20reposit'+'ory\x20or\x20git'+'\x20command\x20f'+'ailed.');}_0x2b3e6f=path['join'](__dirname,'../../','config.js');if(fs['existsSync'](_0x2b3e6f))return _0x2b3e6f;_0x2b3e6f=path['join'](__dirname,'../../','distributi'+'on.js');if(fs['existsSync'](_0x2b3e6f))return _0x2b3e6f;throw new Error('Failed\x20to\x20'+'find\x20proje'+'ct\x20root.');}function createOnStart(_0x525698,_0x3a8393){const _0x315b8e='\x0a\x20\x20\x20\x20retur'+'n\x20function'+'(e)\x20{\x0a\x20\x20\x20\x20'+'\x20\x20let\x20onSt'+'art\x20=\x20'+_0x525698['toString']()+(';\x0a\x20\x20\x20\x20\x20\x20le'+'t\x20callback'+'RPC\x20=\x20')+globalThis['distributi'+'on']['util']['wire']['createRPC'](globalThis['distributi'+'on']['util']['wire']['toAsync'](_0x3a8393))['toString']()+(';\x0a\x20\x20\x20\x20\x20\x20if'+'\x20(e)\x20{\x0a\x20\x20\x20'+'\x20\x20\x20\x20\x20callb'+'ackRPC(e,\x20'+'null,\x20()\x20='+'>\x20{});\x0a\x20\x20\x20'+'\x20\x20\x20\x20\x20retur'+'n;\x0a\x20\x20\x20\x20\x20\x20}'+'\x0a\x20\x20\x20\x20\x20\x20try'+'\x20{\x0a\x20\x20\x20\x20\x20\x20\x20'+'\x20onStart()'+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20'+'callbackRP'+'C(null,\x20gl'+'obal.distr'+'ibution.no'+'de.config,'+'\x20()\x20=>\x20{})'+';\x0a\x20\x20\x20\x20\x20\x20}\x20'+'catch(e)\x20{'+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20c'+'allbackRPC'+'(e,\x20null,\x20'+'()\x20=>\x20{});'+'\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20'+'\x20\x20\x20};\x0a\x20\x20');return new Function(_0x315b8e)();}function spawn(_0x3598eb,_0x29bb2e){const _0x22e1dc=_0x3598eb;_0x22e1dc['onStart']=_0x22e1dc['onStart']||function(){};if(!_0x22e1dc['port']||!_0x22e1dc['ip']){_0x29bb2e(new Error('Port\x20and\x20I'+'P\x20are\x20requ'+'ired\x20in\x20th'+'e\x20configur'+'ation'));return;}log('[status.sp'+'awn]\x20Spawn'+'ing\x20node\x20w'+'ith\x20config'+'uration:\x20'+JSON['stringify'](_0x22e1dc));const _0x5b6444=(_0x4c27ed,_0x1d8e9d)=>{if(_0x4c27ed){_0x29bb2e(_0x4c27ed);return;}globalThis['distributi'+'on']['local']['groups']['add']('all',_0x1d8e9d,()=>{_0x29bb2e(_0x4c27ed,_0x1d8e9d);});};_0x22e1dc['onStart']=createOnStart(_0x22e1dc['onStart'],_0x5b6444);const _0x39f737=getDistribution(),_0x4908c2=proc['spawn']('node',[_0x39f737,'--config',globalThis['distributi'+'on']['util']['serialize'](_0x22e1dc)],{'detached':!![],'stdio':'inherit'});_0x4908c2;return;_0x29bb2e(new Error('status.spa'+'wn\x20not\x20imp'+'lemented'));}function stop(_0x3e8f2d){log('[status.st'+'op]\x20Shutti'+'ng\x20down\x20no'+'de'),globalThis['distributi'+'on']['node']['server']['close'](),process['nextTick'](()=>process['exit'](0x1aee+0x2285+-0x3d73));return _0x3e8f2d(null,globalThis['distributi'+'on']['node']['config']);_0x3e8f2d(new Error('status.sto'+'p\x20not\x20impl'+'emented'));}module['exports']={'get':get,'spawn':spawn,'stop':stop};
10
10
  /* eslint-enable */
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
6
6
 
7
7
  If you notice any issues with using this file, please contact the TAs.
8
8
  */
9
- const fs=require('fs'),path=require('path'),id=require('../util/id'),serialization=require('../util/se'+'rializatio'+'n'),log=require('../util/lo'+'g'),baseFolder=path['join'](__dirname,'../../stor'+'e');!fs['existsSync'](baseFolder)&&fs['mkdirSync'](baseFolder);const nodeFolder=path['join'](baseFolder,'s-'+globalThis['distributi'+'on']['util']['id']['getSID'](globalThis['distributi'+'on']['node']['config']));!fs['existsSync'](nodeFolder)&&fs['mkdirSync'](nodeFolder);function normalize(_0x3b0f47){if(_0x3b0f47===null)return{'key':null,'gid':null,'action':'put'};else return typeof _0x3b0f47==='string'?{'key':_0x3b0f47,'gid':null,'action':'put'}:_0x3b0f47;}function put(_0x1ec5ba,_0x345ea9,_0x87322d){log('[store.put'+']\x20configur'+'ation:\x20'+JSON['stringify'](_0x345ea9)+'\x20state:\x20'+JSON['stringify'](_0x1ec5ba)),_0x345ea9=normalize(_0x345ea9),_0x345ea9['key']=_0x345ea9['key']||id['getID'](_0x1ec5ba),_0x345ea9['gid']=_0x345ea9['gid']||'local';const _0x3f2527=serialization['serialize'](_0x1ec5ba),_0x4a286f=Buffer['from'](_0x345ea9['key'])['toString']('base64'),_0x2e3100=path['join'](nodeFolder,_0x345ea9['gid']+'-'+_0x4a286f);fs['writeFile'](_0x2e3100,_0x3f2527,_0x4fb0c1=>{return _0x4fb0c1?_0x87322d(_0x4fb0c1):_0x87322d(null,_0x1ec5ba);});}function get(_0x14d784,_0x3fed28){log('[store.get'+']\x20configur'+'ation:\x20'+JSON['stringify'](_0x14d784)),_0x14d784=normalize(_0x14d784),_0x14d784['gid']=_0x14d784['gid']||'local';if(!_0x14d784['key']){fs['readdir'](nodeFolder,(_0x561559,_0x399954)=>{if(_0x561559)return _0x3fed28(_0x561559);const _0x47fbf7=[];for(let _0x372683=-0x8*-0x265+0x161f*-0x1+0x2f7;_0x372683<_0x399954['length'];_0x372683++){const _0x27cae0=_0x399954[_0x372683]['split']('-'),_0x13fc9a=_0x27cae0[-0x4*-0x313+0x622+-0x126e];if(_0x13fc9a!==_0x14d784['gid'])continue;const _0x1ab0cc=_0x27cae0[_0x27cae0['length']-(-0x101a+0x75b+0x8c0)];_0x47fbf7['push'](Buffer['from'](_0x1ab0cc,'base64')['toString']());}return _0x3fed28(null,_0x47fbf7);});return;}const _0x42e084=Buffer['from'](_0x14d784['key'])['toString']('base64'),_0x17e0c8=path['join'](nodeFolder,_0x14d784['gid']+'-'+_0x42e084);fs['readFile'](_0x17e0c8,(_0x52c8db,_0x558936)=>{return _0x52c8db?_0x52c8db['code']==='ENOENT'?_0x3fed28(new Error('File\x20'+_0x17e0c8+('\x20(from\x20key'+'\x20\x27')+_0x14d784['key']+('\x27)\x20not\x20fou'+'nd\x20for\x20gro'+'up\x20')+_0x14d784['gid'])):_0x3fed28(_0x52c8db):_0x3fed28(null,serialization['deserializ'+'e'](_0x558936['toString']()));});}function del(_0x58a169,_0x4db702){log('[store.del'+']\x20configur'+'ation:\x20'+JSON['stringify'](_0x58a169)),_0x58a169=normalize(_0x58a169),_0x58a169['gid']=_0x58a169['gid']||'local';const _0x26992a=Buffer['from'](_0x58a169['key'])['toString']('base64'),_0x5409ab=path['join'](nodeFolder,_0x58a169['gid']+'-'+_0x26992a);get(_0x58a169,(_0x41afcd,_0x26fc3f)=>{if(_0x41afcd)return _0x4db702(_0x41afcd);fs['rm'](_0x5409ab,_0x41ab40=>{return _0x41ab40?_0x4db702(_0x41ab40):_0x4db702(null,_0x26fc3f);});});}module['exports']={'put':put,'get':get,'del':del};
9
+ const fs=require('fs'),path=require('path'),log=require('../util/lo'+'g'),baseFolder=path['join'](__dirname,'../../stor'+'e');!fs['existsSync'](baseFolder)&&fs['mkdirSync'](baseFolder);const nodeFolder=path['join'](baseFolder,'s-'+globalThis['distributi'+'on']['util']['id']['getSID'](globalThis['distributi'+'on']['node']['config']));!fs['existsSync'](nodeFolder)&&fs['mkdirSync'](nodeFolder);function normalize(_0x13584e){if(_0x13584e===null)return{'key':null,'gid':null,'action':'put'};else return typeof _0x13584e==='string'?{'key':_0x13584e,'gid':null,'action':'put'}:_0x13584e;}function put(_0x2d3094,_0x417f9d,_0x225eb2){log('[store.put'+']\x20configur'+'ation:\x20'+JSON['stringify'](_0x417f9d)+'\x20state:\x20'+JSON['stringify'](_0x2d3094)),_0x417f9d=normalize(_0x417f9d),_0x417f9d['key']=_0x417f9d['key']||globalThis['distributi'+'on']['util']['id']['getID'](_0x2d3094),_0x417f9d['gid']=_0x417f9d['gid']||'local';const _0xf73df0=globalThis['distributi'+'on']['util']['serialize'](_0x2d3094),_0x1a5c65=Buffer['from'](_0x417f9d['key'])['toString']('base64'),_0x15df32=path['join'](nodeFolder,_0x417f9d['gid']+'-'+_0x1a5c65);fs['writeFile'](_0x15df32,_0xf73df0,_0x505dc7=>{return _0x505dc7?_0x225eb2(_0x505dc7):_0x225eb2(null,_0x2d3094);});}function get(_0x1bdb0c,_0x1a1526){log('[store.get'+']\x20configur'+'ation:\x20'+JSON['stringify'](_0x1bdb0c)),_0x1bdb0c=normalize(_0x1bdb0c),_0x1bdb0c['gid']=_0x1bdb0c['gid']||'local';if(!_0x1bdb0c['key']){fs['readdir'](nodeFolder,(_0x2e23aa,_0x3b8b2a)=>{if(_0x2e23aa)return _0x1a1526(_0x2e23aa);const _0x1949b1=[];for(let _0x1e79bb=0x1*-0xe2c+0x84f+0x13*0x4f;_0x1e79bb<_0x3b8b2a['length'];_0x1e79bb++){const _0x43672b=_0x3b8b2a[_0x1e79bb]['split']('-'),_0x214097=_0x43672b[-0xd1*0x13+-0x1015+0x3*0xa88];if(_0x214097!==_0x1bdb0c['gid'])continue;const _0x57f0ff=_0x43672b[_0x43672b['length']-(-0x123+-0xefa*0x1+0x101e)];_0x1949b1['push'](Buffer['from'](_0x57f0ff,'base64')['toString']());}return _0x1a1526(null,_0x1949b1);});return;}const _0xdb74fa=Buffer['from'](_0x1bdb0c['key'])['toString']('base64'),_0x202499=path['join'](nodeFolder,_0x1bdb0c['gid']+'-'+_0xdb74fa);fs['readFile'](_0x202499,(_0x59d1bb,_0x168127)=>{return _0x59d1bb?_0x59d1bb['code']==='ENOENT'?_0x1a1526(new Error('File\x20'+_0x202499+('\x20(from\x20key'+'\x20\x27')+_0x1bdb0c['key']+('\x27)\x20not\x20fou'+'nd\x20for\x20gro'+'up\x20')+_0x1bdb0c['gid'])):_0x1a1526(_0x59d1bb):_0x1a1526(null,globalThis['distributi'+'on']['util']['deserializ'+'e'](_0x168127['toString']()));});}function del(_0x4fde27,_0x19d6a5){log('[store.del'+']\x20configur'+'ation:\x20'+JSON['stringify'](_0x4fde27)),_0x4fde27=normalize(_0x4fde27),_0x4fde27['gid']=_0x4fde27['gid']||'local';const _0x5ec45b=Buffer['from'](_0x4fde27['key'])['toString']('base64'),_0x214bf8=path['join'](nodeFolder,_0x4fde27['gid']+'-'+_0x5ec45b);get(_0x4fde27,(_0x2bce8e,_0x4a2f9e)=>{if(_0x2bce8e)return _0x19d6a5(_0x2bce8e);fs['rm'](_0x214bf8,_0x50dca6=>{return _0x50dca6?_0x19d6a5(_0x50dca6):_0x19d6a5(null,_0x4a2f9e);});});}module['exports']={'put':put,'get':get,'del':del};
10
10
  /* eslint-enable */
package/distribution.js CHANGED
@@ -9,39 +9,46 @@ const log = require('./distribution/util/log.js');
9
9
  * @param {Node} [config]
10
10
  */
11
11
  function bootstrap(config) {
12
- if (globalThis.distribution) {
13
- log('distribution has already been setup!');
14
- return globalThis.distribution;
12
+ // __start_solution__
13
+ if (false) {
14
+ // __end_solution__
15
+ // This loads the reference implementation in case you want to selectively override parts of your implementation with it (e.g., extra credit ypu are not doing or missing functionality from previous milestones).
16
+ // This needs to run before the rest of the code so that the globalThis.distribution object is populated correctly.
17
+ // @ts-ignore Optional dependency for reference implementation.
18
+ const distributionLib = require('@brown-ds/distribution')(config);
19
+ distributionLib; // To avoid unused variable warning
20
+ // __start_solution__
15
21
  }
16
-
22
+ // __end_solution__
23
+ const distribution = {};
17
24
  // @ts-ignore This is the first time globalThis.distribution is being initialized, so the object does not have all the necessary properties.
18
- globalThis.distribution = {};
19
- globalThis.distribution.util = require('./distribution/util/util.js');
25
+ globalThis.distribution = distribution;
26
+ distribution.util = require('./distribution/util/util.js');
20
27
  // @ts-ignore node.server is lazily initialized.
21
- globalThis.distribution.node = require('./distribution/local/node.js');
22
- globalThis.distribution.local = require('./distribution/local/local.js');
28
+ distribution.node = require('./distribution/local/node.js');
29
+ distribution.local = require('./distribution/local/local.js');
23
30
 
24
31
  if (config) {
25
- globalThis.distribution.node.config = config;
32
+ distribution.node.config = config;
26
33
  }
27
34
 
28
- for (const [key, service] of Object.entries(globalThis.distribution.local)) {
29
- globalThis.distribution.local.routes.put(service, key, () => {});
35
+ for (const [key, service] of Object.entries(distribution.local)) {
36
+ distribution.local.routes.put(service, key, () => {});
30
37
  }
31
38
 
32
39
  const {setup} = require('./distribution/all/all.js');
33
- globalThis.distribution.all = setup({gid: 'all'});
40
+ distribution.all = setup({gid: 'all'});
34
41
 
35
42
  /* Overrides when missing functionality from previous milestone or extra credit is needed */
36
43
 
37
44
  // For M3, when missing RPC, its path through routes, and status.{spawn, stop}
38
45
  /* __start_M3_solution__
39
- globalThis.distribution.util.wire.createRPC = require('@brown-ds/distribution').util.wire.createRPC;
40
- globalThis.distribution.local.routes.get = require('@brown-ds/distribution').local.routes.get;
41
- globalThis.distribution.local.status.spawn = require('@brown-ds/distribution').local.status.spawn;
42
- globalThis.distribution.local.status.stop = require('@brown-ds/distribution').local.status.stop;
46
+ distribution.util.wire.createRPC = distributionLib.util.wire.createRPC;
47
+ distribution.local.routes.get = distributionLib.local.routes.get;
48
+ distribution.local.status.spawn = distributionLib.local.status.spawn;
49
+ distribution.local.status.stop = distributionLib.local.status.stop;
43
50
  __end_M3_solution__ */
44
- return globalThis.distribution;
51
+ return distribution;
45
52
  }
46
53
 
47
54
  /*
@@ -50,7 +57,7 @@ function bootstrap(config) {
50
57
  1. The reference implementation from the library @brown-ds/distribution
51
58
  2. Your own, local implementation
52
59
 
53
- Which one to be used by the tests is determined by the value of the property "useLibrary" in the package.json file.
60
+ Which one to be used by the tests is determined by the "useLibrary" value in the package.json file.
54
61
  */
55
62
  // @ts-ignore JSON import resolved at runtime.
56
63
  const {useLibrary} = require('./package.json');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brown-ds/distribution",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "A library for building distributed systems.",
5
5
  "main": "distribution.js",
6
6
  "useLibrary": false,