Skip to content

Commit

Permalink
Use pubkey2index directly
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion authored Jun 15, 2021
1 parent b83c681 commit b01bcb6
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,29 +277,25 @@ export const CachedBeaconStateProxyHandler: ProxyHandler<CachedBeaconState<allFo
} else {
if (isTreeBacked(value)) {
if (key === "currentSyncCommittee") {
const {pubkey2index} = target.epochCtx;
target.currentSyncCommittee = convertToIndexedSyncCommittee(
(value as unknown) as TreeBacked<altair.SyncCommittee>,
pubkey2index
target.epochCtx.pubkey2index
);
} else if (key === "nextSyncCommittee") {
const {pubkey2index} = target.epochCtx;
target.nextSyncCommittee = convertToIndexedSyncCommittee(
(value as unknown) as TreeBacked<altair.SyncCommittee>,
pubkey2index
target.epochCtx.pubkey2index
);
}
return target.type.tree_setProperty(target.tree, key, value.tree);
} else {
if (key === "currentSyncCommittee") {
const {pubkey2index} = target.epochCtx;
const treeBackedValue = ssz.altair.SyncCommittee.createTreeBackedFromStruct(value as altair.SyncCommittee);
target.currentSyncCommittee = convertToIndexedSyncCommittee(treeBackedValue, pubkey2index);
target.currentSyncCommittee = convertToIndexedSyncCommittee(treeBackedValue, target.epochCtx.pubkey2index);
return target.type.tree_setProperty(target.tree, key, treeBackedValue.tree);
} else if (key === "nextSyncCommittee") {
const {pubkey2index} = target.epochCtx;
const treeBackedValue = ssz.altair.SyncCommittee.createTreeBackedFromStruct(value as altair.SyncCommittee);
target.nextSyncCommittee = convertToIndexedSyncCommittee(treeBackedValue, pubkey2index);
target.nextSyncCommittee = convertToIndexedSyncCommittee(treeBackedValue, target.epochCtx.pubkey2index);
return target.type.tree_setProperty(target.tree, key, treeBackedValue.tree);
}
return target.type.tree_setProperty(
Expand Down

0 comments on commit b01bcb6

Please sign in to comment.