forked from bettybao1209/PriceFeedsService
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProviderManager.Registry.cs
38 lines (34 loc) · 1.19 KB
/
ProviderManager.Registry.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
37
38
using Neo;
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Services;
using System;
namespace PriceFeedService
{
partial class ProviderManager
{
public static bool RegisterProvider(UInt160 provider)
{
if (!IsOwner()) throw new Exception("No authorization");
if (Providers[provider] is not null) throw new InvalidOperationException("The provider already exists.");
Providers.Put(provider, 0);
return true;
}
public static bool UnRegisterProvider(UInt160 provider)
{
if (!IsOwner()) throw new Exception("No authorization");
if (Providers[provider] is null) throw new InvalidOperationException("The provider does not exist.");
Providers.Delete(provider);
return true;
}
public static UInt160[] GetRegisteredProviders()
{
List<UInt160> ret = new();
Iterator providersList = Providers.Find(FindOptions.RemovePrefix | FindOptions.KeysOnly);
while (providersList.Next())
{
ret.Add((UInt160)providersList.Value);
}
return ret;
}
}
}