예제 #1
0
        public IActionResult UpdateGraphState([FromBody] Graph graph)
        {
            var graphContext = GraphsContainer.GetRunningGraphByHash(graph.UniqueHash);

            if (graphContext == null)
            {
                return(Ok(new { success = false, message = string.Format("Graph {0} not loaded in the GraphLinq engine", graph.UniqueHash) }));
            }

            GraphsContainer.UpdateStorageStateGraph(graphContext, graph.DeployedState);
            if (graph.DeployedState == Enums.GraphStateEnum.STARTING || graph.DeployedState == Enums.GraphStateEnum.RESTARTING)
            {
                var decompressedRaw = GraphCompression.DecompressGraphData(graphContext.graph.CompressedRaw);
                var reloadedGraph   = BlockGraph.LoadGraph(decompressedRaw, graph.UniqueHash, graphContext.graph.CompressedRaw);

                GraphsContainer.AddNewGraph(reloadedGraph, graphContext.graph.currentContext.walletIdentifier, graph.DeployedState);
            }
            return(Ok(new { success = true }));
        }
예제 #2
0
        public async Task <BlockGraph> InitGraph(Graph graph)
        {
            return(await Task.Run(() =>
            {
                try
                {
                    var hash = graph.UniqueHash ?? GraphCompression.GetUniqueGraphHash(graph.WalletIdentifier, graph.RawBytes);
                    var decompressedRaw = GraphCompression.DecompressGraphData(graph.RawBytes);
                    var loadedGraph = BlockGraph.LoadGraph(decompressedRaw, hash, graph.RawBytes);
                    loadedGraph.Debug = graph.Debug;

                    return loadedGraph;
                }
                catch (Exception error)
                {
                    logger.Error(error);
                    return null;
                }
            }));
        }