示例#1
0
 public static void CallPieceRejected(this RepositoryHooks hooks, FileHash hash, PieceInfo piece)
 {
     hooks.OnPieceRejected?.Invoke(new PieceRejected
     {
         Hash  = hash,
         Piece = piece
     });
 }
示例#2
0
 public static void CallBlockWritten(this RepositoryHooks hooks, FileHash hash, BlockIndex block)
 {
     hooks.OnBlockWritten?.Invoke(new BlockWritten
     {
         Hash  = hash,
         Block = block
     });
 }
示例#3
0
 public static void CallDataVerified(this RepositoryHooks hooks, FileHash hash, Bitfield bitfield)
 {
     hooks.OnDataVerified?.Invoke(new DataVerified
     {
         Hash     = hash,
         Bitfield = bitfield
     });
 }
示例#4
0
 public static void CallDataAllocated(this RepositoryHooks hooks, FileHash hash, string directory)
 {
     hooks.OnDataAllocated?.Invoke(new DataAllocated
     {
         Hash      = hash,
         Directory = directory
     });
 }
示例#5
0
 public static void CallBlockRead(this RepositoryHooks hooks, FileHash hash, BlockIndex block, DataBlock payload)
 {
     hooks.OnBlockRead?.Invoke(new BlockRead
     {
         Hash    = hash,
         Block   = block,
         Payload = payload
     });
 }
示例#6
0
        public RepositoryContext(RepositoryParameters parameters, RepositoryDependencies dependencies, RepositoryHooks hooks, RepositoryConfiguration configuration)
        {
            this.parameters    = parameters;
            this.dependencies  = dependencies;
            this.hooks         = hooks;
            this.configuration = configuration;

            bitfile = new BitfileService(parameters.Hash, Path.Combine(parameters.MetaDestination, $"{parameters.Hash}.bitfield"));
            queue   = new RepositoryTaskQueue(this);
        }
示例#7
0
 public RepositoryService(RepositoryParameters parameters, RepositoryDependencies dependencies, RepositoryHooks hooks, RepositoryConfiguration configuration)
 {
     context = new RepositoryContext(parameters, dependencies, hooks, configuration);
 }
示例#8
0
 public RepositoryService Build(RepositoryHooks hooks)
 {
     return(new RepositoryService(parameters, dependencies, hooks, configuration));
 }