graph-update: fix add-graph

This commit is contained in:
Liam Fitzgerald 2021-04-27 11:34:05 +10:00
parent 9304409e8b
commit 19f9dd6009
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB

View File

@ -52,23 +52,18 @@ const keys = (json, state: GraphState): GraphState => {
const processNode = (node) => { const processNode = (node) => {
// is empty // is empty
if (!node.children) { if (!node.children) {
node.children = new BigIntOrderedMap(); return produce(node, draft => {
return node; draft.children = new BigIntOrderedMap();
});
} }
// is graph // is graph
let converted = new BigIntOrderedMap(); return produce(node, draft => {
for (let idx in node.children) { draft.children = new BigIntOrderedMap()
let item = node.children[idx]; .gas(_.map(draft.children, (item, idx) =>
let index = bigInt(idx); [bigInt(idx), processNode(item)] as [BigInteger, any]
));
converted.set( });
index,
processNode(item)
);
}
node.children = converted;
return node;
}; };
@ -89,6 +84,7 @@ const addGraph = (json, state: GraphState): GraphState => {
state.graphs[resource] = state.graphs[resource].gas(Object.keys(data.graph).map(idx => { state.graphs[resource] = state.graphs[resource].gas(Object.keys(data.graph).map(idx => {
return [bigInt(idx), processNode(data.graph[idx])]; return [bigInt(idx), processNode(data.graph[idx])];
})); }));
state.graphKeys.add(resource); state.graphKeys.add(resource);
} }
return state; return state;