Skip to content

Commit

Permalink
fix: move ZERO_SNAPSHOT to ssz
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Sep 9, 2024
1 parent 60bcdac commit d1b38f4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 0 additions & 6 deletions packages/persistent-merkle-tree/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ type Snapshot = {
count: number;
};

export const ZERO_SNAPSHOT = {
finalized: [],
root: zeroNode(0).root,
count: 0,
};

/**
* Given a tree, return a snapshot of the tree with the root, finalized nodes, and count.
* Tree could be full tree, or partial tree. See https://github.com/ChainSafe/ssz/issues/293
Expand Down
8 changes: 8 additions & 0 deletions packages/ssz/src/util/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import {zeroNode} from "@chainsafe/persistent-merkle-tree";

export type Require<T, K extends keyof T> = T & Required<Pick<T, K>>;

export type Snapshot = {
finalized: Uint8Array[];
root: Uint8Array;
count: number;
};

export const ZERO_SNAPSHOT = {
finalized: [],
root: zeroNode(0).root,
count: 0,
};
4 changes: 2 additions & 2 deletions packages/ssz/src/viewDU/partialListComposite.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Node, zeroNode, subtreeFillToContents, getNodesAtDepth, ZERO_SNAPSHOT} from "@chainsafe/persistent-merkle-tree";
import {Node, zeroNode, subtreeFillToContents, getNodesAtDepth} from "@chainsafe/persistent-merkle-tree";
import {ValueOf} from "../type/abstract";
import {CompositeType, CompositeView, CompositeViewDU} from "../type/composite";
import {ArrayCompositeTreeViewDUCache} from "./arrayComposite";
import {ListCompositeTreeViewDU} from "./listComposite";
import {PartialListCompositeType} from "../type/partialListComposite";
import {Snapshot} from "../util/types";
import {Snapshot, ZERO_SNAPSHOT} from "../util/types";

/**
* Similar to ListCompositeTreeViewDU but this is created from a snapshot so some methods are not supported
Expand Down

0 comments on commit d1b38f4

Please sign in to comment.