Algorithms » History » Version 11
Greg Burri, 08/02/2009 01:35 PM
1 | 1 | Greg Burri | h1. Algorithms |
---|---|---|---|
2 | |||
3 | h2. Searching |
||
4 | 2 | Greg Burri | |
5 | 3 | Greg Burri | For a functional description see here : [[Functional definition#The-search-window]] |
6 | 9 | Greg Burri | # |
7 | 2 | Greg Burri | !aybabtu_search.png! |
8 | 4 | Greg Burri | |
9 | 5 | Greg Burri | h2. Peer ID |
10 | |||
11 | 7 | Greg Burri | Each peer owns a peer id which is unique and generated during the first start. This ID is used to identify a peer, it's better than the previous usage of peer IP, considering this situation : |
12 | 5 | Greg Burri | |
13 | * _A_ put in queue a file entry _f_ from _B_, _B_ doesn't know the hashes of this file entry. |
||
14 | * _B_ change his IP address. |
||
15 | * _A_ want to download _f_, it can ask _B_ for the hashes even _B_'s IP changed. |
||
16 | |||
17 | 8 | Greg Burri | h2. Core threads |
18 | |||
19 | 9 | Greg Burri | There are three kind of threads in the core in addition to the main thread : |
20 | * [[Protocol_core-core#Downloading-thread|Downloading thread]] : @DownloadManager::ChunkDownloader@ |
||
21 | 8 | Greg Burri | * Uploading thread : @UploadManager::Uploader@ |
22 | 11 | Greg Burri | * [[Algorithms#Updating-the-file-cache|Updating file cache thread]] : @FileManager::FileUpdater@ |
23 | 5 | Greg Burri | |
24 | 10 | Greg Burri | h2. Updating the file cache |
25 | |||
26 | Here is the algorithm for the thread (@FileManager::FileUpdater@) which will periodically update the file cache and persist it. |
||
27 | |||
28 | <pre> |
||
29 | D : The set of shared directories |
||
30 | T : Time during the hashes are computed (for example 30s) |
||
31 | F : A set of file initialy empty |
||
32 | |||
33 | Loop : |
||
34 | For each d in D (recursively) : |
||
35 | - Synchronize physical folders and files whith d content |
||
36 | - Add in F the files which doesn't have computed hashes |
||
37 | t : Time.now |
||
38 | For each f in F : |
||
39 | - Compute the unkown hash of files f |
||
40 | - Remove f from F |
||
41 | If (Time.now - t) > T : break |
||
42 | - Wait T - (Time.now - t) |
||
43 | - Persist the entire cache in a file |
||
44 | </pre> |
||
45 | |||
46 | 5 | Greg Burri | |
47 | 4 | Greg Burri | h2. Downloading |
48 | |||
49 | See here : [[Protocol_core-core#Downloading-threads]] |