コード例 #1
0
        public void VisitExtension(TrieNode node, TrieVisitContext trieVisitContext)
        {
            AddProofItem(node, trieVisitContext);
            _nodeToVisitFilter.Remove(node.Keccak);

            Keccak childHash = node.GetChildHash(0);

            if (trieVisitContext.IsStorage)
            {
                _storageNodeInfos[childHash]           = new StorageNodeInfo();
                _storageNodeInfos[childHash].PathIndex = _pathTraversalIndex + node.Path.Length;

                foreach (int storageIndex in _storageNodeInfos[node.Keccak].StorageIndices)
                {
                    bool isPathMatched = IsPathMatched(node, _fullStoragePaths[storageIndex]);
                    if (isPathMatched)
                    {
                        _storageNodeInfos[childHash].StorageIndices.Add(storageIndex);
                        _nodeToVisitFilter.Add(childHash); // always accept so can optimize
                    }
                }
            }

            if (IsPathMatched(node, _fullAccountPath))
            {
                _nodeToVisitFilter.Add(childHash); // always accept so can optimize
                _pathTraversalIndex += node.Path.Length;
            }
        }
コード例 #2
0
        // -------------------------------------------------------
        // 保存 删除
        // -------------------------------------------------------

        #region 函数:Save(XmlDocument doc)
        /// <summary>保存记录</summary>
        /// <param name="doc">Xml 文档对象</param>
        /// <returns>返回操作结果</returns>
        public string Save(XmlDocument doc)
        {
            StorageNodeInfo param = new StorageNodeInfo();

            param = (StorageNodeInfo)AjaxUtil.Deserialize(param, doc);

            this.service.Save(param);

            return(MessageObject.Stringify("0", I18n.Strings["msg_save_success"]));
        }
コード例 #3
0
        /// <summary>创建新的对象</summary>
        /// <param name="doc">Xml 文档对象</param>
        /// <returns>返回操作结果</returns>
        public string CreateNewObject(XmlDocument doc)
        {
            StringBuilder outString = new StringBuilder();

            StorageNodeInfo param = new StorageNodeInfo();

            param.Id = DigitalNumberContext.Generate("Key_Guid");

            param.Status = 1;

            param.UpdateDate = param.CreateDate = DateTime.Now;

            outString.Append("{\"data\":" + AjaxUtil.Parse <IStorageNode>(param) + ",");

            outString.Append(MessageObject.Stringify("0", I18n.Strings["msg_create_success"], true) + "}");

            return(outString.ToString());
        }
コード例 #4
0
        public void VisitBranch(TrieNode node, TrieVisitContext trieVisitContext)
        {
            AddProofItem(node, trieVisitContext);
            _nodeToVisitFilter.Remove(node.Keccak);

            if (trieVisitContext.IsStorage)
            {
                HashSet <int> bumpedIndexes = new HashSet <int>();
                foreach (int storageIndex in _storageNodeInfos[node.Keccak].StorageIndices)
                {
                    Nibble childIndex = _fullStoragePaths[storageIndex][_pathTraversalIndex];
                    Keccak childHash  = node.GetChildHash((byte)childIndex);
                    if (childHash == null)
                    {
                        Console.WriteLine($"Empty at {storageIndex}");

                        AddEmpty(node, trieVisitContext);
                    }
                    else
                    {
                        if (!_storageNodeInfos.ContainsKey(childHash))
                        {
                            _storageNodeInfos[childHash] = new StorageNodeInfo();
                        }

                        if (!bumpedIndexes.Contains((byte)childIndex))
                        {
                            bumpedIndexes.Add((byte)childIndex);
                            _storageNodeInfos[childHash].PathIndex = _pathTraversalIndex + 1;
                        }

                        _storageNodeInfos[childHash].StorageIndices.Add(storageIndex);
                        _nodeToVisitFilter.Add(childHash);
                    }
                }
            }
            else
            {
                _nodeToVisitFilter.Add(node.GetChildHash((byte)_fullAccountPath[_pathTraversalIndex]));
            }

            _pathTraversalIndex++;
        }