trac-peer 0.1.84 → 0.1.86

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trac-peer",
3
3
  "main": "src/index.js",
4
- "version": "0.1.84",
4
+ "version": "0.1.86",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "assert": "npm:bare-node-assert",
package/src/index.js CHANGED
@@ -632,6 +632,7 @@ export class Peer extends ReadyResource {
632
632
 
633
633
  async tx_observer(){
634
634
  while(true){
635
+ let backoff = 1;
635
636
  const ts = Math.floor(Date.now() / 1000);
636
637
  for(let tx in this.tx_pool){
637
638
  if(ts - this.tx_pool[tx].ts > this.max_tx_delay){
@@ -645,17 +646,20 @@ export class Peer extends ReadyResource {
645
646
  const msb_tx = await view_session.get(tx);
646
647
  await view_session.close();
647
648
  if(null !== msb_tx){
648
- const _this = this;
649
- async function push(){
650
- await _this.sleep(5_000);
651
- try{
652
- await _this.protocol_instance.broadcastTransaction(_this.msb.getNetwork().validator,{
653
- type : 'p',
654
- value : ''
655
- });
656
- } catch(e) { }
649
+ if(this.protocol_instance.prepared_transactions_content[tx].dispatch.type !== undefined &&
650
+ this.protocol_instance.prepared_transactions_content[tx].dispatch.type !== 'p'){
651
+ const _this = this;
652
+ async function push(){
653
+ await _this.sleep(10_000 + (backoff * 250));
654
+ try{
655
+ await _this.protocol_instance.broadcastTransaction(_this.msb.getNetwork().validator,{
656
+ type : 'p',
657
+ value : ''
658
+ });
659
+ } catch(e) { }
660
+ }
661
+ push();
657
662
  }
658
- push();
659
663
  const _tx = {};
660
664
  _tx['msbsl'] = msbsl;
661
665
  _tx['dispatch'] = this.protocol_instance.prepared_transactions_content[tx].dispatch;
@@ -665,6 +669,7 @@ export class Peer extends ReadyResource {
665
669
  delete this.tx_pool[tx];
666
670
  delete this.protocol_instance.prepared_transactions_content[tx];
667
671
  await this.base.append({ type: 'tx', key: tx, value: _tx });
672
+ backoff += 1;
668
673
  }
669
674
  await this.sleep(5);
670
675
  }
package/src/protocol.js CHANGED
@@ -199,7 +199,7 @@ class Protocol{
199
199
  }, sim, surrogate);
200
200
  const _this = this;
201
201
  async function push(){
202
- await _this.peer.sleep(5_000);
202
+ await _this.peer.sleep(10_000);
203
203
  try{
204
204
  await _this.broadcastTransaction(_this.peer.msb.getNetwork().validator,{
205
205
  type : 'p',