Esempio n. 1
0
        private void StartDataStore(string destination, string metaDestination)
        {
            RepositoryHooks hooks = new RepositoryHooks
            {
                OnDataAllocated = OnDataAllocated,
                OnDataVerified  = OnDataVerified,
                OnBlockWritten  = data => DataGet?.Handle(data),
                OnBlockRead     = data => DataShare?.Handle(data),
                OnPieceAccepted = data => DataGet?.Handle(data),
                OnPieceRejected = OnPieceRejected
            };

            DataStore =
                new RepositoryBuilder()
                .WithHash(Hash)
                .WithDestination(destination)
                .WithMetaDestination(metaDestination)
                .WithPipeline(Pipeline)
                .WithFiles(Files)
                .WithMemory(Memory.AsDataStore())
                .WithBufferSize(256 * 1024)
                .Build(hooks);

            DataStore.Start();
        }
Esempio n. 2
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public HookManager() {
            onLoad = new Dictionary<Type, object>();
            onBeforeSave = new Dictionary<Type, object>();
            onAfterSave = new Dictionary<Type, object>();
            onBeforeDelete = new Dictionary<Type, object>();
            onAfterDelete = new Dictionary<Type, object>();

            Alias = new RepositoryHooks<Data.Alias>();
            Category = new RepositoryHooks<Data.Category>();
            Media = new RepositoryHooks<Data.Media>();
            MediaFolder = new RepositoryHooks<Data.MediaFolder>();
            Param = new RepositoryHooks<Data.Param>();
            Site = new RepositoryHooks<Data.Site>();
            Tag = new RepositoryHooks<Data.Tag>();
        }
Esempio n. 3
0
        private void StartDataStore(string destination)
        {
            RepositoryHooks hooks = new RepositoryHooks
            {
                OnDataAllocated = OnDataAllocated,
                OnDataVerified  = OnDataVerified,
                OnBlockWritten  = OnBlockWritten,
                OnPieceAccepted = OnPieceAccepted,
                OnPieceRejected = OnPieceRejected
            };

            DataStore =
                new RepositoryBuilder()
                .WithHash(Hash)
                .WithDestination(Path.Combine(destination, Hash.ToString()))
                .WithPipeline(Pipeline)
                .WithFiles(Files)
                .WithMemory(Memory.AsDataStore())
                .WithBufferSize(256 * 1024)
                .Build(hooks);

            DataStore.Start();
        }