@lodestar/state-transition 1.35.0-dev.91dadf81de → 1.35.0-dev.98d359db41

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.
@@ -4,4 +4,5 @@ export declare function getSlotsSinceGenesis(config: ChainConfig, genesisTime: T
4
4
  export declare function getCurrentSlot(config: ChainConfig, genesisTime: TimeSeconds): Slot;
5
5
  export declare function computeSlotsSinceEpochStart(slot: Slot, epoch?: Epoch): Slot;
6
6
  export declare function computeTimeAtSlot(config: ChainConfig, slot: Slot, genesisTime: TimeSeconds): TimeSeconds;
7
+ export declare function getCurrentInterval(config: ChainConfig, secondsIntoSlot: number): number;
7
8
  //# sourceMappingURL=slot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../../src/util/slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAC,KAAK,EAAE,IAAI,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAGzD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAGxF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAElF;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAG3E;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,GAAG,WAAW,CAExG"}
1
+ {"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../../src/util/slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAC,KAAK,EAAE,IAAI,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAGzD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAGxF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAElF;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAG3E;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,GAAG,WAAW,CAExG;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAGvF"}
package/lib/util/slot.js CHANGED
@@ -1,4 +1,4 @@
1
- import { GENESIS_SLOT } from "@lodestar/params";
1
+ import { GENESIS_SLOT, INTERVALS_PER_SLOT } from "@lodestar/params";
2
2
  import { computeEpochAtSlot, computeStartSlotAtEpoch } from "./epoch.js";
3
3
  export function getSlotsSinceGenesis(config, genesisTime) {
4
4
  const diffInSeconds = Date.now() / 1000 - genesisTime;
@@ -14,4 +14,8 @@ export function computeSlotsSinceEpochStart(slot, epoch) {
14
14
  export function computeTimeAtSlot(config, slot, genesisTime) {
15
15
  return genesisTime + slot * config.SECONDS_PER_SLOT;
16
16
  }
17
+ export function getCurrentInterval(config, secondsIntoSlot) {
18
+ const timePerInterval = Math.floor(config.SECONDS_PER_SLOT / INTERVALS_PER_SLOT);
19
+ return Math.floor(secondsIntoSlot / timePerInterval);
20
+ }
17
21
  //# sourceMappingURL=slot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"slot.js","sourceRoot":"","sources":["../../src/util/slot.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,kBAAkB,EAAE,uBAAuB,EAAC,MAAM,YAAY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;AAClE,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,IAAU,EAAE,KAAa;IACnE,MAAM,YAAY,GAAG,KAAK,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACvD,OAAO,IAAI,GAAG,uBAAuB,CAAC,YAAY,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAmB,EAAE,IAAU,EAAE,WAAwB;IACzF,OAAO,WAAW,GAAG,IAAI,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAmB,EAAE,eAAuB;IAC7E,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,gBAAgB,GAAG,kBAAkB,CAAC,CAAC;IACjF,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,eAAe,CAAC,CAAC;AACvD,CAAC"}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "bugs": {
12
12
  "url": "https://github.com/ChainSafe/lodestar/issues"
13
13
  },
14
- "version": "1.35.0-dev.91dadf81de",
14
+ "version": "1.35.0-dev.98d359db41",
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
@@ -67,10 +67,10 @@
67
67
  "@chainsafe/pubkey-index-map": "^3.0.0",
68
68
  "@chainsafe/ssz": "^1.2.2",
69
69
  "@chainsafe/swap-or-not-shuffle": "^1.2.1",
70
- "@lodestar/config": "1.35.0-dev.91dadf81de",
71
- "@lodestar/params": "1.35.0-dev.91dadf81de",
72
- "@lodestar/types": "1.35.0-dev.91dadf81de",
73
- "@lodestar/utils": "1.35.0-dev.91dadf81de",
70
+ "@lodestar/config": "1.35.0-dev.98d359db41",
71
+ "@lodestar/params": "1.35.0-dev.98d359db41",
72
+ "@lodestar/types": "1.35.0-dev.98d359db41",
73
+ "@lodestar/utils": "1.35.0-dev.98d359db41",
74
74
  "bigint-buffer": "^1.1.5"
75
75
  },
76
76
  "keywords": [
@@ -79,5 +79,5 @@
79
79
  "beacon",
80
80
  "blockchain"
81
81
  ],
82
- "gitHead": "7adab90fbdd05bff1005342660de37c56c8aa538"
82
+ "gitHead": "8b90f83d313e2dd3e7584faaa70269fe570fad25"
83
83
  }
package/src/util/slot.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import {ChainConfig} from "@lodestar/config";
2
- import {GENESIS_SLOT} from "@lodestar/params";
2
+ import {GENESIS_SLOT, INTERVALS_PER_SLOT} from "@lodestar/params";
3
3
  import {Epoch, Slot, TimeSeconds} from "@lodestar/types";
4
4
  import {computeEpochAtSlot, computeStartSlotAtEpoch} from "./epoch.js";
5
5
 
@@ -20,3 +20,8 @@ export function computeSlotsSinceEpochStart(slot: Slot, epoch?: Epoch): Slot {
20
20
  export function computeTimeAtSlot(config: ChainConfig, slot: Slot, genesisTime: TimeSeconds): TimeSeconds {
21
21
  return genesisTime + slot * config.SECONDS_PER_SLOT;
22
22
  }
23
+
24
+ export function getCurrentInterval(config: ChainConfig, secondsIntoSlot: number): number {
25
+ const timePerInterval = Math.floor(config.SECONDS_PER_SLOT / INTERVALS_PER_SLOT);
26
+ return Math.floor(secondsIntoSlot / timePerInterval);
27
+ }