wao 0.14.1 → 0.14.3

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.
@@ -33,6 +33,7 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
33
33
  var pkg = (_WarpArBundles$defaul = WarpArBundles["default"]) !== null && _WarpArBundles$defaul !== void 0 ? _WarpArBundles$defaul : WarpArBundles;
34
34
  var DataItem = pkg.DataItem;
35
35
  var onRecovery = {};
36
+ var ongoing = {};
36
37
  var _default = exports["default"] = function _default() {
37
38
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
38
39
  AR = _ref.AR,
@@ -298,6 +299,7 @@ var _default = exports["default"] = function _default() {
298
299
  item,
299
300
  __tags,
300
301
  msg_owner,
302
+ _opt$id,
301
303
  _yield$ar$httpmsg,
302
304
  _opt$tags,
303
305
  ex,
@@ -355,13 +357,31 @@ var _default = exports["default"] = function _default() {
355
357
  format = _yield$mem$getWasm.format;
356
358
  msg_owner = mu.addr;
357
359
  if (!ar.isHttpMsg(opt.http_msg)) {
358
- _context3.next = 25;
360
+ _context3.next = 35;
359
361
  break;
360
362
  }
361
- id = opt.http_msg.target;
362
- _context3.next = 16;
363
+ id = (_opt$id = opt.id) !== null && _opt$id !== void 0 ? _opt$id : opt.http_msg.target;
364
+ if (!ongoing[id]) {
365
+ _context3.next = 23;
366
+ break;
367
+ }
368
+ case 15:
369
+ if (!ongoing[id]) {
370
+ _context3.next = 20;
371
+ break;
372
+ }
373
+ _context3.next = 18;
374
+ return (0, _utils.wait)(100);
375
+ case 18:
376
+ _context3.next = 15;
377
+ break;
378
+ case 20:
379
+ return _context3.abrupt("return", id);
380
+ case 23:
381
+ ongoing[id] = true;
382
+ _context3.next = 26;
363
383
  return ar.httpmsg(opt.http_msg, id);
364
- case 16:
384
+ case 26:
365
385
  _yield$ar$httpmsg = _context3.sent;
366
386
  owner = _yield$ar$httpmsg.owner;
367
387
  item = _yield$ar$httpmsg.item;
@@ -369,9 +389,10 @@ var _default = exports["default"] = function _default() {
369
389
  opt.tags = (0, _utils.buildTags)(null, __tags);
370
390
  opt.data = opt.http_msg.data;
371
391
  msg_owner = owner;
372
- _context3.next = 42;
392
+ case 33:
393
+ _context3.next = 52;
373
394
  break;
374
- case 25:
395
+ case 35:
375
396
  opt.tags = (0, _utils.buildTags)(null, (0, _ramda.mergeLeft)((0, _utils.tags)((_opt$tags = opt.tags) !== null && _opt$tags !== void 0 ? _opt$tags : []), {
376
397
  "Data-Protocol": "ao",
377
398
  Variant: "ao.TN.1",
@@ -402,14 +423,14 @@ var _default = exports["default"] = function _default() {
402
423
  name: "Pushed-For",
403
424
  value: opt["for"]
404
425
  });
405
- _context3.next = 33;
426
+ _context3.next = 43;
406
427
  return ar.dataitem({
407
428
  item: opt.item,
408
429
  data: opt.data,
409
430
  signer: opt.signer,
410
431
  tags: (0, _utils.tags)(opt.tags)
411
432
  });
412
- case 33:
433
+ case 43:
413
434
  _yield$ar$dataitem = _context3.sent;
414
435
  id = _yield$ar$dataitem.id;
415
436
  owner = _yield$ar$dataitem.owner;
@@ -417,23 +438,23 @@ var _default = exports["default"] = function _default() {
417
438
  __tags = _yield$ar$dataitem.tags;
418
439
  opt.tags = (0, _utils.buildTags)(null, __tags);
419
440
  if (opt.item) opt.data = _base64url["default"].decode(item.data);
420
- _context3.next = 42;
441
+ _context3.next = 52;
421
442
  return ar.postItems(item, su.jwk);
422
- case 42:
443
+ case 52:
423
444
  now = Date.now;
424
445
  t = (0, _utils.tags)(opt.tags);
425
446
  ext = t.Extension || "WeaveDrive";
426
447
  wdrive = extensions[ext];
427
448
  handle = null;
428
- _context3.prev = 47;
449
+ _context3.prev = 57;
429
450
  _context3.t0 = AoLoader;
430
451
  _context3.t1 = wasm;
431
452
  _context3.t2 = format;
432
453
  _context3.t3 = wdrive;
433
454
  _context3.t4 = item;
434
- _context3.next = 55;
455
+ _context3.next = 65;
435
456
  return mem.getTx(mod);
436
- case 55:
457
+ case 65:
437
458
  _context3.t5 = _context3.sent;
438
459
  _context3.t6 = {
439
460
  format: _context3.t2,
@@ -441,23 +462,23 @@ var _default = exports["default"] = function _default() {
441
462
  spawn: _context3.t4,
442
463
  module: _context3.t5
443
464
  };
444
- _context3.next = 59;
465
+ _context3.next = 69;
445
466
  return (0, _context3.t0)(_context3.t1, _context3.t6);
446
- case 59:
467
+ case 69:
447
468
  handle = _context3.sent;
448
- _context3.next = 65;
469
+ _context3.next = 75;
449
470
  break;
450
- case 62:
451
- _context3.prev = 62;
452
- _context3.t7 = _context3["catch"](47);
471
+ case 72:
472
+ _context3.prev = 72;
473
+ _context3.t7 = _context3["catch"](57);
453
474
  console.log(mod, _context3.t7);
454
- case 65:
475
+ case 75:
455
476
  if (handle) {
456
- _context3.next = 67;
477
+ _context3.next = 77;
457
478
  break;
458
479
  }
459
480
  return _context3.abrupt("return", null);
460
- case 67:
481
+ case 77:
461
482
  _module = null;
462
483
  _module = {
463
484
  handle: handle,
@@ -481,126 +502,126 @@ var _default = exports["default"] = function _default() {
481
502
  results: [id]
482
503
  };
483
504
  if (!memory) {
484
- _context3.next = 77;
505
+ _context3.next = 87;
485
506
  break;
486
507
  }
487
- _context3.next = 118;
508
+ _context3.next = 128;
488
509
  break;
489
- case 77:
510
+ case 87:
490
511
  if (!(_tags["On-Boot"] || true)) {
491
- _context3.next = 117;
512
+ _context3.next = 127;
492
513
  break;
493
514
  }
494
515
  data = "";
495
516
  if (!(_tags["On-Boot"] === "Data")) {
496
- _context3.next = 83;
517
+ _context3.next = 93;
497
518
  break;
498
519
  }
499
520
  data = (_opt$data = opt.data) !== null && _opt$data !== void 0 ? _opt$data : "";
500
- _context3.next = 104;
521
+ _context3.next = 114;
501
522
  break;
502
- case 83:
503
- _context3.next = 85;
523
+ case 93:
524
+ _context3.next = 95;
504
525
  return mem.get("msgs", _tags["On-Boot"]);
505
- case 85:
526
+ case 95:
506
527
  _context3.t10 = _yield$mem$get = _context3.sent;
507
528
  _context3.t9 = _context3.t10 === null;
508
529
  if (_context3.t9) {
509
- _context3.next = 89;
530
+ _context3.next = 99;
510
531
  break;
511
532
  }
512
533
  _context3.t9 = _yield$mem$get === void 0;
513
- case 89:
534
+ case 99:
514
535
  if (!_context3.t9) {
515
- _context3.next = 93;
536
+ _context3.next = 103;
516
537
  break;
517
538
  }
518
539
  _context3.t11 = void 0;
519
- _context3.next = 94;
540
+ _context3.next = 104;
520
541
  break;
521
- case 93:
542
+ case 103:
522
543
  _context3.t11 = _yield$mem$get.data;
523
- case 94:
544
+ case 104:
524
545
  _context3.t12 = _yield$mem$get$data = _context3.t11;
525
546
  _context3.t8 = _context3.t12 !== null;
526
547
  if (!_context3.t8) {
527
- _context3.next = 98;
548
+ _context3.next = 108;
528
549
  break;
529
550
  }
530
551
  _context3.t8 = _yield$mem$get$data !== void 0;
531
- case 98:
552
+ case 108:
532
553
  if (!_context3.t8) {
533
- _context3.next = 102;
554
+ _context3.next = 112;
534
555
  break;
535
556
  }
536
557
  _context3.t13 = _yield$mem$get$data;
537
- _context3.next = 103;
558
+ _context3.next = 113;
538
559
  break;
539
- case 102:
560
+ case 112:
540
561
  _context3.t13 = "";
541
- case 103:
562
+ case 113:
542
563
  data = _context3.t13;
543
- case 104:
544
- _context3.next = 106;
564
+ case 114:
565
+ _context3.next = 116;
545
566
  return genMsg(id, p, data, opt.tags, owner, msg_owner, true);
546
- case 106:
567
+ case 116:
547
568
  msg = _context3.sent;
548
- _context3.next = 109;
569
+ _context3.next = 119;
549
570
  return genEnv({
550
571
  pid: p.id,
551
572
  owner: p.owner,
552
573
  module: p.module
553
574
  });
554
- case 109:
575
+ case 119:
555
576
  _env = _context3.sent;
556
- _context3.next = 112;
577
+ _context3.next = 122;
557
578
  return _module.handle(null, msg, _env);
558
- case 112:
579
+ case 122:
559
580
  res = _context3.sent;
560
581
  p.memory = res.Memory;
561
582
  delete res.Memory;
562
- _context3.next = 118;
583
+ _context3.next = 128;
563
584
  break;
564
- case 117:
585
+ case 127:
565
586
  p.height += 1;
566
- case 118:
587
+ case 128:
567
588
  _msg = _objectSpread(_objectSpread({}, (0, _ramda.o)((0, _ramda.dissoc)("signer"), (0, _ramda.dissoc)("memory"))(opt)), {}, {
568
589
  res: res
569
590
  });
570
- _context3.next = 121;
591
+ _context3.next = 131;
571
592
  return mem.set(_msg, "msgs", id);
572
- case 121:
593
+ case 131:
573
594
  if (!_tags["Cron-Interval"]) {
574
- _context3.next = 145;
595
+ _context3.next = 155;
575
596
  break;
576
597
  }
577
598
  _tags$CronInterval$s = _tags["Cron-Interval"].split("-"), _tags$CronInterval$s2 = _slicedToArray(_tags$CronInterval$s, 2), num = _tags$CronInterval$s2[0], unit = _tags$CronInterval$s2[1];
578
599
  _int = 0;
579
600
  _context3.t14 = unit.replace(/s$/, "");
580
- _context3.next = _context3.t14 === "millisecond" ? 127 : _context3.t14 === "second" ? 129 : _context3.t14 === "minute" ? 131 : _context3.t14 === "hour" ? 133 : _context3.t14 === "day" ? 135 : _context3.t14 === "month" ? 137 : _context3.t14 === "year" ? 139 : 141;
601
+ _context3.next = _context3.t14 === "millisecond" ? 137 : _context3.t14 === "second" ? 139 : _context3.t14 === "minute" ? 141 : _context3.t14 === "hour" ? 143 : _context3.t14 === "day" ? 145 : _context3.t14 === "month" ? 147 : _context3.t14 === "year" ? 149 : 151;
581
602
  break;
582
- case 127:
603
+ case 137:
583
604
  _int = num;
584
- return _context3.abrupt("break", 141);
585
- case 129:
605
+ return _context3.abrupt("break", 151);
606
+ case 139:
586
607
  _int = num * 1000;
587
- return _context3.abrupt("break", 141);
588
- case 131:
608
+ return _context3.abrupt("break", 151);
609
+ case 141:
589
610
  _int = num * 1000 * 60;
590
- return _context3.abrupt("break", 141);
591
- case 133:
611
+ return _context3.abrupt("break", 151);
612
+ case 143:
592
613
  _int = num * 1000 * 60 * 60;
593
- return _context3.abrupt("break", 141);
594
- case 135:
614
+ return _context3.abrupt("break", 151);
615
+ case 145:
595
616
  _int = num * 1000 * 60 * 60 * 24;
596
- return _context3.abrupt("break", 141);
597
- case 137:
617
+ return _context3.abrupt("break", 151);
618
+ case 147:
598
619
  _int = num * 1000 * 60 * 60 * 24 * 30;
599
- return _context3.abrupt("break", 141);
600
- case 139:
620
+ return _context3.abrupt("break", 151);
621
+ case 149:
601
622
  _int = num * 1000 * 60 * 60 * 24 * 365;
602
- return _context3.abrupt("break", 141);
603
- case 141:
623
+ return _context3.abrupt("break", 151);
624
+ case 151:
604
625
  cronTags = [];
605
626
  for (_k in _tags) {
606
627
  if (/^Cron-Tag-/.test(_k)) {
@@ -612,16 +633,16 @@ var _default = exports["default"] = function _default() {
612
633
  }
613
634
  p.cronTags = cronTags;
614
635
  p.span = _int;
615
- case 145:
616
- _context3.next = 147;
636
+ case 155:
637
+ _context3.next = 157;
617
638
  return mem.set(p, "env", id);
618
- case 147:
639
+ case 157:
619
640
  return _context3.abrupt("return", id);
620
- case 148:
641
+ case 158:
621
642
  case "end":
622
643
  return _context3.stop();
623
644
  }
624
- }, _callee3, null, [[47, 62]]);
645
+ }, _callee3, null, [[57, 72]]);
625
646
  }));
626
647
  return function spawn() {
627
648
  return _ref8.apply(this, arguments);
@@ -639,7 +660,7 @@ var _default = exports["default"] = function _default() {
639
660
  var _assign = /*#__PURE__*/function () {
640
661
  var _ref9 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(opt) {
641
662
  var _opt$tags2;
642
- var p, _opt, hash, _yield$ar$dataitem2, id, owner, item, _opt$data2, _ref10, _opt$from, _res$Messages, _res$Spawns, _res$Assignments, data, _tags, from, raw_owner, hashBuffer, msg, _env, _yield$mem$getWasm2, format, mod, wasm, wdrive, res, _msg, _iterator3, _step3, v, _iterator4, _step4, _v, __tags, _iterator5, _step5, _v2, _iterator6, _step6, v2;
663
+ var p, _opt, hash, _yield$ar$dataitem2, id, owner, item, _opt$data2, _ref10, _opt$from, _res$Messages, _res$Spawns, _res$Assignments, data, _tags, from, raw_owner, hashBuffer, msg, _env, _yield$mem$getTx3, _yield$mem$getWasm2, format, mod, wasm, wdrive, start, res, _msg, _iterator3, _step3, v, _iterator4, _step4, _v, __tags, _iterator5, _step5, _v2, _iterator6, _step6, v2;
643
664
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
644
665
  while (1) switch (_context4.prev = _context4.next) {
645
666
  case 0:
@@ -756,7 +777,7 @@ var _default = exports["default"] = function _default() {
756
777
  case 64:
757
778
  _env = _context4.sent;
758
779
  if (p.handle) {
759
- _context4.next = 88;
780
+ _context4.next = 97;
760
781
  break;
761
782
  }
762
783
  _context4.next = 68;
@@ -774,56 +795,79 @@ var _default = exports["default"] = function _default() {
774
795
  _context4.next = 79;
775
796
  return mem.getTx(p.id);
776
797
  case 79:
777
- _context4.t18 = _context4.sent.item;
778
- _context4.next = 82;
798
+ _context4.t19 = _yield$mem$getTx3 = _context4.sent;
799
+ _context4.t18 = _context4.t19 === null;
800
+ if (_context4.t18) {
801
+ _context4.next = 83;
802
+ break;
803
+ }
804
+ _context4.t18 = _yield$mem$getTx3 === void 0;
805
+ case 83:
806
+ if (!_context4.t18) {
807
+ _context4.next = 87;
808
+ break;
809
+ }
810
+ _context4.t20 = void 0;
811
+ _context4.next = 88;
812
+ break;
813
+ case 87:
814
+ _context4.t20 = _yield$mem$getTx3.item;
815
+ case 88:
816
+ _context4.t21 = _context4.t20;
817
+ _context4.next = 91;
779
818
  return mem.getTx(mod);
780
- case 82:
781
- _context4.t19 = _context4.sent;
782
- _context4.t20 = {
819
+ case 91:
820
+ _context4.t22 = _context4.sent;
821
+ _context4.t23 = {
783
822
  format: _context4.t16,
784
823
  WeaveDrive: _context4.t17,
785
- spawn: _context4.t18,
786
- module: _context4.t19
824
+ spawn: _context4.t21,
825
+ module: _context4.t22
787
826
  };
788
- _context4.next = 86;
789
- return (0, _context4.t14)(_context4.t15, _context4.t20);
790
- case 86:
827
+ _context4.next = 95;
828
+ return (0, _context4.t14)(_context4.t15, _context4.t23);
829
+ case 95:
791
830
  p.handle = _context4.sent;
792
831
  mem.env[opt.process].handle = p.handle;
793
- case 88:
794
- _context4.next = 90;
832
+ case 97:
833
+ if (p.compressed) {
834
+ start = Date.now();
835
+ p.memory = mem.waosm.decompress(p.memory, p.original_size);
836
+ p.compressed = false;
837
+ }
838
+ _context4.next = 100;
795
839
  return p.handle(p.memory, msg, _env);
796
- case 90:
840
+ case 100:
797
841
  res = _context4.sent;
798
842
  p.memory = res.Memory;
799
843
  delete res.Memory;
800
844
  p.results.push(opt.message);
801
- _context4.next = 96;
845
+ _context4.next = 106;
802
846
  return mem.set(p, "env", opt.process);
803
- case 96:
847
+ case 106:
804
848
  _msg = _objectSpread(_objectSpread({}, (0, _ramda.dissoc)("signer", _opt)), {}, {
805
849
  res: res
806
850
  });
807
- _context4.next = 99;
851
+ _context4.next = 109;
808
852
  return mem.set(_msg, "msgs", opt.message);
809
- case 99:
853
+ case 109:
810
854
  _iterator3 = _createForOfIteratorHelper((_res$Messages = res.Messages) !== null && _res$Messages !== void 0 ? _res$Messages : []);
811
- _context4.prev = 100;
855
+ _context4.prev = 110;
812
856
  _iterator3.s();
813
- case 102:
857
+ case 112:
814
858
  if ((_step3 = _iterator3.n()).done) {
815
- _context4.next = 111;
859
+ _context4.next = 121;
816
860
  break;
817
861
  }
818
862
  v = _step3.value;
819
- _context4.next = 106;
863
+ _context4.next = 116;
820
864
  return mem.get("env", v.Target);
821
- case 106:
865
+ case 116:
822
866
  if (!_context4.sent) {
823
- _context4.next = 109;
867
+ _context4.next = 119;
824
868
  break;
825
869
  }
826
- _context4.next = 109;
870
+ _context4.next = 119;
827
871
  return message({
828
872
  "for": opt.message,
829
873
  process: v.Target,
@@ -832,32 +876,32 @@ var _default = exports["default"] = function _default() {
832
876
  signer: mu.signer,
833
877
  from: opt.process
834
878
  });
835
- case 109:
836
- _context4.next = 102;
879
+ case 119:
880
+ _context4.next = 112;
837
881
  break;
838
- case 111:
839
- _context4.next = 116;
882
+ case 121:
883
+ _context4.next = 126;
840
884
  break;
841
- case 113:
842
- _context4.prev = 113;
843
- _context4.t21 = _context4["catch"](100);
844
- _iterator3.e(_context4.t21);
845
- case 116:
846
- _context4.prev = 116;
885
+ case 123:
886
+ _context4.prev = 123;
887
+ _context4.t24 = _context4["catch"](110);
888
+ _iterator3.e(_context4.t24);
889
+ case 126:
890
+ _context4.prev = 126;
847
891
  _iterator3.f();
848
- return _context4.finish(116);
849
- case 119:
892
+ return _context4.finish(126);
893
+ case 129:
850
894
  _iterator4 = _createForOfIteratorHelper((_res$Spawns = res.Spawns) !== null && _res$Spawns !== void 0 ? _res$Spawns : []);
851
- _context4.prev = 120;
895
+ _context4.prev = 130;
852
896
  _iterator4.s();
853
- case 122:
897
+ case 132:
854
898
  if ((_step4 = _iterator4.n()).done) {
855
- _context4.next = 129;
899
+ _context4.next = 139;
856
900
  break;
857
901
  }
858
902
  _v = _step4.value;
859
903
  __tags = (0, _utils.tags)(_v.Tags);
860
- _context4.next = 127;
904
+ _context4.next = 137;
861
905
  return spawn({
862
906
  "for": opt.message,
863
907
  module: __tags.Module,
@@ -867,87 +911,87 @@ var _default = exports["default"] = function _default() {
867
911
  from: __tags["From-Process"],
868
912
  signer: mu.signer
869
913
  });
870
- case 127:
871
- _context4.next = 122;
914
+ case 137:
915
+ _context4.next = 132;
872
916
  break;
873
- case 129:
874
- _context4.next = 134;
917
+ case 139:
918
+ _context4.next = 144;
875
919
  break;
876
- case 131:
877
- _context4.prev = 131;
878
- _context4.t22 = _context4["catch"](120);
879
- _iterator4.e(_context4.t22);
880
- case 134:
881
- _context4.prev = 134;
920
+ case 141:
921
+ _context4.prev = 141;
922
+ _context4.t25 = _context4["catch"](130);
923
+ _iterator4.e(_context4.t25);
924
+ case 144:
925
+ _context4.prev = 144;
882
926
  _iterator4.f();
883
- return _context4.finish(134);
884
- case 137:
927
+ return _context4.finish(144);
928
+ case 147:
885
929
  _iterator5 = _createForOfIteratorHelper((_res$Assignments = res.Assignments) !== null && _res$Assignments !== void 0 ? _res$Assignments : []);
886
- _context4.prev = 138;
930
+ _context4.prev = 148;
887
931
  _iterator5.s();
888
- case 140:
932
+ case 150:
889
933
  if ((_step5 = _iterator5.n()).done) {
890
- _context4.next = 161;
934
+ _context4.next = 171;
891
935
  break;
892
936
  }
893
937
  _v2 = _step5.value;
894
938
  _iterator6 = _createForOfIteratorHelper(_v2.Processes);
895
- _context4.prev = 143;
939
+ _context4.prev = 153;
896
940
  _iterator6.s();
897
- case 145:
941
+ case 155:
898
942
  if ((_step6 = _iterator6.n()).done) {
899
- _context4.next = 151;
943
+ _context4.next = 161;
900
944
  break;
901
945
  }
902
946
  v2 = _step6.value;
903
- _context4.next = 149;
947
+ _context4.next = 159;
904
948
  return _assign({
905
949
  message: _v2.Message,
906
950
  process: v2,
907
951
  from: opt.process,
908
952
  signer: mu.signer
909
953
  });
910
- case 149:
911
- _context4.next = 145;
912
- break;
913
- case 151:
914
- _context4.next = 156;
915
- break;
916
- case 153:
917
- _context4.prev = 153;
918
- _context4.t23 = _context4["catch"](143);
919
- _iterator6.e(_context4.t23);
920
- case 156:
921
- _context4.prev = 156;
922
- _iterator6.f();
923
- return _context4.finish(156);
924
954
  case 159:
925
- _context4.next = 140;
955
+ _context4.next = 155;
926
956
  break;
927
957
  case 161:
928
958
  _context4.next = 166;
929
959
  break;
930
960
  case 163:
931
961
  _context4.prev = 163;
932
- _context4.t24 = _context4["catch"](138);
933
- _iterator5.e(_context4.t24);
962
+ _context4.t26 = _context4["catch"](153);
963
+ _iterator6.e(_context4.t26);
934
964
  case 166:
935
965
  _context4.prev = 166;
936
- _iterator5.f();
966
+ _iterator6.f();
937
967
  return _context4.finish(166);
938
968
  case 169:
969
+ _context4.next = 150;
970
+ break;
971
+ case 171:
972
+ _context4.next = 176;
973
+ break;
974
+ case 173:
975
+ _context4.prev = 173;
976
+ _context4.t27 = _context4["catch"](148);
977
+ _iterator5.e(_context4.t27);
978
+ case 176:
979
+ _context4.prev = 176;
980
+ _iterator5.f();
981
+ return _context4.finish(176);
982
+ case 179:
939
983
  return _context4.abrupt("return", id);
940
- case 172:
941
- _context4.prev = 172;
942
- _context4.t25 = _context4["catch"](38);
943
- console.log(_context4.t25);
944
- case 175:
984
+ case 182:
985
+ _context4.prev = 182;
986
+ _context4.t28 = _context4["catch"](38);
987
+ console.log(_context4.t28);
988
+ case 185:
945
989
  return _context4.abrupt("return", null);
946
- case 176:
990
+ case 186:
947
991
  case "end":
948
992
  return _context4.stop();
949
993
  }
950
- }, _callee4, null, [[38, 172], [43, 56], [100, 113, 116, 119], [120, 131, 134, 137], [138, 163, 166, 169], [143, 153, 156, 159]]);
994
+ }, _callee4, null, [[38, 182], [43, 56], [110, 123, 126, 129], [130, 141, 144, 147], [148, 173, 176, 179], [153, 163, 166, 169]]);
951
995
  }));
952
996
  return function assign(_x8) {
953
997
  return _ref9.apply(this, arguments);
@@ -955,7 +999,7 @@ var _default = exports["default"] = function _default() {
955
999
  }();
956
1000
  var message = /*#__PURE__*/function () {
957
1001
  var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(opt) {
958
- var id, owner, item, _yield$ar$httpmsg2, _p, new_slot, last_slot, _opt$item$id, _opt$item, _opt$owner, _id, _owner, _item, p, _opt$tags3, _yield$mem$getTx$tags3, _yield$mem$getTx3, pr, module, _yield$ar$dataitem3, _msg, _opt, _ref12, _opt$from2, _opt$http_msg$data, from, data, _tags, msg, _env, _yield$mem$getWasm3, format, mod, wasm, wdrive, res, _msg2;
1002
+ var id, owner, item, _opt$id2, _yield$ar$httpmsg2, _p, new_slot, last_slot, _opt$item$id, _opt$item, _opt$owner, _id, _owner, _item, p, _opt$tags3, _yield$mem$getTx$tags3, _yield$mem$getTx4, pr, module, _yield$ar$dataitem3, _msg, _opt, _ref12, _opt$from2, _opt$http_msg$data, from, data, _tags, msg, _env, _yield$mem$getTx5, _yield$mem$getWasm3, format, mod, wasm, wdrive, start, res, _msg2;
959
1003
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
960
1004
  while (1) switch (_context5.prev = _context5.next) {
961
1005
  case 0:
@@ -963,54 +1007,72 @@ var _default = exports["default"] = function _default() {
963
1007
  owner = "";
964
1008
  item = null;
965
1009
  if (!ar.isHttpMsg(opt.http_msg)) {
966
- _context5.next = 22;
1010
+ _context5.next = 32;
1011
+ break;
1012
+ }
1013
+ id = (_opt$id2 = opt.id) !== null && _opt$id2 !== void 0 ? _opt$id2 : opt.http_msg.target;
1014
+ if (!ongoing[id]) {
1015
+ _context5.next = 14;
1016
+ break;
1017
+ }
1018
+ case 6:
1019
+ if (!ongoing[id]) {
1020
+ _context5.next = 11;
967
1021
  break;
968
1022
  }
969
- id = opt.http_msg.target;
970
- _context5.next = 7;
1023
+ _context5.next = 9;
1024
+ return (0, _utils.wait)(100);
1025
+ case 9:
1026
+ _context5.next = 6;
1027
+ break;
1028
+ case 11:
1029
+ return _context5.abrupt("return", id);
1030
+ case 14:
1031
+ ongoing[id] = true;
1032
+ _context5.next = 17;
971
1033
  return ar.httpmsg(opt.http_msg, id);
972
- case 7:
1034
+ case 17:
973
1035
  _yield$ar$httpmsg2 = _context5.sent;
974
1036
  owner = _yield$ar$httpmsg2.owner;
975
1037
  item = _yield$ar$httpmsg2.item;
976
- _context5.next = 12;
1038
+ _context5.next = 22;
977
1039
  return mem.get("env", opt.process);
978
- case 12:
1040
+ case 22:
979
1041
  _p = _context5.sent;
980
1042
  new_slot = opt.slot * 1;
981
1043
  last_slot = !_p ? -1 : _p.results.length - 1;
982
- if (!(last_slot + 1 !== new_slot)) {
983
- _context5.next = 20;
1044
+ if (!(last_slot + 1 < new_slot)) {
1045
+ _context5.next = 30;
984
1046
  break;
985
1047
  }
986
1048
  if (!(!hb || opt.recovery)) {
987
- _context5.next = 18;
1049
+ _context5.next = 28;
988
1050
  break;
989
1051
  }
990
1052
  return _context5.abrupt("return", null);
991
- case 18:
992
- _context5.next = 20;
1053
+ case 28:
1054
+ _context5.next = 30;
993
1055
  return _recover(opt.process);
994
- case 20:
995
- _context5.next = 25;
1056
+ case 30:
1057
+ _context5.next = 35;
996
1058
  break;
997
- case 22:
1059
+ case 32:
998
1060
  _id = (_opt$item$id = opt === null || opt === void 0 || (_opt$item = opt.item) === null || _opt$item === void 0 ? void 0 : _opt$item.id) !== null && _opt$item$id !== void 0 ? _opt$item$id : "";
999
1061
  _owner = (_opt$owner = opt.owner) !== null && _opt$owner !== void 0 ? _opt$owner : "";
1000
1062
  _item = opt.item;
1001
- case 25:
1002
- _context5.next = 27;
1063
+ case 35:
1064
+ _context5.next = 37;
1003
1065
  return mem.get("env", opt.process);
1004
- case 27:
1066
+ case 37:
1005
1067
  p = _context5.sent;
1006
1068
  if (p) {
1007
- _context5.next = 30;
1069
+ _context5.next = 40;
1008
1070
  break;
1009
1071
  }
1010
1072
  return _context5.abrupt("return", null);
1011
- case 30:
1073
+ case 40:
1012
1074
  if (!(!opt.item && opt.signer)) {
1013
- _context5.next = 65;
1075
+ _context5.next = 75;
1014
1076
  break;
1015
1077
  }
1016
1078
  opt.tags = (0, _utils.buildTags)(null, (0, _ramda.mergeLeft)((0, _utils.tags)((_opt$tags3 = opt.tags) !== null && _opt$tags3 !== void 0 ? _opt$tags3 : []), {
@@ -1020,7 +1082,7 @@ var _default = exports["default"] = function _default() {
1020
1082
  SDK: "aoconnect"
1021
1083
  }));
1022
1084
  if (!opt["for"]) {
1023
- _context5.next = 58;
1085
+ _context5.next = 68;
1024
1086
  break;
1025
1087
  }
1026
1088
  opt.tags.push({
@@ -1031,100 +1093,100 @@ var _default = exports["default"] = function _default() {
1031
1093
  name: "From-Process",
1032
1094
  value: opt.from
1033
1095
  });
1034
- _context5.next = 37;
1096
+ _context5.next = 47;
1035
1097
  return mem.getTx(opt.from);
1036
- case 37:
1037
- _context5.t2 = _yield$mem$getTx3 = _context5.sent;
1098
+ case 47:
1099
+ _context5.t2 = _yield$mem$getTx4 = _context5.sent;
1038
1100
  _context5.t1 = _context5.t2 === null;
1039
1101
  if (_context5.t1) {
1040
- _context5.next = 41;
1102
+ _context5.next = 51;
1041
1103
  break;
1042
1104
  }
1043
- _context5.t1 = _yield$mem$getTx3 === void 0;
1044
- case 41:
1105
+ _context5.t1 = _yield$mem$getTx4 === void 0;
1106
+ case 51:
1045
1107
  if (!_context5.t1) {
1046
- _context5.next = 45;
1108
+ _context5.next = 55;
1047
1109
  break;
1048
1110
  }
1049
1111
  _context5.t3 = void 0;
1050
- _context5.next = 46;
1112
+ _context5.next = 56;
1051
1113
  break;
1052
- case 45:
1053
- _context5.t3 = _yield$mem$getTx3.tags;
1054
- case 46:
1114
+ case 55:
1115
+ _context5.t3 = _yield$mem$getTx4.tags;
1116
+ case 56:
1055
1117
  _context5.t4 = _yield$mem$getTx$tags3 = _context5.t3;
1056
1118
  _context5.t0 = _context5.t4 !== null;
1057
1119
  if (!_context5.t0) {
1058
- _context5.next = 50;
1120
+ _context5.next = 60;
1059
1121
  break;
1060
1122
  }
1061
1123
  _context5.t0 = _yield$mem$getTx$tags3 !== void 0;
1062
- case 50:
1124
+ case 60:
1063
1125
  if (!_context5.t0) {
1064
- _context5.next = 54;
1126
+ _context5.next = 64;
1065
1127
  break;
1066
1128
  }
1067
1129
  _context5.t5 = _yield$mem$getTx$tags3;
1068
- _context5.next = 55;
1130
+ _context5.next = 65;
1069
1131
  break;
1070
- case 54:
1132
+ case 64:
1071
1133
  _context5.t5 = [];
1072
- case 55:
1134
+ case 65:
1073
1135
  pr = _context5.t5;
1074
1136
  module = (0, _utils.tags)(pr).Module;
1075
1137
  if (module) opt.tags.push({
1076
1138
  name: "From-Module",
1077
1139
  value: module
1078
1140
  });
1079
- case 58:
1141
+ case 68:
1080
1142
  ;
1081
- _context5.next = 61;
1143
+ _context5.next = 71;
1082
1144
  return ar.dataitem({
1083
1145
  data: opt.data,
1084
1146
  signer: opt.signer,
1085
1147
  tags: (0, _utils.tags)(opt.tags),
1086
1148
  target: opt.process
1087
1149
  });
1088
- case 61:
1150
+ case 71:
1089
1151
  _yield$ar$dataitem3 = _context5.sent;
1090
1152
  item = _yield$ar$dataitem3.item;
1091
1153
  id = _yield$ar$dataitem3.id;
1092
1154
  owner = _yield$ar$dataitem3.owner;
1093
- case 65:
1155
+ case 75:
1094
1156
  _msg = (0, _ramda.dissoc)("signer", opt);
1095
- _context5.next = 68;
1157
+ _context5.next = 78;
1096
1158
  return mem.set(_msg, "msgs", id);
1097
- case 68:
1159
+ case 78:
1098
1160
  if (!ar.isHttpMsg(opt.http_msg)) {
1099
- _context5.next = 123;
1161
+ _context5.next = 143;
1100
1162
  break;
1101
1163
  }
1102
1164
  p.epochs.push([id]);
1103
1165
  _opt = opt;
1104
- _context5.prev = 71;
1166
+ _context5.prev = 81;
1105
1167
  // todo: not sure if this is correct
1106
1168
  from = (_ref12 = (_opt$from2 = _opt.from) !== null && _opt$from2 !== void 0 ? _opt$from2 : opt.from) !== null && _ref12 !== void 0 ? _ref12 : owner;
1107
1169
  data = (_opt$http_msg$data = opt.http_msg.data) !== null && _opt$http_msg$data !== void 0 ? _opt$http_msg$data : "";
1108
1170
  _tags = _opt.http_msg.tags; // todo: check if owner=mu.addr right?
1109
- _context5.next = 77;
1171
+ _context5.next = 87;
1110
1172
  return genMsg(opt.http_msg, p, data, _tags, from, owner);
1111
- case 77:
1173
+ case 87:
1112
1174
  msg = _context5.sent;
1113
- _context5.next = 80;
1175
+ _context5.next = 90;
1114
1176
  return genEnv({
1115
1177
  pid: p.id,
1116
1178
  owner: p.owner,
1117
1179
  module: p.module
1118
1180
  });
1119
- case 80:
1181
+ case 90:
1120
1182
  _env = _context5.sent;
1121
1183
  if (p.handle) {
1122
- _context5.next = 104;
1184
+ _context5.next = 123;
1123
1185
  break;
1124
1186
  }
1125
- _context5.next = 84;
1187
+ _context5.next = 94;
1126
1188
  return mem.getWasm(p.modulea);
1127
- case 84:
1189
+ case 94:
1128
1190
  _yield$mem$getWasm3 = _context5.sent;
1129
1191
  format = _yield$mem$getWasm3.format;
1130
1192
  mod = _yield$mem$getWasm3.mod;
@@ -1134,52 +1196,75 @@ var _default = exports["default"] = function _default() {
1134
1196
  _context5.t7 = wasm;
1135
1197
  _context5.t8 = format;
1136
1198
  _context5.t9 = wdrive;
1137
- _context5.next = 95;
1199
+ _context5.next = 105;
1138
1200
  return mem.getTx(p.id);
1139
- case 95:
1140
- _context5.t10 = _context5.sent.item;
1141
- _context5.next = 98;
1201
+ case 105:
1202
+ _context5.t11 = _yield$mem$getTx5 = _context5.sent;
1203
+ _context5.t10 = _context5.t11 === null;
1204
+ if (_context5.t10) {
1205
+ _context5.next = 109;
1206
+ break;
1207
+ }
1208
+ _context5.t10 = _yield$mem$getTx5 === void 0;
1209
+ case 109:
1210
+ if (!_context5.t10) {
1211
+ _context5.next = 113;
1212
+ break;
1213
+ }
1214
+ _context5.t12 = void 0;
1215
+ _context5.next = 114;
1216
+ break;
1217
+ case 113:
1218
+ _context5.t12 = _yield$mem$getTx5.item;
1219
+ case 114:
1220
+ _context5.t13 = _context5.t12;
1221
+ _context5.next = 117;
1142
1222
  return mem.getTx(mod);
1143
- case 98:
1144
- _context5.t11 = _context5.sent;
1145
- _context5.t12 = {
1223
+ case 117:
1224
+ _context5.t14 = _context5.sent;
1225
+ _context5.t15 = {
1146
1226
  format: _context5.t8,
1147
1227
  WeaveDrive: _context5.t9,
1148
- spawn: _context5.t10,
1149
- module: _context5.t11
1228
+ spawn: _context5.t13,
1229
+ module: _context5.t14
1150
1230
  };
1151
- _context5.next = 102;
1152
- return (0, _context5.t6)(_context5.t7, _context5.t12);
1153
- case 102:
1231
+ _context5.next = 121;
1232
+ return (0, _context5.t6)(_context5.t7, _context5.t15);
1233
+ case 121:
1154
1234
  p.handle = _context5.sent;
1155
1235
  mem.env[opt.process].handle = p.handle;
1156
- case 104:
1157
- _context5.next = 106;
1236
+ case 123:
1237
+ if (p.compressed) {
1238
+ start = Date.now();
1239
+ p.memory = mem.waosm.decompress(p.memory, p.original_size);
1240
+ p.compressed = false;
1241
+ }
1242
+ _context5.next = 126;
1158
1243
  return p.handle(p.memory, msg, _env);
1159
- case 106:
1244
+ case 126:
1160
1245
  res = _context5.sent;
1161
1246
  p.memory = res.Memory;
1162
1247
  delete res.Memory;
1163
1248
  p.results.push(id);
1164
- _context5.next = 112;
1249
+ _context5.next = 132;
1165
1250
  return mem.set(p, "env", opt.process);
1166
- case 112:
1251
+ case 132:
1167
1252
  _msg2 = _objectSpread(_objectSpread({}, (0, _ramda.dissoc)("signer", _opt)), {}, {
1168
1253
  res: res
1169
1254
  });
1170
- _context5.next = 115;
1255
+ _context5.next = 135;
1171
1256
  return mem.set(_msg2, "msgs", id);
1172
- case 115:
1257
+ case 135:
1173
1258
  return _context5.abrupt("return", id);
1174
- case 118:
1175
- _context5.prev = 118;
1176
- _context5.t13 = _context5["catch"](71);
1177
- console.log(_context5.t13);
1178
- case 121:
1179
- _context5.next = 125;
1259
+ case 138:
1260
+ _context5.prev = 138;
1261
+ _context5.t16 = _context5["catch"](81);
1262
+ console.log(_context5.t16);
1263
+ case 141:
1264
+ _context5.next = 145;
1180
1265
  break;
1181
- case 123:
1182
- _context5.next = 125;
1266
+ case 143:
1267
+ _context5.next = 145;
1183
1268
  return _assign({
1184
1269
  message_item: item,
1185
1270
  message: id,
@@ -1187,13 +1272,14 @@ var _default = exports["default"] = function _default() {
1187
1272
  from: owner,
1188
1273
  signer: mu.signer
1189
1274
  });
1190
- case 125:
1275
+ case 145:
1276
+ delete ongoing[id];
1191
1277
  return _context5.abrupt("return", id);
1192
- case 126:
1278
+ case 147:
1193
1279
  case "end":
1194
1280
  return _context5.stop();
1195
1281
  }
1196
- }, _callee5, null, [[71, 118]]);
1282
+ }, _callee5, null, [[81, 138]]);
1197
1283
  }));
1198
1284
  return function message(_x9) {
1199
1285
  return _ref11.apply(this, arguments);
@@ -1311,6 +1397,7 @@ var _default = exports["default"] = function _default() {
1311
1397
  }
1312
1398
  _context6.next = 52;
1313
1399
  return spawn({
1400
+ id: v.node.message.Id,
1314
1401
  http_msg: item,
1315
1402
  scheduler: _tags.Scheduler,
1316
1403
  module: _tags.Module,
@@ -1323,6 +1410,7 @@ var _default = exports["default"] = function _default() {
1323
1410
  case 54:
1324
1411
  _context6.next = 56;
1325
1412
  return message({
1413
+ id: v.node.message.Id,
1326
1414
  process: pid,
1327
1415
  http_msg: item,
1328
1416
  slot: v.cursor,
@@ -1585,8 +1673,8 @@ var _default = exports["default"] = function _default() {
1585
1673
  }(),
1586
1674
  dryrun: function () {
1587
1675
  var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(opt) {
1588
- var _opt$id, _opt$owner2;
1589
- var p, id, owner, _yield$ar$dataitem4, _opt$data3, cloneMemory, msg, _env, _yield$mem$getWasm4, format, mod, wasm, wdrive, res;
1676
+ var _opt$id3, _opt$owner2;
1677
+ var p, id, owner, _yield$ar$dataitem4, _opt$data3, cloneMemory, msg, _env, _yield$mem$getWasm4, format, mod, wasm, wdrive, start, res;
1590
1678
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1591
1679
  while (1) switch (_context12.prev = _context12.next) {
1592
1680
  case 0:
@@ -1600,7 +1688,7 @@ var _default = exports["default"] = function _default() {
1600
1688
  }
1601
1689
  return _context12.abrupt("return", null);
1602
1690
  case 5:
1603
- id = (_opt$id = opt.id) !== null && _opt$id !== void 0 ? _opt$id : "";
1691
+ id = (_opt$id3 = opt.id) !== null && _opt$id3 !== void 0 ? _opt$id3 : "";
1604
1692
  owner = (_opt$owner2 = opt.owner) !== null && _opt$owner2 !== void 0 ? _opt$owner2 : mu.addr;
1605
1693
  if (!(!opt.id && opt.signer)) {
1606
1694
  _context12.next = 14;
@@ -1673,23 +1761,28 @@ var _default = exports["default"] = function _default() {
1673
1761
  p.handle = _context12.sent;
1674
1762
  mem.env[opt.process].handle = p.handle;
1675
1763
  case 45:
1676
- _context12.next = 47;
1764
+ if (p.compressed) {
1765
+ start = Date.now();
1766
+ p.memory = mem.waosm.decompress(p.memory, p.original_size);
1767
+ p.compressed = false;
1768
+ }
1769
+ _context12.next = 48;
1677
1770
  return p.handle(p.memory, msg, _env);
1678
- case 47:
1771
+ case 48:
1679
1772
  res = _context12.sent;
1680
1773
  delete res.Memory;
1681
1774
  return _context12.abrupt("return", res);
1682
- case 52:
1683
- _context12.prev = 52;
1775
+ case 53:
1776
+ _context12.prev = 53;
1684
1777
  _context12.t7 = _context12["catch"](14);
1685
1778
  console.log(_context12.t7);
1686
- case 55:
1687
- return _context12.abrupt("return", null);
1688
1779
  case 56:
1780
+ return _context12.abrupt("return", null);
1781
+ case 57:
1689
1782
  case "end":
1690
1783
  return _context12.stop();
1691
1784
  }
1692
- }, _callee12, null, [[14, 52]]);
1785
+ }, _callee12, null, [[14, 53]]);
1693
1786
  }));
1694
1787
  function dryrun(_x16) {
1695
1788
  return _dryrun.apply(this, arguments);
package/cjs/armem-base.js CHANGED
@@ -396,7 +396,8 @@ var ArMemBase = exports["default"] = /*#__PURE__*/function () {
396
396
  v3 = _context5.sent;
397
397
  if ((0, _ramda.is)(Uint8Array, v3.memory)) {
398
398
  try {
399
- v3.memory = this.waosm.decompress(v3.memory, v3.original_size);
399
+ v3.compressed = true;
400
+ //v3.memory = this.waosm.decompress(v3.memory, v3.original_size)
400
401
  } catch (e) {
401
402
  console.log(e);
402
403
  v3.memory = (0, _compress.decompress)(v3.memory);
@@ -27,6 +27,8 @@ import {
27
27
  } from "ramda"
28
28
 
29
29
  let onRecovery = {}
30
+ let ongoing = {}
31
+
30
32
  export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
31
33
  return (mem, { cache, log = false, extensions = {}, hb } = {}) => {
32
34
  const isMem = mem?.__type__ === "mem"
@@ -110,11 +112,17 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
110
112
  let id, owner, item, __tags
111
113
  let msg_owner = mu.addr
112
114
  if (ar.isHttpMsg(opt.http_msg)) {
113
- id = opt.http_msg.target
114
- ;({ owner, item, tags: __tags } = await ar.httpmsg(opt.http_msg, id))
115
- opt.tags = buildTags(null, __tags)
116
- opt.data = opt.http_msg.data
117
- msg_owner = owner
115
+ id = opt.id ?? opt.http_msg.target
116
+ if (ongoing[id]) {
117
+ while (ongoing[id]) await wait(100)
118
+ return id
119
+ } else {
120
+ ongoing[id] = true
121
+ ;({ owner, item, tags: __tags } = await ar.httpmsg(opt.http_msg, id))
122
+ opt.tags = buildTags(null, __tags)
123
+ opt.data = opt.http_msg.data
124
+ msg_owner = owner
125
+ }
118
126
  } else {
119
127
  opt.tags = buildTags(
120
128
  null,
@@ -318,11 +326,16 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
318
326
  p.handle = await AoLoader(wasm, {
319
327
  format,
320
328
  WeaveDrive: wdrive,
321
- spawn: (await mem.getTx(p.id)).item,
329
+ spawn: (await mem.getTx(p.id))?.item,
322
330
  module: await mem.getTx(mod),
323
331
  })
324
332
  mem.env[opt.process].handle = p.handle
325
333
  }
334
+ if (p.compressed) {
335
+ const start = Date.now()
336
+ p.memory = mem.waosm.decompress(p.memory, p.original_size)
337
+ p.compressed = false
338
+ }
326
339
  const res = await p.handle(p.memory, msg, _env)
327
340
  p.memory = res.Memory
328
341
  delete res.Memory
@@ -376,15 +389,21 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
376
389
  let owner = ""
377
390
  let item = null
378
391
  if (ar.isHttpMsg(opt.http_msg)) {
379
- id = opt.http_msg.target
380
- ;({ owner, item } = await ar.httpmsg(opt.http_msg, id))
381
- // check if process exists, and recover if necessary
382
- const p = await mem.get("env", opt.process)
383
- const new_slot = opt.slot * 1
384
- const last_slot = !p ? -1 : p.results.length - 1
385
- if (last_slot + 1 !== new_slot) {
386
- if (!hb || opt.recovery) return null
387
- await recover(opt.process)
392
+ id = opt.id ?? opt.http_msg.target
393
+ if (ongoing[id]) {
394
+ while (ongoing[id]) await wait(100)
395
+ return id
396
+ } else {
397
+ ongoing[id] = true
398
+ ;({ owner, item } = await ar.httpmsg(opt.http_msg, id))
399
+ // check if process exists, and recover if necessary
400
+ const p = await mem.get("env", opt.process)
401
+ const new_slot = opt.slot * 1
402
+ const last_slot = !p ? -1 : p.results.length - 1
403
+ if (last_slot + 1 < new_slot) {
404
+ if (!hb || opt.recovery) return null
405
+ await recover(opt.process)
406
+ }
388
407
  }
389
408
  } else {
390
409
  let id = opt?.item?.id ?? ""
@@ -394,7 +413,6 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
394
413
 
395
414
  const p = await mem.get("env", opt.process)
396
415
  if (!p) return null
397
-
398
416
  if (!opt.item && opt.signer) {
399
417
  opt.tags = buildTags(
400
418
  null,
@@ -442,11 +460,16 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
442
460
  p.handle = await AoLoader(wasm, {
443
461
  format,
444
462
  WeaveDrive: wdrive,
445
- spawn: (await mem.getTx(p.id)).item,
463
+ spawn: (await mem.getTx(p.id))?.item,
446
464
  module: await mem.getTx(mod),
447
465
  })
448
466
  mem.env[opt.process].handle = p.handle
449
467
  }
468
+ if (p.compressed) {
469
+ const start = Date.now()
470
+ p.memory = mem.waosm.decompress(p.memory, p.original_size)
471
+ p.compressed = false
472
+ }
450
473
  const res = await p.handle(p.memory, msg, _env)
451
474
  p.memory = res.Memory
452
475
  delete res.Memory
@@ -467,6 +490,7 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
467
490
  signer: mu.signer,
468
491
  })
469
492
  }
493
+ delete ongoing[id]
470
494
  return id
471
495
  }
472
496
  const recover = async (pid, next) => {
@@ -513,6 +537,7 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
513
537
  let _tags = tags(item.tags)
514
538
  if (_tags.Type === "Process") {
515
539
  await spawn({
540
+ id: v.node.message.Id,
516
541
  http_msg: item,
517
542
  scheduler: _tags.Scheduler,
518
543
  module: _tags.Module,
@@ -521,6 +546,7 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
521
546
  })
522
547
  } else {
523
548
  await message({
549
+ id: v.node.message.Id,
524
550
  process: pid,
525
551
  http_msg: item,
526
552
  slot: v.cursor,
@@ -540,7 +566,9 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
540
566
  return { recovered: count, pid, success }
541
567
  }
542
568
 
543
- const result = async opt => (await mem.get("msgs", opt.message))?.res
569
+ const result = async opt => {
570
+ return (await mem.get("msgs", opt.message))?.res
571
+ }
544
572
 
545
573
  return {
546
574
  message,
@@ -630,6 +658,11 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
630
658
  })
631
659
  mem.env[opt.process].handle = p.handle
632
660
  }
661
+ if (p.compressed) {
662
+ const start = Date.now()
663
+ p.memory = mem.waosm.decompress(p.memory, p.original_size)
664
+ p.compressed = false
665
+ }
633
666
  const res = await p.handle(p.memory, msg, _env)
634
667
  delete res.Memory
635
668
  return res
package/esm/armem-base.js CHANGED
@@ -199,7 +199,8 @@ export default class ArMemBase {
199
199
  let v3 = await this.db.get(v2)
200
200
  if (is(Uint8Array, v3.memory)) {
201
201
  try {
202
- v3.memory = this.waosm.decompress(v3.memory, v3.original_size)
202
+ v3.compressed = true
203
+ //v3.memory = this.waosm.decompress(v3.memory, v3.original_size)
203
204
  } catch (e) {
204
205
  console.log(e)
205
206
  v3.memory = decompress(v3.memory)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.14.1",
3
+ "version": "0.14.3",
4
4
  "bin": {
5
5
  "wao": "./cjs/cli.js",
6
6
  "wao-esm": "./esm/cli.js"