@leofcoin/chain 1.4.54 → 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.
@@ -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-5484753a.js';
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
- this.id = options.id;
40930
- this.to = options.to;
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
@@ -1,4 +1,4 @@
1
- import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-5484753a.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-3d505e1f.js';
2
2
  import './index-640d9f36.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './node-browser-5484753a.js';
1
+ import { F as FormatInterface } from './node-browser-3d505e1f.js';
2
2
  import './index-640d9f36.js';
3
3
 
4
4
  var proto$b = {
@@ -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-437bf7cd-47a5a0fb.js');
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-ccc03e41-b2b7bce7.js');
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-a56e0aac-0ade57cc.js');
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-5484753a.js';
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.4.54",
3
+ "version": "1.4.55",
4
4
  "description": "Official javascript implementation",
5
5
  "exports": {
6
6
  "./node": "./exports/node.js",