using System.Threading;
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Serializers;

namespace StellaOps.Vexer.Storage.Mongo;

public static class VexMongoMappingRegistry
{
    private static int _initialized;

    public static void Register()
    {
        if (Interlocked.Exchange(ref _initialized, 1) == 1)
        {
            return;
        }

        if (!BsonSerializer.IsSerializerRegistered(typeof(byte[])))
        {
            BsonSerializer.RegisterSerializer(new ByteArraySerializer());
        }
    }
}

public static class VexMongoCollectionNames
{
    public const string Providers = "vex.providers";
    public const string Raw = "vex.raw";
    public const string Claims = "vex.claims";
    public const string Consensus = "vex.consensus";
    public const string Exports = "vex.exports";
    public const string Cache = "vex.cache";
}
