aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-23 08:18:41 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-23 08:18:41 +0000
commitfeb4578a243f456236608c78f87c53edc245bfeb (patch)
treef06b450ead95d77537424f6e7f5c0233f4594be4 /src/fs
parent669d77b3d4d3aa5ddca24ad6f35db745aea62688 (diff)
downloadgnunet-feb4578a243f456236608c78f87c53edc245bfeb.tar.gz
gnunet-feb4578a243f456236608c78f87c53edc245bfeb.zip
-comment / naming cleanups
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/fs.conf.in2
-rw-r--r--src/fs/fs_download.c6
-rw-r--r--src/fs/gnunet-service-fs_cp.c110
3 files changed, 60 insertions, 58 deletions
diff --git a/src/fs/fs.conf.in b/src/fs/fs.conf.in
index df302d478..6c4d8217d 100644
--- a/src/fs/fs.conf.in
+++ b/src/fs/fs.conf.in
@@ -1,7 +1,7 @@
1[fs] 1[fs]
2AUTOSTART = YES 2AUTOSTART = YES
3INDEXDB = $SERVICEHOME/fs/idxinfo.lst 3INDEXDB = $SERVICEHOME/fs/idxinfo.lst
4TRUST = $SERVICEHOME/fs/credit/ 4RESPECT = $SERVICEHOME/fs/credit/
5IDENTITY_DIR = $SERVICEHOME/fs/identities/ 5IDENTITY_DIR = $SERVICEHOME/fs/identities/
6STATE_DIR = $SERVICEHOME/fs/persistence/ 6STATE_DIR = $SERVICEHOME/fs/persistence/
7UPDATE_DIR = $SERVICEHOME/fs/updates/ 7UPDATE_DIR = $SERVICEHOME/fs/updates/
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index 7273b56d8..2e1633c8e 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -525,7 +525,7 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
525 pi.value.download.specifics.progress.offset = 0; 525 pi.value.download.specifics.progress.offset = 0;
526 pi.value.download.specifics.progress.data_len = dlen; 526 pi.value.download.specifics.progress.data_len = dlen;
527 pi.value.download.specifics.progress.depth = 0; 527 pi.value.download.specifics.progress.depth = 0;
528 pi.value.download.specifics.progress.trust_offered = 0; 528 pi.value.download.specifics.progress.respect_offered = 0;
529 pi.value.download.specifics.progress.block_download_duration = GNUNET_TIME_UNIT_ZERO; 529 pi.value.download.specifics.progress.block_download_duration = GNUNET_TIME_UNIT_ZERO;
530 GNUNET_FS_download_make_status_ (&pi, dc); 530 GNUNET_FS_download_make_status_ (&pi, dc);
531 if ((NULL != dc->filename) && 531 if ((NULL != dc->filename) &&
@@ -1069,7 +1069,7 @@ process_result_with_request (void *cls, const struct GNUNET_HashCode * key,
1069 pi.value.download.specifics.progress.offset = dr->offset; 1069 pi.value.download.specifics.progress.offset = dr->offset;
1070 pi.value.download.specifics.progress.data_len = prc->size; 1070 pi.value.download.specifics.progress.data_len = prc->size;
1071 pi.value.download.specifics.progress.depth = dr->depth; 1071 pi.value.download.specifics.progress.depth = dr->depth;
1072 pi.value.download.specifics.progress.trust_offered = 0; 1072 pi.value.download.specifics.progress.respect_offered = 0;
1073 if (prc->last_transmission.abs_value != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) 1073 if (prc->last_transmission.abs_value != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value)
1074 pi.value.download.specifics.progress.block_download_duration 1074 pi.value.download.specifics.progress.block_download_duration
1075 = GNUNET_TIME_absolute_get_duration (prc->last_transmission); 1075 = GNUNET_TIME_absolute_get_duration (prc->last_transmission);
@@ -1725,7 +1725,7 @@ reconstruct_cb (void *cls, const struct ContentHashKey *chk, uint64_t offset,
1725 pi.value.download.specifics.progress.offset = offset; 1725 pi.value.download.specifics.progress.offset = offset;
1726 pi.value.download.specifics.progress.data_len = 0; 1726 pi.value.download.specifics.progress.data_len = 0;
1727 pi.value.download.specifics.progress.depth = 0; 1727 pi.value.download.specifics.progress.depth = 0;
1728 pi.value.download.specifics.progress.trust_offered = 0; 1728 pi.value.download.specifics.progress.respect_offered = 0;
1729 pi.value.download.specifics.progress.block_download_duration = GNUNET_TIME_UNIT_ZERO; 1729 pi.value.download.specifics.progress.block_download_duration = GNUNET_TIME_UNIT_ZERO;
1730 GNUNET_FS_download_make_status_ (&pi, dc); 1730 GNUNET_FS_download_make_status_ (&pi, dc);
1731 /* FIXME: duplicated code from 'process_result_with_request - refactor */ 1731 /* FIXME: duplicated code from 'process_result_with_request - refactor */
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index e021606a9..8c6bf0b06 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -41,9 +41,9 @@
41#define RUNAVG_DELAY_N 16 41#define RUNAVG_DELAY_N 16
42 42
43/** 43/**
44 * How often do we flush trust values to disk? 44 * How often do we flush respect values to disk?
45 */ 45 */
46#define TRUST_FLUSH_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) 46#define RESPECT_FLUSH_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
47 47
48/** 48/**
49 * After how long do we discard a reply? 49 * After how long do we discard a reply?
@@ -270,9 +270,9 @@ struct GSF_ConnectedPeer
270 unsigned int cth_in_progress; 270 unsigned int cth_in_progress;
271 271
272 /** 272 /**
273 * Trust rating for this peer on disk. 273 * Respect rating for this peer on disk.
274 */ 274 */
275 uint32_t disk_trust; 275 uint32_t disk_respect;
276 276
277 /** 277 /**
278 * Which offset in "last_p2p_replies" will be updated next? 278 * Which offset in "last_p2p_replies" will be updated next?
@@ -306,9 +306,9 @@ struct GSF_ConnectedPeer
306static struct GNUNET_CONTAINER_MultiHashMap *cp_map; 306static struct GNUNET_CONTAINER_MultiHashMap *cp_map;
307 307
308/** 308/**
309 * Where do we store trust information? 309 * Where do we store respect information?
310 */ 310 */
311static char *trustDirectory; 311static char *respectDirectory;
312 312
313/** 313/**
314 * Handle to ATS service. 314 * Handle to ATS service.
@@ -316,18 +316,20 @@ static char *trustDirectory;
316static struct GNUNET_ATS_PerformanceHandle *ats; 316static struct GNUNET_ATS_PerformanceHandle *ats;
317 317
318/** 318/**
319 * Get the filename under which we would store the GNUNET_HELLO_Message 319 * Get the filename under which we would store respect
320 * for the given host and protocol. 320 * for the given peer.
321 * @return filename of the form DIRECTORY/HOSTID 321 *
322 * @param id peer to get the filename for
323 * @return filename of the form DIRECTORY/PEERID
322 */ 324 */
323static char * 325static char *
324get_trust_filename (const struct GNUNET_PeerIdentity *id) 326get_respect_filename (const struct GNUNET_PeerIdentity *id)
325{ 327{
326 struct GNUNET_CRYPTO_HashAsciiEncoded fil; 328 struct GNUNET_CRYPTO_HashAsciiEncoded fil;
327 char *fn; 329 char *fn;
328 330
329 GNUNET_CRYPTO_hash_to_enc (&id->hashPubKey, &fil); 331 GNUNET_CRYPTO_hash_to_enc (&id->hashPubKey, &fil);
330 GNUNET_asprintf (&fn, "%s%s%s", trustDirectory, DIR_SEPARATOR_STR, &fil); 332 GNUNET_asprintf (&fn, "%s%s%s", respectDirectory, DIR_SEPARATOR_STR, &fil);
331 return fn; 333 return fn;
332} 334}
333 335
@@ -597,7 +599,7 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
597{ 599{
598 struct GSF_ConnectedPeer *cp; 600 struct GSF_ConnectedPeer *cp;
599 char *fn; 601 char *fn;
600 uint32_t trust; 602 uint32_t respect;
601 603
602 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %s\n", 604 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %s\n",
603 GNUNET_i2s (peer)); 605 GNUNET_i2s (peer));
@@ -607,10 +609,10 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
607 cp->rc = 609 cp->rc =
608 GNUNET_ATS_reserve_bandwidth (ats, peer, DBLOCK_SIZE, 610 GNUNET_ATS_reserve_bandwidth (ats, peer, DBLOCK_SIZE,
609 &ats_reserve_callback, cp); 611 &ats_reserve_callback, cp);
610 fn = get_trust_filename (peer); 612 fn = get_respect_filename (peer);
611 if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) && 613 if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) &&
612 (sizeof (trust) == GNUNET_DISK_fn_read (fn, &trust, sizeof (trust)))) 614 (sizeof (respect) == GNUNET_DISK_fn_read (fn, &respect, sizeof (respect))))
613 cp->disk_trust = cp->ppd.trust = ntohl (trust); 615 cp->disk_respect = cp->ppd.respect = ntohl (respect);
614 GNUNET_free (fn); 616 GNUNET_free (fn);
615 cp->request_map = GNUNET_CONTAINER_multihashmap_create (128); 617 cp->request_map = GNUNET_CONTAINER_multihashmap_create (128);
616 GNUNET_break (GNUNET_OK == 618 GNUNET_break (GNUNET_OK ==
@@ -982,38 +984,38 @@ handle_p2p_reply (void *cls, enum GNUNET_BLOCK_EvaluationResult eval,
982 984
983 985
984/** 986/**
985 * Increase the host credit by a value. 987 * Increase the peer's respect by a value.
986 * 988 *
987 * @param cp which peer to change the trust value on 989 * @param cp which peer to change the respect value on
988 * @param value is the int value by which the 990 * @param value is the int value by which the
989 * host credit is to be increased or decreased 991 * peer's credit is to be increased or decreased
990 * @returns the actual change in trust (positive or negative) 992 * @returns the actual change in respect (positive or negative)
991 */ 993 */
992static int 994static int
993change_host_trust (struct GSF_ConnectedPeer *cp, int value) 995change_peer_respect (struct GSF_ConnectedPeer *cp, int value)
994{ 996{
995 if (value == 0) 997 if (value == 0)
996 return 0; 998 return 0;
997 GNUNET_assert (cp != NULL); 999 GNUNET_assert (cp != NULL);
998 if (value > 0) 1000 if (value > 0)
999 { 1001 {
1000 if (cp->ppd.trust + value < cp->ppd.trust) 1002 if (cp->ppd.respect + value < cp->ppd.respect)
1001 { 1003 {
1002 value = UINT32_MAX - cp->ppd.trust; 1004 value = UINT32_MAX - cp->ppd.respect;
1003 cp->ppd.trust = UINT32_MAX; 1005 cp->ppd.respect = UINT32_MAX;
1004 } 1006 }
1005 else 1007 else
1006 cp->ppd.trust += value; 1008 cp->ppd.respect += value;
1007 } 1009 }
1008 else 1010 else
1009 { 1011 {
1010 if (cp->ppd.trust < -value) 1012 if (cp->ppd.respect < -value)
1011 { 1013 {
1012 value = -cp->ppd.trust; 1014 value = -cp->ppd.respect;
1013 cp->ppd.trust = 0; 1015 cp->ppd.respect = 0;
1014 } 1016 }
1015 else 1017 else
1016 cp->ppd.trust += value; 1018 cp->ppd.respect += value;
1017 } 1019 }
1018 return value; 1020 return value;
1019} 1021}
@@ -1021,7 +1023,7 @@ change_host_trust (struct GSF_ConnectedPeer *cp, int value)
1021 1023
1022/** 1024/**
1023 * We've received a request with the specified priority. Bound it 1025 * We've received a request with the specified priority. Bound it
1024 * according to how much we trust the given peer. 1026 * according to how much we respect the given peer.
1025 * 1027 *
1026 * @param prio_in requested priority 1028 * @param prio_in requested priority
1027 * @param cp the peer making the request 1029 * @param cp the peer making the request
@@ -1046,7 +1048,7 @@ bound_priority (uint32_t prio_in, struct GSF_ConnectedPeer *cp)
1046 } 1048 }
1047 if (prio_in > INT32_MAX) 1049 if (prio_in > INT32_MAX)
1048 prio_in = INT32_MAX; 1050 prio_in = INT32_MAX;
1049 ret = -change_host_trust (cp, -(int) prio_in); 1051 ret = -change_peer_respect (cp, -(int) prio_in);
1050 if (ret > 0) 1052 if (ret > 0)
1051 { 1053 {
1052 if (ret > GSF_current_priorities + N) 1054 if (ret > GSF_current_priorities + N)
@@ -1067,7 +1069,7 @@ bound_priority (uint32_t prio_in, struct GSF_ConnectedPeer *cp)
1067 ("# request dropped, priority insufficient"), 1, 1069 ("# request dropped, priority insufficient"), 1,
1068 GNUNET_NO); 1070 GNUNET_NO);
1069 /* undo charge */ 1071 /* undo charge */
1070 change_host_trust (cp, (int) ret); 1072 change_peer_respect (cp, (int) ret);
1071 return -1; /* not enough resources */ 1073 return -1; /* not enough resources */
1072 } 1074 }
1073 else 1075 else
@@ -1720,27 +1722,27 @@ GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp,
1720 1722
1721 1723
1722/** 1724/**
1723 * Write host-trust information to a file - flush the buffer entry! 1725 * Write peer-respect information to a file - flush the buffer entry!
1724 * 1726 *
1725 * @param cls closure, not used 1727 * @param cls unused
1726 * @param key host identity 1728 * @param key peer identity
1727 * @param value the 'struct GSF_ConnectedPeer' to flush 1729 * @param value the 'struct GSF_ConnectedPeer' to flush
1728 * @return GNUNET_OK to continue iteration 1730 * @return GNUNET_OK to continue iteration
1729 */ 1731 */
1730static int 1732static int
1731flush_trust (void *cls, const struct GNUNET_HashCode * key, void *value) 1733flush_respect (void *cls, const struct GNUNET_HashCode * key, void *value)
1732{ 1734{
1733 struct GSF_ConnectedPeer *cp = value; 1735 struct GSF_ConnectedPeer *cp = value;
1734 char *fn; 1736 char *fn;
1735 uint32_t trust; 1737 uint32_t respect;
1736 struct GNUNET_PeerIdentity pid; 1738 struct GNUNET_PeerIdentity pid;
1737 1739
1738 if (cp->ppd.trust == cp->disk_trust) 1740 if (cp->ppd.respect == cp->disk_respect)
1739 return GNUNET_OK; /* unchanged */ 1741 return GNUNET_OK; /* unchanged */
1740 GNUNET_assert (0 != cp->ppd.pid); 1742 GNUNET_assert (0 != cp->ppd.pid);
1741 GNUNET_PEER_resolve (cp->ppd.pid, &pid); 1743 GNUNET_PEER_resolve (cp->ppd.pid, &pid);
1742 fn = get_trust_filename (&pid); 1744 fn = get_respect_filename (&pid);
1743 if (cp->ppd.trust == 0) 1745 if (cp->ppd.respect == 0)
1744 { 1746 {
1745 if ((0 != UNLINK (fn)) && (errno != ENOENT)) 1747 if ((0 != UNLINK (fn)) && (errno != ENOENT))
1746 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | 1748 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
@@ -1748,14 +1750,14 @@ flush_trust (void *cls, const struct GNUNET_HashCode * key, void *value)
1748 } 1750 }
1749 else 1751 else
1750 { 1752 {
1751 trust = htonl (cp->ppd.trust); 1753 respect = htonl (cp->ppd.respect);
1752 if (sizeof (uint32_t) == 1754 if (sizeof (uint32_t) ==
1753 GNUNET_DISK_fn_write (fn, &trust, sizeof (uint32_t), 1755 GNUNET_DISK_fn_write (fn, &respect, sizeof (uint32_t),
1754 GNUNET_DISK_PERM_USER_READ | 1756 GNUNET_DISK_PERM_USER_READ |
1755 GNUNET_DISK_PERM_USER_WRITE | 1757 GNUNET_DISK_PERM_USER_WRITE |
1756 GNUNET_DISK_PERM_GROUP_READ | 1758 GNUNET_DISK_PERM_GROUP_READ |
1757 GNUNET_DISK_PERM_OTHER_READ)) 1759 GNUNET_DISK_PERM_OTHER_READ))
1758 cp->disk_trust = cp->ppd.trust; 1760 cp->disk_respect = cp->ppd.respect;
1759 } 1761 }
1760 GNUNET_free (fn); 1762 GNUNET_free (fn);
1761 return GNUNET_OK; 1763 return GNUNET_OK;
@@ -1780,25 +1782,25 @@ GSF_connected_peer_change_preference_ (struct GSF_ConnectedPeer *cp,
1780 1782
1781 1783
1782/** 1784/**
1783 * Call this method periodically to flush trust information to disk. 1785 * Call this method periodically to flush respect information to disk.
1784 * 1786 *
1785 * @param cls closure, not used 1787 * @param cls closure, not used
1786 * @param tc task context, not used 1788 * @param tc task context, not used
1787 */ 1789 */
1788static void 1790static void
1789cron_flush_trust (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1791cron_flush_respect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1790{ 1792{
1791 1793
1792 if (NULL == cp_map) 1794 if (NULL == cp_map)
1793 return; 1795 return;
1794 GNUNET_CONTAINER_multihashmap_iterate (cp_map, &flush_trust, NULL); 1796 GNUNET_CONTAINER_multihashmap_iterate (cp_map, &flush_respect, NULL);
1795 if (NULL == tc) 1797 if (NULL == tc)
1796 return; 1798 return;
1797 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1799 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1798 return; 1800 return;
1799 GNUNET_SCHEDULER_add_delayed_with_priority (TRUST_FLUSH_FREQ, 1801 GNUNET_SCHEDULER_add_delayed_with_priority (RESPECT_FLUSH_FREQ,
1800 GNUNET_SCHEDULER_PRIORITY_HIGH, 1802 GNUNET_SCHEDULER_PRIORITY_HIGH,
1801 &cron_flush_trust, NULL); 1803 &cron_flush_respect, NULL);
1802} 1804}
1803 1805
1804 1806
@@ -1812,11 +1814,11 @@ GSF_connected_peer_init_ ()
1812 ats = GNUNET_ATS_performance_init (GSF_cfg, NULL, NULL); 1814 ats = GNUNET_ATS_performance_init (GSF_cfg, NULL, NULL);
1813 GNUNET_assert (GNUNET_OK == 1815 GNUNET_assert (GNUNET_OK ==
1814 GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, "fs", 1816 GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, "fs",
1815 "TRUST", 1817 "RESPECT",
1816 &trustDirectory)); 1818 &respectDirectory));
1817 GNUNET_DISK_directory_create (trustDirectory); 1819 GNUNET_DISK_directory_create (respectDirectory);
1818 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_HIGH, 1820 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_HIGH,
1819 &cron_flush_trust, NULL); 1821 &cron_flush_respect, NULL);
1820} 1822}
1821 1823
1822 1824
@@ -1842,12 +1844,12 @@ clean_peer (void *cls, const struct GNUNET_HashCode * key, void *value)
1842void 1844void
1843GSF_connected_peer_done_ () 1845GSF_connected_peer_done_ ()
1844{ 1846{
1845 cron_flush_trust (NULL, NULL); 1847 cron_flush_respect (NULL, NULL);
1846 GNUNET_CONTAINER_multihashmap_iterate (cp_map, &clean_peer, NULL); 1848 GNUNET_CONTAINER_multihashmap_iterate (cp_map, &clean_peer, NULL);
1847 GNUNET_CONTAINER_multihashmap_destroy (cp_map); 1849 GNUNET_CONTAINER_multihashmap_destroy (cp_map);
1848 cp_map = NULL; 1850 cp_map = NULL;
1849 GNUNET_free (trustDirectory); 1851 GNUNET_free (respectDirectory);
1850 trustDirectory = NULL; 1852 respectDirectory = NULL;
1851 GNUNET_ATS_performance_done (ats); 1853 GNUNET_ATS_performance_done (ats);
1852 ats = NULL; 1854 ats = NULL;
1853} 1855}