Beispiel #1
0
        public TokenIndexItem Get(string symbol)
        {
            var cachedIndex = IndexTokenCache.Get(symbol);

            if (cachedIndex != null)
            {
                return(cachedIndex);
            }

            var index = database.GetTokenIndex(symbol);

            if (index != null)
            {
                IndexTokenCache.AddOrUpdate(index);
            }
            return(index);
        }
Beispiel #2
0
        public void AddToIndex(TransactionToken record)
        {
            if (record == null)
            {
                return;
            }

            var tokenIndex = new TokenIndexItem()
            {
                Name     = record.Name,
                Symbol   = record.Symbol,
                Decimals = record.Decimals
            };

            database.SaveTokenIndex(tokenIndex);
            IndexTokenCache.AddOrUpdate(tokenIndex);

            //Update key map
            List <string> symbols = database.GetKeyMap("token");

            if (symbols == null)
            {
                //First token in block is native
                database.SaveNativeTokenIndex(tokenIndex);

                symbols = new List <string>();
                symbols.Add(record.Symbol);
                database.SaveKeyMap("token", symbols);
            }
            else
            {
                if (!symbols.Contains(record.Symbol))
                {
                    symbols.Add(record.Symbol);
                    database.SaveKeyMap("token", symbols);
                }
            }
        }
Beispiel #3
0
 public void DeleteIndex(TransactionToken record)
 {
     database.DeleteTokenIndex(record.Symbol);
     database.DeleteKeyMap("token");
     IndexTokenCache.Remove(record.Symbol);
 }