@leofcoin/chain 1.4.53 → 1.4.55
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/exports/browser/chain.js +1 -25
- package/exports/browser/{client-0ebd5821-7a2c6603.js → client-d1c29e20-c5d45b87.js} +24 -14
- package/exports/browser/{index-ff3a61f6-e0290b5d.js → index-904b9f85-2d6175c2.js} +1 -1
- package/exports/browser/{messages-8b773ecf-97158d69.js → messages-de2c5670-d99ad896.js} +1 -1
- package/exports/browser/{node-browser-582c5fb0.js → node-browser-3d505e1f.js} +189 -189
- package/exports/browser/node-browser.js +1 -1
- package/exports/chain.js +1 -25
- package/package.json +1 -1
package/exports/browser/chain.js
CHANGED
|
@@ -8236,32 +8236,8 @@ class Chain extends Contract {
|
|
|
8236
8236
|
if (!peer.version || peer.version !== this.version)
|
|
8237
8237
|
return;
|
|
8238
8238
|
const lastBlock = await this.#makeRequest(peer, 'lastBlock');
|
|
8239
|
-
if (lastBlock.index > this.#lastBlock?.index) {
|
|
8239
|
+
if (lastBlock && lastBlock.index > this.#lastBlock?.index) {
|
|
8240
8240
|
// this.#knownBlocks = await this.#makeRequest(peer, 'knownBlocks')
|
|
8241
|
-
try {
|
|
8242
|
-
console.log('getting pool');
|
|
8243
|
-
let pool = await this.#makeRequest(peer, 'transactionPool');
|
|
8244
|
-
console.log('got pool');
|
|
8245
|
-
pool = await Promise.all(pool.map(async (hash) => {
|
|
8246
|
-
const has = await globalThis.peernet.has(hash);
|
|
8247
|
-
return { has, hash };
|
|
8248
|
-
}));
|
|
8249
|
-
pool = pool.filter(item => !item.has);
|
|
8250
|
-
await Promise.all(pool.map(async ({ hash }) => {
|
|
8251
|
-
const result = await globalThis.peernet.get(hash);
|
|
8252
|
-
// result could be undefined cause invalid/double transactions could be deleted already
|
|
8253
|
-
if (!result)
|
|
8254
|
-
console.log(result);
|
|
8255
|
-
if (result) {
|
|
8256
|
-
const node = await new TransactionMessage(result);
|
|
8257
|
-
await globalThis.transactionPoolStore.put(await node.hash(), node.encoded);
|
|
8258
|
-
}
|
|
8259
|
-
}));
|
|
8260
|
-
}
|
|
8261
|
-
catch (error) {
|
|
8262
|
-
console.log(error);
|
|
8263
|
-
console.log('error fetching transactionPool');
|
|
8264
|
-
}
|
|
8265
8241
|
console.log(lastBlock);
|
|
8266
8242
|
if (lastBlock)
|
|
8267
8243
|
await this.#syncChain(lastBlock);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './node-browser-
|
|
1
|
+
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './node-browser-3d505e1f.js';
|
|
2
2
|
import './index-640d9f36.js';
|
|
3
3
|
|
|
4
4
|
function commonjsRequire(path) {
|
|
@@ -40901,6 +40901,8 @@ var P2PT = /*@__PURE__*/getDefaultExportFromCjs(p2pt_umdExports);
|
|
|
40901
40901
|
|
|
40902
40902
|
class P2PTPeer {
|
|
40903
40903
|
id;
|
|
40904
|
+
remotePeerId;
|
|
40905
|
+
localPeerId;
|
|
40904
40906
|
#peerId;
|
|
40905
40907
|
#channelName
|
|
40906
40908
|
initiator = false
|
|
@@ -40926,8 +40928,10 @@ class P2PTPeer {
|
|
|
40926
40928
|
constructor(peer, p2pt, options = {}) {
|
|
40927
40929
|
this.#connection = peer;
|
|
40928
40930
|
this.p2pt = p2pt;
|
|
40929
|
-
|
|
40930
|
-
this.
|
|
40931
|
+
|
|
40932
|
+
this.id = options.id || peer.id;
|
|
40933
|
+
this.localPeerId = this.p2pt.peerId;
|
|
40934
|
+
|
|
40931
40935
|
this.bw = {
|
|
40932
40936
|
up: 0,
|
|
40933
40937
|
down: 0
|
|
@@ -41036,31 +41040,37 @@ class P2PTClient extends P2PT {
|
|
|
41036
41040
|
this.peerId = peerId;
|
|
41037
41041
|
|
|
41038
41042
|
this.on('trackerconnect', async (tracker, stats) => {
|
|
41039
|
-
|
|
41040
|
-
|
|
41041
|
-
|
|
41042
|
-
|
|
41043
|
-
|
|
41044
|
-
|
|
41045
|
-
|
|
41043
|
+
const peers = await this.requestMorePeers();
|
|
41044
|
+
let promises = Object.entries(peers).map(async ([id, peer]) => {
|
|
41045
|
+
const hasPeer = this.#discovered[id];
|
|
41046
|
+
if (!hasPeer) this.#discovered[id] = await new P2PTPeer(peer, this);
|
|
41047
|
+
if (this.#discovered[id].connected) pubsub.publish('peer:discovered', this.#discovered[id]);
|
|
41048
|
+
});
|
|
41049
|
+
promises = await Promise.allSettled(promises);
|
|
41046
41050
|
pubsub.publish('star:connected', tracker);
|
|
41047
41051
|
});
|
|
41048
41052
|
|
|
41049
41053
|
this.on('peerconnect', async (peer) => {
|
|
41050
41054
|
this.#discovered[peer.id] = await new P2PTPeer(peer, this);
|
|
41051
|
-
pubsub.publish('peer:discovered', this.#discovered[peer.id]);
|
|
41055
|
+
if (this.#discovered[peer.id].connected) pubsub.publish('peer:discovered', this.#discovered[peer.id]);
|
|
41052
41056
|
});
|
|
41053
41057
|
|
|
41054
41058
|
this.on('peerclose', async (peer) => {
|
|
41055
|
-
|
|
41059
|
+
if (this.#discovered[peer.id]) {
|
|
41060
|
+
pubsub.publish('peer:left', this.#discovered[peer.id]);
|
|
41061
|
+
delete this.#discovered[peer.id];
|
|
41062
|
+
}
|
|
41056
41063
|
});
|
|
41057
41064
|
|
|
41058
41065
|
this.on('msg', async (peer, data, id, from) => {
|
|
41059
41066
|
const hasPeer = this.#discovered[peer.id];
|
|
41060
41067
|
if (!hasPeer) this.#discovered[peer.id] = await new P2PTPeer(peer, this);
|
|
41061
41068
|
|
|
41062
|
-
this.#discovered[peer.id]
|
|
41063
|
-
|
|
41069
|
+
if (this.#discovered[peer.id].connected) {
|
|
41070
|
+
this.#discovered[peer.id]?._handleMessage(new Uint8Array(Object.values(data)), id, from);
|
|
41071
|
+
this.bw.down += data.length || data.byteLength;
|
|
41072
|
+
}
|
|
41073
|
+
|
|
41064
41074
|
});
|
|
41065
41075
|
|
|
41066
41076
|
this.on('data', async (peer, data) => {
|
|
@@ -5500,188 +5500,195 @@ new Mutex();
|
|
|
5500
5500
|
|
|
5501
5501
|
new Mutex();
|
|
5502
5502
|
|
|
5503
|
-
const blockchainCodecs = [
|
|
5504
|
-
{
|
|
5505
|
-
name: 'leofcoin-block',
|
|
5506
|
-
codec: '0x6c62',
|
|
5507
|
-
hashAlg: 'dbl-keccak-512',
|
|
5508
|
-
},
|
|
5509
|
-
{
|
|
5510
|
-
name: 'leofcoin-tx',
|
|
5511
|
-
codec: '0x6c74',
|
|
5512
|
-
hashAlg: 'dbl-keccak-512',
|
|
5513
|
-
},
|
|
5514
|
-
{
|
|
5515
|
-
name: 'leofcoin-itx',
|
|
5516
|
-
codec: '0x6c69',
|
|
5517
|
-
hashAlg: 'keccak-512',
|
|
5518
|
-
},
|
|
5519
|
-
{
|
|
5520
|
-
name: 'leofcoin-pr',
|
|
5521
|
-
codec: '0x6c70',
|
|
5522
|
-
hashAlg: 'keccak-256',
|
|
5523
|
-
},
|
|
5524
|
-
{
|
|
5525
|
-
name: 'contract-message',
|
|
5526
|
-
codec: '0x63636d',
|
|
5527
|
-
hashAlg: 'keccak-256'
|
|
5528
|
-
},
|
|
5529
|
-
{
|
|
5530
|
-
name: 'transaction-message',
|
|
5531
|
-
codec: '0x746d',
|
|
5532
|
-
hashAlg: 'keccak-256'
|
|
5533
|
-
},
|
|
5534
|
-
{
|
|
5535
|
-
name: '
|
|
5536
|
-
codec: '
|
|
5537
|
-
hashAlg: 'keccak-256'
|
|
5538
|
-
},
|
|
5539
|
-
{
|
|
5540
|
-
name: '
|
|
5541
|
-
codec: '
|
|
5542
|
-
hashAlg: 'keccak-256'
|
|
5543
|
-
},
|
|
5544
|
-
{
|
|
5545
|
-
name: 'bw-
|
|
5546
|
-
codec: '
|
|
5547
|
-
hashAlg: 'keccak-256'
|
|
5548
|
-
},
|
|
5549
|
-
{
|
|
5550
|
-
name: '
|
|
5551
|
-
codec: '
|
|
5552
|
-
hashAlg: 'keccak-256'
|
|
5553
|
-
}
|
|
5503
|
+
const blockchainCodecs = [
|
|
5504
|
+
{
|
|
5505
|
+
name: 'leofcoin-block',
|
|
5506
|
+
codec: '0x6c62',
|
|
5507
|
+
hashAlg: 'dbl-keccak-512',
|
|
5508
|
+
},
|
|
5509
|
+
{
|
|
5510
|
+
name: 'leofcoin-tx',
|
|
5511
|
+
codec: '0x6c74',
|
|
5512
|
+
hashAlg: 'dbl-keccak-512',
|
|
5513
|
+
},
|
|
5514
|
+
{
|
|
5515
|
+
name: 'leofcoin-itx',
|
|
5516
|
+
codec: '0x6c69',
|
|
5517
|
+
hashAlg: 'keccak-512',
|
|
5518
|
+
},
|
|
5519
|
+
{
|
|
5520
|
+
name: 'leofcoin-pr',
|
|
5521
|
+
codec: '0x6c70',
|
|
5522
|
+
hashAlg: 'keccak-256',
|
|
5523
|
+
},
|
|
5524
|
+
{
|
|
5525
|
+
name: 'contract-message',
|
|
5526
|
+
codec: '0x63636d',
|
|
5527
|
+
hashAlg: 'keccak-256'
|
|
5528
|
+
},
|
|
5529
|
+
{
|
|
5530
|
+
name: 'transaction-message',
|
|
5531
|
+
codec: '0x746d',
|
|
5532
|
+
hashAlg: 'keccak-256'
|
|
5533
|
+
},
|
|
5534
|
+
{
|
|
5535
|
+
name: 'raw-transaction-message',
|
|
5536
|
+
codec: '0x772746d',
|
|
5537
|
+
hashAlg: 'keccak-256'
|
|
5538
|
+
},
|
|
5539
|
+
{
|
|
5540
|
+
name: 'block-message',
|
|
5541
|
+
codec: '0x626d',
|
|
5542
|
+
hashAlg: 'keccak-256'
|
|
5543
|
+
},
|
|
5544
|
+
{
|
|
5545
|
+
name: 'bw-message',
|
|
5546
|
+
codec: '0x62776d',
|
|
5547
|
+
hashAlg: 'keccak-256'
|
|
5548
|
+
},
|
|
5549
|
+
{
|
|
5550
|
+
name: 'bw-request-message',
|
|
5551
|
+
codec: '0x6277726d',
|
|
5552
|
+
hashAlg: 'keccak-256'
|
|
5553
|
+
},
|
|
5554
|
+
{
|
|
5555
|
+
name: 'validator-message',
|
|
5556
|
+
codec: '0x766d',
|
|
5557
|
+
hashAlg: 'keccak-256'
|
|
5558
|
+
}
|
|
5554
5559
|
];
|
|
5555
5560
|
|
|
5556
|
-
const internalCodecs = [
|
|
5557
|
-
{
|
|
5558
|
-
name: 'disco-hash',
|
|
5559
|
-
codec: '0x30',
|
|
5560
|
-
hashAlg: 'dbl-keccak-256',
|
|
5561
|
-
},
|
|
5562
|
-
{
|
|
5563
|
-
name: 'peernet-peer-response',
|
|
5564
|
-
codec: '0x707072',
|
|
5565
|
-
hashAlg: 'keccak-256',
|
|
5566
|
-
},
|
|
5567
|
-
{
|
|
5568
|
-
name: 'peernet-peer',
|
|
5569
|
-
codec: '0x7070',
|
|
5570
|
-
hashAlg: 'keccak-256',
|
|
5571
|
-
},
|
|
5572
|
-
{
|
|
5573
|
-
name: 'peernet-dht',
|
|
5574
|
-
codec: '0x706468',
|
|
5575
|
-
hashAlg: 'keccak-256',
|
|
5576
|
-
},
|
|
5577
|
-
{
|
|
5578
|
-
name: 'peernet-dht-response',
|
|
5579
|
-
codec: '0x706472',
|
|
5580
|
-
hashAlg: 'keccak-256',
|
|
5581
|
-
},
|
|
5582
|
-
{
|
|
5583
|
-
name: 'peernet-data',
|
|
5584
|
-
codec: '0x706461',
|
|
5585
|
-
hashAlg: 'keccak-256',
|
|
5586
|
-
},
|
|
5587
|
-
{
|
|
5588
|
-
name: 'peernet-data-response',
|
|
5589
|
-
codec: '0x70646172',
|
|
5590
|
-
hashAlg: 'keccak-256',
|
|
5591
|
-
},
|
|
5592
|
-
{
|
|
5593
|
-
name: 'peernet-message',
|
|
5594
|
-
codec: '0x706d65',
|
|
5595
|
-
hashAlg: 'keccak-256',
|
|
5596
|
-
},
|
|
5597
|
-
{
|
|
5598
|
-
name: 'peernet-ps',
|
|
5599
|
-
codec: '707073',
|
|
5600
|
-
hashAlg: 'keccak-256',
|
|
5601
|
-
},
|
|
5602
|
-
{
|
|
5603
|
-
name: 'peernet-response',
|
|
5604
|
-
codec: '0x7072',
|
|
5605
|
-
hashAlg: 'keccak-256',
|
|
5606
|
-
},
|
|
5607
|
-
{
|
|
5608
|
-
name: 'peernet-request',
|
|
5609
|
-
codec: '0x707271',
|
|
5610
|
-
hashAlg: 'keccak-256',
|
|
5611
|
-
},
|
|
5612
|
-
{
|
|
5613
|
-
name: 'peernet-file',
|
|
5614
|
-
codec: '0x7066',
|
|
5615
|
-
hashAlg: 'keccak-256',
|
|
5616
|
-
},
|
|
5617
|
-
{
|
|
5618
|
-
name: 'peernet-file-response',
|
|
5619
|
-
codec: '0x706672',
|
|
5620
|
-
hashAlg: 'keccak-256',
|
|
5621
|
-
}
|
|
5561
|
+
const internalCodecs = [
|
|
5562
|
+
{
|
|
5563
|
+
name: 'disco-hash',
|
|
5564
|
+
codec: '0x30',
|
|
5565
|
+
hashAlg: 'dbl-keccak-256',
|
|
5566
|
+
},
|
|
5567
|
+
{
|
|
5568
|
+
name: 'peernet-peer-response',
|
|
5569
|
+
codec: '0x707072',
|
|
5570
|
+
hashAlg: 'keccak-256',
|
|
5571
|
+
},
|
|
5572
|
+
{
|
|
5573
|
+
name: 'peernet-peer',
|
|
5574
|
+
codec: '0x7070',
|
|
5575
|
+
hashAlg: 'keccak-256',
|
|
5576
|
+
},
|
|
5577
|
+
{
|
|
5578
|
+
name: 'peernet-dht',
|
|
5579
|
+
codec: '0x706468',
|
|
5580
|
+
hashAlg: 'keccak-256',
|
|
5581
|
+
},
|
|
5582
|
+
{
|
|
5583
|
+
name: 'peernet-dht-response',
|
|
5584
|
+
codec: '0x706472',
|
|
5585
|
+
hashAlg: 'keccak-256',
|
|
5586
|
+
},
|
|
5587
|
+
{
|
|
5588
|
+
name: 'peernet-data',
|
|
5589
|
+
codec: '0x706461',
|
|
5590
|
+
hashAlg: 'keccak-256',
|
|
5591
|
+
},
|
|
5592
|
+
{
|
|
5593
|
+
name: 'peernet-data-response',
|
|
5594
|
+
codec: '0x70646172',
|
|
5595
|
+
hashAlg: 'keccak-256',
|
|
5596
|
+
},
|
|
5597
|
+
{
|
|
5598
|
+
name: 'peernet-message',
|
|
5599
|
+
codec: '0x706d65',
|
|
5600
|
+
hashAlg: 'keccak-256',
|
|
5601
|
+
},
|
|
5602
|
+
{
|
|
5603
|
+
name: 'peernet-ps',
|
|
5604
|
+
codec: '707073',
|
|
5605
|
+
hashAlg: 'keccak-256',
|
|
5606
|
+
},
|
|
5607
|
+
{
|
|
5608
|
+
name: 'peernet-response',
|
|
5609
|
+
codec: '0x7072',
|
|
5610
|
+
hashAlg: 'keccak-256',
|
|
5611
|
+
},
|
|
5612
|
+
{
|
|
5613
|
+
name: 'peernet-request',
|
|
5614
|
+
codec: '0x707271',
|
|
5615
|
+
hashAlg: 'keccak-256',
|
|
5616
|
+
},
|
|
5617
|
+
{
|
|
5618
|
+
name: 'peernet-file',
|
|
5619
|
+
codec: '0x7066',
|
|
5620
|
+
hashAlg: 'keccak-256',
|
|
5621
|
+
},
|
|
5622
|
+
{
|
|
5623
|
+
name: 'peernet-file-response',
|
|
5624
|
+
codec: '0x706672',
|
|
5625
|
+
hashAlg: 'keccak-256',
|
|
5626
|
+
}
|
|
5622
5627
|
];
|
|
5623
5628
|
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5629
|
+
var social = [{
|
|
5630
|
+
name: 'chat-message',
|
|
5631
|
+
codec: '0x70636d',
|
|
5632
|
+
hashAlg: 'dbl-keccak-256',
|
|
5633
|
+
}];
|
|
5634
|
+
|
|
5635
|
+
const codecs = [
|
|
5636
|
+
...internalCodecs,
|
|
5637
|
+
...blockchainCodecs,
|
|
5638
|
+
...social
|
|
5632
5639
|
];
|
|
5633
5640
|
|
|
5634
|
-
globalThis.peernetCodecs = globalThis.peernetCodecs || {};
|
|
5635
|
-
const addCodec = (codecInput) => {
|
|
5636
|
-
let { hashAlg, codec, name } = codecInput;
|
|
5637
|
-
if (!globalThis.peernetCodecs[name])
|
|
5638
|
-
globalThis.peernetCodecs[name] = {
|
|
5639
|
-
hashAlg,
|
|
5640
|
-
codec: typeof codec === 'string' ? parseInt(codec, 16) : codec
|
|
5641
|
-
};
|
|
5642
|
-
};
|
|
5643
|
-
const getCodec = (name) => {
|
|
5644
|
-
if (typeof name === 'number')
|
|
5645
|
-
return name;
|
|
5646
|
-
return getCodecByName(name).codec;
|
|
5647
|
-
};
|
|
5648
|
-
const getCodecName = (codec) => {
|
|
5649
|
-
return Object.keys(globalThis.peernetCodecs).reduce((p, c) => {
|
|
5650
|
-
const item = globalThis.peernetCodecs[c];
|
|
5651
|
-
if (item.codec === codec)
|
|
5652
|
-
return c;
|
|
5653
|
-
else
|
|
5654
|
-
return p;
|
|
5655
|
-
}, undefined);
|
|
5656
|
-
};
|
|
5657
|
-
const getCodecByName = (name) => globalThis.peernetCodecs[name];
|
|
5658
|
-
const getHashAlg = (name) => {
|
|
5659
|
-
if (typeof name === 'number')
|
|
5660
|
-
return getCodecByName(getCodecName(name)).hashAlg;
|
|
5661
|
-
return getCodecByName(name).hashAlg;
|
|
5662
|
-
};
|
|
5663
|
-
const isCodec = (codec) => {
|
|
5664
|
-
if (codec.codec !== undefined && codec.hashAlg)
|
|
5665
|
-
return true;
|
|
5666
|
-
return false;
|
|
5667
|
-
};
|
|
5668
|
-
const validateCodec = (codec) => {
|
|
5669
|
-
if (codec.codec === undefined ||
|
|
5670
|
-
codec.hashAlg === undefined ||
|
|
5671
|
-
codec.name === undefined)
|
|
5672
|
-
throw new Error(`invalid codecInput: ${codec}`);
|
|
5673
|
-
};
|
|
5674
|
-
for (const codec of codecs) {
|
|
5675
|
-
addCodec(codec);
|
|
5676
|
-
}
|
|
5677
|
-
var utils$p = {
|
|
5678
|
-
isCodec,
|
|
5679
|
-
addCodec,
|
|
5680
|
-
getCodec,
|
|
5681
|
-
getHashAlg,
|
|
5682
|
-
getCodecName,
|
|
5683
|
-
validateCodec,
|
|
5684
|
-
codecs: globalThis.peernetCodecs
|
|
5641
|
+
globalThis.peernetCodecs = globalThis.peernetCodecs || {};
|
|
5642
|
+
const addCodec = (codecInput) => {
|
|
5643
|
+
let { hashAlg, codec, name } = codecInput;
|
|
5644
|
+
if (!globalThis.peernetCodecs[name])
|
|
5645
|
+
globalThis.peernetCodecs[name] = {
|
|
5646
|
+
hashAlg,
|
|
5647
|
+
codec: typeof codec === 'string' ? parseInt(codec, 16) : codec
|
|
5648
|
+
};
|
|
5649
|
+
};
|
|
5650
|
+
const getCodec = (name) => {
|
|
5651
|
+
if (typeof name === 'number')
|
|
5652
|
+
return name;
|
|
5653
|
+
return getCodecByName(name).codec;
|
|
5654
|
+
};
|
|
5655
|
+
const getCodecName = (codec) => {
|
|
5656
|
+
return Object.keys(globalThis.peernetCodecs).reduce((p, c) => {
|
|
5657
|
+
const item = globalThis.peernetCodecs[c];
|
|
5658
|
+
if (item.codec === codec)
|
|
5659
|
+
return c;
|
|
5660
|
+
else
|
|
5661
|
+
return p;
|
|
5662
|
+
}, undefined);
|
|
5663
|
+
};
|
|
5664
|
+
const getCodecByName = (name) => globalThis.peernetCodecs[name];
|
|
5665
|
+
const getHashAlg = (name) => {
|
|
5666
|
+
if (typeof name === 'number')
|
|
5667
|
+
return getCodecByName(getCodecName(name)).hashAlg;
|
|
5668
|
+
return getCodecByName(name).hashAlg;
|
|
5669
|
+
};
|
|
5670
|
+
const isCodec = (codec) => {
|
|
5671
|
+
if (codec.codec !== undefined && codec.hashAlg)
|
|
5672
|
+
return true;
|
|
5673
|
+
return false;
|
|
5674
|
+
};
|
|
5675
|
+
const validateCodec = (codec) => {
|
|
5676
|
+
if (codec.codec === undefined ||
|
|
5677
|
+
codec.hashAlg === undefined ||
|
|
5678
|
+
codec.name === undefined)
|
|
5679
|
+
throw new Error(`invalid codecInput: ${codec}`);
|
|
5680
|
+
};
|
|
5681
|
+
for (const codec of codecs) {
|
|
5682
|
+
addCodec(codec);
|
|
5683
|
+
}
|
|
5684
|
+
var utils$p = {
|
|
5685
|
+
isCodec,
|
|
5686
|
+
addCodec,
|
|
5687
|
+
getCodec,
|
|
5688
|
+
getHashAlg,
|
|
5689
|
+
getCodecName,
|
|
5690
|
+
validateCodec,
|
|
5691
|
+
codecs: globalThis.peernetCodecs
|
|
5685
5692
|
};
|
|
5686
5693
|
|
|
5687
5694
|
/**
|
|
@@ -5713,11 +5720,11 @@ let BasicInterface$1 = class BasicInterface {
|
|
|
5713
5720
|
// get Codec(): Codec {}
|
|
5714
5721
|
protoEncode(data) {
|
|
5715
5722
|
// check schema
|
|
5716
|
-
return index$1.encode(this.proto, data);
|
|
5723
|
+
return index$1.encode(this.proto, data, false);
|
|
5717
5724
|
}
|
|
5718
5725
|
protoDecode(data) {
|
|
5719
5726
|
// check schema
|
|
5720
|
-
return index$1.decode(this.proto, data);
|
|
5727
|
+
return index$1.decode(this.proto, data, false);
|
|
5721
5728
|
}
|
|
5722
5729
|
isHex(string) {
|
|
5723
5730
|
return isHex(string);
|
|
@@ -6114,14 +6121,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface$1 {
|
|
|
6114
6121
|
const decoded = {};
|
|
6115
6122
|
if (this.keys?.length > 0) {
|
|
6116
6123
|
for (const key of this.keys) {
|
|
6117
|
-
|
|
6118
|
-
[key]: {
|
|
6119
|
-
enumerable: true,
|
|
6120
|
-
configurable: true,
|
|
6121
|
-
set: (value) => data[key],
|
|
6122
|
-
get: () => data[key]
|
|
6123
|
-
}
|
|
6124
|
-
});
|
|
6124
|
+
decoded[key] = data[key];
|
|
6125
6125
|
}
|
|
6126
6126
|
this.decoded = decoded;
|
|
6127
6127
|
return this.encode(decoded);
|
|
@@ -20267,7 +20267,7 @@ class Identity {
|
|
|
20267
20267
|
globalThis.peernet.selectedAccount = new TextDecoder().decode(selected);
|
|
20268
20268
|
}
|
|
20269
20269
|
else {
|
|
20270
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-
|
|
20270
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-904b9f85-2d6175c2.js');
|
|
20271
20271
|
const { identity, accounts } = await importee.default(password, this.network);
|
|
20272
20272
|
await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
|
|
20273
20273
|
await globalThis.walletStore.put('version', String(1));
|
|
@@ -20438,7 +20438,7 @@ class Peernet {
|
|
|
20438
20438
|
this.root = options.root;
|
|
20439
20439
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
20440
20440
|
// FolderMessageResponse
|
|
20441
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-
|
|
20441
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-de2c5670-d99ad896.js');
|
|
20442
20442
|
/**
|
|
20443
20443
|
* proto Object containing protos
|
|
20444
20444
|
* @type {Object}
|
|
@@ -20517,7 +20517,7 @@ class Peernet {
|
|
|
20517
20517
|
if (this.#starting || this.#started)
|
|
20518
20518
|
return;
|
|
20519
20519
|
this.#starting = true;
|
|
20520
|
-
const importee = await import('./client-
|
|
20520
|
+
const importee = await import('./client-d1c29e20-c5d45b87.js');
|
|
20521
20521
|
/**
|
|
20522
20522
|
* @access public
|
|
20523
20523
|
* @type {PeernetClient}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { N as default } from './node-browser-
|
|
1
|
+
export { N as default } from './node-browser-3d505e1f.js';
|
|
2
2
|
import './index-640d9f36.js';
|
package/exports/chain.js
CHANGED
|
@@ -822,32 +822,8 @@ class Chain extends Contract {
|
|
|
822
822
|
if (!peer.version || peer.version !== this.version)
|
|
823
823
|
return;
|
|
824
824
|
const lastBlock = await this.#makeRequest(peer, 'lastBlock');
|
|
825
|
-
if (lastBlock.index > this.#lastBlock?.index) {
|
|
825
|
+
if (lastBlock && lastBlock.index > this.#lastBlock?.index) {
|
|
826
826
|
// this.#knownBlocks = await this.#makeRequest(peer, 'knownBlocks')
|
|
827
|
-
try {
|
|
828
|
-
console.log('getting pool');
|
|
829
|
-
let pool = await this.#makeRequest(peer, 'transactionPool');
|
|
830
|
-
console.log('got pool');
|
|
831
|
-
pool = await Promise.all(pool.map(async (hash) => {
|
|
832
|
-
const has = await globalThis.peernet.has(hash);
|
|
833
|
-
return { has, hash };
|
|
834
|
-
}));
|
|
835
|
-
pool = pool.filter(item => !item.has);
|
|
836
|
-
await Promise.all(pool.map(async ({ hash }) => {
|
|
837
|
-
const result = await globalThis.peernet.get(hash);
|
|
838
|
-
// result could be undefined cause invalid/double transactions could be deleted already
|
|
839
|
-
if (!result)
|
|
840
|
-
console.log(result);
|
|
841
|
-
if (result) {
|
|
842
|
-
const node = await new TransactionMessage(result);
|
|
843
|
-
await globalThis.transactionPoolStore.put(await node.hash(), node.encoded);
|
|
844
|
-
}
|
|
845
|
-
}));
|
|
846
|
-
}
|
|
847
|
-
catch (error) {
|
|
848
|
-
console.log(error);
|
|
849
|
-
console.log('error fetching transactionPool');
|
|
850
|
-
}
|
|
851
827
|
console.log(lastBlock);
|
|
852
828
|
if (lastBlock)
|
|
853
829
|
await this.#syncChain(lastBlock);
|