예제 #1
0
 public void Add(T nodeId)
 {
     if (store.ContainsKey(nodeId))
     {
         return;
     }
     AddNode(nodeId);
 }
예제 #2
0
        public bool ContainsBlock(Hash hash)
        {
            if (hash == null)
            {
                return(false);
            }

            return(_blocks.ContainsKey(hash));
        }
예제 #3
0
        public Archive FindArchive(Hash hash)
        {
            if (_archiveEntries.ContainsKey(hash))
            {
                return(_archiveEntries.Get(hash));
            }

            return(null);
        }
예제 #4
0
        public void TestDBStorageContains()
        {
            _testStorage.Set("test1", "Value11");
            bool result = _testStorage.ContainsKey("test1");

            Assert.IsTrue(result);
        }
예제 #5
0
        public bool DeleteArchive(Archive archive)
        {
            Throw.IfNull(archive, nameof(archive));

            for (int i = 0; i < archive.BlockCount; i++)
            {
                var blockHash = archive.MerkleTree.GetHash(i);
                if (_archiveContents.ContainsKey(blockHash))
                {
                    _archiveContents.Remove(blockHash);
                }
            }

            _archiveEntries.Remove(archive.Hash);

            return(true);
        }
예제 #6
0
        public Block FindBlockByHeight(BigInteger height)
        {
            if (_blockHeightMap.ContainsKey(height))
            {
                var hash = _blockHeightMap[height];
                return(FindBlockByHash(hash));
            }

            return(null); // TODO Should thrown an exception?
        }
예제 #7
0
        public Block FindTransactionBlock(Hash hash)
        {
            if (_transactionBlockMap.ContainsKey(hash))
            {
                var blockHash = _transactionBlockMap[hash];
                return(FindBlockByHash(blockHash));
            }

            return(null);
        }
예제 #8
0
        private string LookUpChainNameByAddress(Address address)
        {
            var key = ChainAddressMapKey + address.Text;

            if (_vars.ContainsKey(key))
            {
                var bytes = _vars.Get(key);
                return(Encoding.UTF8.GetString(bytes));
            }

            return(null);
        }
예제 #9
0
 public void SetUp(RawlerBase rawler)
 {
     if (string.IsNullOrEmpty(this.ConsumerKey) || string.IsNullOrEmpty(this.ConsumerSecret))
     {
         if (KeyValueStore.ContainsKey(rawler, "ConsumerKey", "ConsumerSecret"))
         {
             this.ConsumerKey    = KeyValueStore.GetValueByKey(rawler, "ConsumerKey");
             this.ConsumerSecret = KeyValueStore.GetValueByKey(rawler, "ConsumerSecret");
             ReportManage.Report(rawler, "KeyValueStoreからのAPI Keyを使います", true, true);
         }
         else if (string.IsNullOrEmpty(SetTwitterApiKeys.consumerKey) || string.IsNullOrEmpty(SetTwitterApiKeys.consumerSecret))
         {
             this.ConsumerKey    = "gHVupgapEXlTZdu7rf3oOg";
             this.ConsumerSecret = "YOicLtW8utx3NJyy88wtzq8QN3ilXeQoEGCPIJNzo";
             ReportManage.Report(rawler, "RawlerのAPI Keyを使います", true, true);
         }
         else
         {
             this.ConsumerKey    = SetTwitterApiKeys.consumerKey;
             this.ConsumerSecret = SetTwitterApiKeys.consumerSecret;
         }
     }
 }
예제 #10
0
        public SpookOracle(Spook cli, Nexus nexus, Logger logger) : base(nexus)
        {
            this._cli = cli;
            nexus.Attach(this);
            platforms   = new KeyValueStore <string, string>(CreateKeyStoreAdapter(StorageConst.Platform.ToString()));
            this.logger = logger;

            logger.Message("Platform count: " + platforms.Count);

            var nexusPlatforms = (nexus as Nexus).GetPlatforms(nexus.RootStorage);

            foreach (var nexusPlatform in nexusPlatforms)
            {
                if (!platforms.ContainsKey(nexusPlatform))
                {
                    platforms.Set(nexusPlatform, nexusPlatform);
                }

                _keyValueStore.Add(nexusPlatform + StorageConst.Block, new KeyValueStore <string, InteropBlock>(CreateKeyStoreAdapter(nexusPlatform + StorageConst.Block)));
                _keyValueStore.Add(nexusPlatform + StorageConst.Transaction, new KeyValueStore <string, InteropTransaction>(CreateKeyStoreAdapter(nexusPlatform + StorageConst.Transaction)));
                _keyValueStore.Add(nexusPlatform + StorageConst.CurrentHeight, new KeyValueStore <string, string>(CreateKeyStoreAdapter(nexusPlatform + StorageConst.CurrentHeight)));
            }
        }
예제 #11
0
 public bool ContainsTransaction(Hash hash)
 {
     return(_transactions.ContainsKey(hash));
 }
예제 #12
0
 public bool HasContract(string contractName)
 {
     return(_contracts.ContainsKey(contractName));
 }
예제 #13
0
 public List <String> GetConfigurationItemArray(String key)
 {
     return((KeyValueStore.ContainsKey(key)) ? KeyValueStore[key].Split(';').Select(x => x.Trim()).ToList() : null);
 }