diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-03 08:48:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-03 08:48:06 +0000 |
commit | 014972b06f9180cc39ad10b34559b441edc3a33f (patch) | |
tree | 69660df5b492f5248ab7a391435a73168ab51c6e /src/fs/fs.h | |
parent | a894ddc0a376fa59850b410b43d3c9331c847677 (diff) | |
download | gnunet-014972b06f9180cc39ad10b34559b441edc3a33f.tar.gz gnunet-014972b06f9180cc39ad10b34559b441edc3a33f.zip |
search deserialization
Diffstat (limited to 'src/fs/fs.h')
-rw-r--r-- | src/fs/fs.h | 209 |
1 files changed, 127 insertions, 82 deletions
diff --git a/src/fs/fs.h b/src/fs/fs.h index 3c111f33e..33ee8dde0 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h | |||
@@ -342,8 +342,7 @@ struct GNUNET_FS_FileInformation | |||
342 | struct GNUNET_FS_TreeEncoder *te; | 342 | struct GNUNET_FS_TreeEncoder *te; |
343 | 343 | ||
344 | /** | 344 | /** |
345 | * Error message (non-NULL if this operation | 345 | * Error message (non-NULL if this operation failed). |
346 | * failed). | ||
347 | */ | 346 | */ |
348 | char *emsg; | 347 | char *emsg; |
349 | 348 | ||
@@ -543,6 +542,87 @@ struct GNUNET_FS_QueueEntry | |||
543 | 542 | ||
544 | 543 | ||
545 | /** | 544 | /** |
545 | * Information we store for each search result. | ||
546 | */ | ||
547 | struct SearchResult | ||
548 | { | ||
549 | |||
550 | /** | ||
551 | * Search context this result belongs to. | ||
552 | */ | ||
553 | struct GNUNET_FS_SearchContext *sc; | ||
554 | |||
555 | /** | ||
556 | * URI to which this search result refers to. | ||
557 | */ | ||
558 | struct GNUNET_FS_Uri *uri; | ||
559 | |||
560 | /** | ||
561 | * Metadata for the search result. | ||
562 | */ | ||
563 | struct GNUNET_CONTAINER_MetaData *meta; | ||
564 | |||
565 | /** | ||
566 | * Client info for this search result. | ||
567 | */ | ||
568 | void *client_info; | ||
569 | |||
570 | /** | ||
571 | * ID of a job that is currently probing this results' availability | ||
572 | * (NULL if we are not currently probing). | ||
573 | */ | ||
574 | struct GNUNET_FS_DownloadContext *probe_ctx; | ||
575 | |||
576 | /** | ||
577 | * Name under which this search result is stored on disk. | ||
578 | */ | ||
579 | char *serialization; | ||
580 | |||
581 | /** | ||
582 | * ID of the task that will clean up the probe_ctx should it not | ||
583 | * complete on time (and that will need to be cancelled if we clean | ||
584 | * up the search result before then). | ||
585 | */ | ||
586 | GNUNET_SCHEDULER_TaskIdentifier probe_cancel_task; | ||
587 | |||
588 | /** | ||
589 | * When did the current probe become active? | ||
590 | */ | ||
591 | struct GNUNET_TIME_Absolute probe_active_time; | ||
592 | |||
593 | /** | ||
594 | * How much longer should we run the current probe before giving up? | ||
595 | */ | ||
596 | struct GNUNET_TIME_Relative remaining_probe_time; | ||
597 | |||
598 | /** | ||
599 | * Number of mandatory keywords for which we have NOT yet found the | ||
600 | * search result; when this value hits zero, the search result is | ||
601 | * given to the callback. | ||
602 | */ | ||
603 | uint32_t mandatory_missing; | ||
604 | |||
605 | /** | ||
606 | * Number of optional keywords under which this result was also | ||
607 | * found. | ||
608 | */ | ||
609 | uint32_t optional_support; | ||
610 | |||
611 | /** | ||
612 | * Number of availability tests that have succeeded for this result. | ||
613 | */ | ||
614 | uint32_t availability_success; | ||
615 | |||
616 | /** | ||
617 | * Number of availability trials that we have performed for this | ||
618 | * search result. | ||
619 | */ | ||
620 | uint32_t availability_trials; | ||
621 | |||
622 | }; | ||
623 | |||
624 | |||
625 | /** | ||
546 | * Add a job to the queue. | 626 | * Add a job to the queue. |
547 | * | 627 | * |
548 | * @param h handle to the overall FS state | 628 | * @param h handle to the overall FS state |
@@ -699,6 +779,19 @@ GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi, | |||
699 | uint64_t offset); | 779 | uint64_t offset); |
700 | 780 | ||
701 | /** | 781 | /** |
782 | * Fill in all of the generic fields for a search event and | ||
783 | * call the callback. | ||
784 | * | ||
785 | * @param pi structure to fill in | ||
786 | * @param sc overall search context | ||
787 | * @return value returned by the callback | ||
788 | */ | ||
789 | void * | ||
790 | GNUNET_FS_search_make_status_ (struct GNUNET_FS_ProgressInfo *pi, | ||
791 | struct GNUNET_FS_SearchContext *sc); | ||
792 | |||
793 | |||
794 | /** | ||
702 | * Connect to the datastore and remove the blocks. | 795 | * Connect to the datastore and remove the blocks. |
703 | * | 796 | * |
704 | * @param uc context for the unindex operation. | 797 | * @param uc context for the unindex operation. |
@@ -706,6 +799,23 @@ GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi, | |||
706 | void | 799 | void |
707 | GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc); | 800 | GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc); |
708 | 801 | ||
802 | /** | ||
803 | * Build the request and actually initiate the search using the | ||
804 | * GNUnet FS service. | ||
805 | * | ||
806 | * @param sc search context | ||
807 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | ||
808 | */ | ||
809 | int | ||
810 | GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc); | ||
811 | |||
812 | /** | ||
813 | * Start download probes for the given search result. | ||
814 | * | ||
815 | * @param sr the search result | ||
816 | */ | ||
817 | void | ||
818 | GNUNET_FS_search_start_probe_ (struct SearchResult *sr); | ||
709 | 819 | ||
710 | /** | 820 | /** |
711 | * Remove serialization/deserialization file from disk. | 821 | * Remove serialization/deserialization file from disk. |
@@ -731,7 +841,6 @@ GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, | |||
731 | void | 841 | void |
732 | GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *f); | 842 | GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *f); |
733 | 843 | ||
734 | |||
735 | /** | 844 | /** |
736 | * Synchronize this publishing struct with its mirror | 845 | * Synchronize this publishing struct with its mirror |
737 | * on disk. Note that all internal FS-operations that change | 846 | * on disk. Note that all internal FS-operations that change |
@@ -743,7 +852,6 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *f); | |||
743 | void | 852 | void |
744 | GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc); | 853 | GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc); |
745 | 854 | ||
746 | |||
747 | /** | 855 | /** |
748 | * Synchronize this unindex struct with its mirror | 856 | * Synchronize this unindex struct with its mirror |
749 | * on disk. Note that all internal FS-operations that change | 857 | * on disk. Note that all internal FS-operations that change |
@@ -755,8 +863,6 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc); | |||
755 | void | 863 | void |
756 | GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc); | 864 | GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc); |
757 | 865 | ||
758 | |||
759 | |||
760 | /** | 866 | /** |
761 | * Synchronize this search struct with its mirror | 867 | * Synchronize this search struct with its mirror |
762 | * on disk. Note that all internal FS-operations that change | 868 | * on disk. Note that all internal FS-operations that change |
@@ -768,6 +874,16 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc); | |||
768 | void | 874 | void |
769 | GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc); | 875 | GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc); |
770 | 876 | ||
877 | /** | ||
878 | * Synchronize this search result with its mirror | ||
879 | * on disk. Note that all internal FS-operations that change | ||
880 | * publishing structs should already call "sync" internally, | ||
881 | * so this function is likely not useful for clients. | ||
882 | * | ||
883 | * @param sc the struct to sync | ||
884 | */ | ||
885 | void | ||
886 | GNUNET_FS_search_result_sync_ (struct SearchResult *sr); | ||
771 | 887 | ||
772 | 888 | ||
773 | /** | 889 | /** |
@@ -1069,82 +1185,6 @@ struct GNUNET_FS_UnindexContext | |||
1069 | 1185 | ||
1070 | 1186 | ||
1071 | /** | 1187 | /** |
1072 | * Information we store for each search result. | ||
1073 | */ | ||
1074 | struct SearchResult | ||
1075 | { | ||
1076 | |||
1077 | /** | ||
1078 | * Search context this result belongs to. | ||
1079 | */ | ||
1080 | struct GNUNET_FS_SearchContext *sc; | ||
1081 | |||
1082 | /** | ||
1083 | * URI to which this search result refers to. | ||
1084 | */ | ||
1085 | struct GNUNET_FS_Uri *uri; | ||
1086 | |||
1087 | /** | ||
1088 | * Metadata for the search result. | ||
1089 | */ | ||
1090 | struct GNUNET_CONTAINER_MetaData *meta; | ||
1091 | |||
1092 | /** | ||
1093 | * Client info for this search result. | ||
1094 | */ | ||
1095 | void *client_info; | ||
1096 | |||
1097 | /** | ||
1098 | * ID of a job that is currently probing this results' availability | ||
1099 | * (NULL if we are not currently probing). | ||
1100 | */ | ||
1101 | struct GNUNET_FS_DownloadContext *probe_ctx; | ||
1102 | |||
1103 | /** | ||
1104 | * ID of the task that will clean up the probe_ctx should it not | ||
1105 | * complete on time (and that will need to be cancelled if we clean | ||
1106 | * up the search result before then). | ||
1107 | */ | ||
1108 | GNUNET_SCHEDULER_TaskIdentifier probe_cancel_task; | ||
1109 | |||
1110 | /** | ||
1111 | * When did the current probe become active? | ||
1112 | */ | ||
1113 | struct GNUNET_TIME_Absolute probe_active_time; | ||
1114 | |||
1115 | /** | ||
1116 | * How much longer should we run the current probe before giving up? | ||
1117 | */ | ||
1118 | struct GNUNET_TIME_Relative remaining_probe_time; | ||
1119 | |||
1120 | /** | ||
1121 | * Number of mandatory keywords for which we have NOT yet found the | ||
1122 | * search result; when this value hits zero, the search result is | ||
1123 | * given to the callback. | ||
1124 | */ | ||
1125 | uint32_t mandatory_missing; | ||
1126 | |||
1127 | /** | ||
1128 | * Number of optional keywords under which this result was also | ||
1129 | * found. | ||
1130 | */ | ||
1131 | uint32_t optional_support; | ||
1132 | |||
1133 | /** | ||
1134 | * Number of availability tests that have succeeded for this result. | ||
1135 | */ | ||
1136 | uint32_t availability_success; | ||
1137 | |||
1138 | /** | ||
1139 | * Number of availability trials that we have performed for this | ||
1140 | * search result. | ||
1141 | */ | ||
1142 | uint32_t availability_trials; | ||
1143 | |||
1144 | }; | ||
1145 | |||
1146 | |||
1147 | /** | ||
1148 | * Information we keep for each keyword in | 1188 | * Information we keep for each keyword in |
1149 | * a keyword search. | 1189 | * a keyword search. |
1150 | */ | 1190 | */ |
@@ -1241,6 +1281,11 @@ struct GNUNET_FS_SearchContext | |||
1241 | char *serialization; | 1281 | char *serialization; |
1242 | 1282 | ||
1243 | /** | 1283 | /** |
1284 | * Error message (non-NULL if this operation failed). | ||
1285 | */ | ||
1286 | char *emsg; | ||
1287 | |||
1288 | /** | ||
1244 | * Map that contains a "struct SearchResult" for each result that | 1289 | * Map that contains a "struct SearchResult" for each result that |
1245 | * was found in the search. The key for each entry is the XOR of | 1290 | * was found in the search. The key for each entry is the XOR of |
1246 | * the key and query in the CHK URI (as a unique identifier for the | 1291 | * the key and query in the CHK URI (as a unique identifier for the |