forked from bettybao1209/PriceFeedsService
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProviderManager.Symbol.cs
36 lines (33 loc) · 1.12 KB
/
ProviderManager.Symbol.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Services;
using System;
namespace PriceFeedService
{
partial class ProviderManager
{
public static bool AddSymbol(string symbol)
{
if (!IsOwner()) throw new Exception("No authorization");
if (Symbols[symbol] is not null) throw new InvalidOperationException("The symbol already exists.");
Symbols.Put(symbol, 0);
return true;
}
public static bool RemoveSymbol(string symbol)
{
if (!IsOwner()) throw new Exception("No authorization");
if (Symbols[symbol] is null) throw new InvalidOperationException("The symbol does not exist.");
Symbols.Delete(symbol);
return true;
}
public static string[] GetAvailableSymbols()
{
List<string> ret = new();
Iterator symbolList = Symbols.Find(FindOptions.RemovePrefix | FindOptions.KeysOnly);
while (symbolList.Next())
{
ret.Add((string)symbolList.Value);
}
return ret;
}
}
}