Exemplo n.º 1
0
        public static RapidBaseConfiguration FromConfiguration()
        {
            var conf = new RapidBaseConfiguration
            {
                Indexer    = IndexerConfiguration.FromConfiguration(),
                LocalChain = ConfigurationManager.AppSettings["LocalChain"],
                ServiceBus = ConfigurationManager.AppSettings["ServiceBus"]
            };

            return(conf);
        }
Exemplo n.º 2
0
 public static void Register(HttpConfiguration config, RapidBaseConfiguration rapidbase)
 {
     SetThrottling();
     if (rapidbase == null)
     {
         rapidbase = RapidBaseConfiguration.FromConfiguration();
     }
     rapidbase.EnsureSetup();
     config.MapHttpAttributeRoutes();
     config.Formatters.Clear();
     config.Formatters.Add(new CustomJsonMediaTypeFormatter()
     {
         Indent = true,
     });
     config.DependencyResolver = new RapidBaseDependencyResolver(rapidbase, config.DependencyResolver);
     config.Filters.Add(new GlobalExceptionFilter());
     config.Services.Replace(typeof(IBodyModelValidator), new NoBodyModelProvider());
     Serializer.RegisterFrontConverters(config.Formatters.JsonFormatter.SerializerSettings, rapidbase.Indexer.Network);
 }
Exemplo n.º 3
0
        public RapidBaseDependencyResolver(RapidBaseConfiguration configuration, IDependencyResolver defaultResolver)
        {
            _defaultResolver = defaultResolver;
            ContainerBuilder builder = new ContainerBuilder();

            builder.Register(ctx => configuration).SingleInstance();
            builder.Register(ctx => configuration.Indexer.CreateIndexerClient());
            builder.Register(ctx =>
            {
                var client            = ctx.Resolve <IndexerClient>();
                ConcurrentChain chain = new ConcurrentChain(configuration.Indexer.Network);
                LoadCache(chain, configuration.LocalChain);
                var changes = client.GetChainChangesUntilFork(chain.Tip, false);
                changes.UpdateChain(chain);
                SaveChainCache(chain, configuration.LocalChain);
                return(chain);
            }).SingleInstance();
            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
            _container = builder.Build();
        }
Exemplo n.º 4
0
 public RapidBaseListener(RapidBaseConfiguration configuration)
 {
     _Configuration = configuration;
 }
Exemplo n.º 5
0
 public BlockEventManager(RapidBaseConfiguration conf)
 {
     Configuration = conf;
     Timeout       = TimeSpan.FromMinutes(1);
 }