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); } } }
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); } } }
public static void Remove() { cache = null; }
public static void AddOrUpdate(TokenIndexItem item) { cache = item; }