Example #1
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);
                }
            }
        }
Example #2
0
        public static void AddOrUpdate(TokenIndexItem item)
        {
            if (cache == null)
            {
                cache = new List <TokenIndexItem>();
                cache.Add(item);
            }
            else
            {
                var find = cache.Where(x =>
                                       x.Symbol == item.Symbol)
                           .FirstOrDefault();

                if (find == null)
                {
                    cache.Add(item);
                }
                else
                {
                    cache.Remove(find);
                    cache.Add(item);
                }
            }
        }
Example #3
0
 public static void Remove()
 {
     cache = null;
 }
Example #4
0
 public static void AddOrUpdate(TokenIndexItem item)
 {
     cache = item;
 }