This commit is contained in:
zzz
2009-11-21 13:45:40 +00:00
parent 647a09b5b9
commit 6bdf750c19
4 changed files with 24 additions and 2 deletions

View File

@ -109,6 +109,8 @@ public class DataHelper {
}
/**
* Writes the props to the stream, sorted by property name.
*
* jrandom disabled UTF-8 in mid-2004, for performance reasons,
* i.e. slow foo.getBytes("UTF-8")
* Re-enable it so we can pass UTF-8 tunnel names through the I2CP SessionConfig.
@ -145,6 +147,11 @@ public class DataHelper {
}
}
/*
* Reads the props from the byte array
* @param props returned OrderedProperties (sorted by property name)
* @return new offset
*/
public static int toProperties(byte target[], int offset, Properties props) throws DataFormatException, IOException {
if (props != null) {
OrderedProperties p = new OrderedProperties();
@ -174,6 +181,11 @@ public class DataHelper {
}
}
/**
* Writes the props to the byte array, not sorted
* (unless the target param is an OrderedProperties)
* @return new offset
*/
public static int fromProperties(byte source[], int offset, Properties target) throws DataFormatException, IOException {
int size = (int)fromLong(source, offset, 2);
offset += 2;
@ -196,6 +208,10 @@ public class DataHelper {
return offset + size;
}
/**
* Writes the props to returned byte array, not sorted
* (unless the opts param is an OrderedProperties)
*/
public static byte[] toProperties(Properties opts) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(2);
@ -209,8 +225,8 @@ public class DataHelper {
}
/**
* Pretty print the mapping
*
* Pretty print the mapping, unsorted
* (unless the options param is an OrderedProperties)
*/
public static String toString(Properties options) {
StringBuilder buf = new StringBuilder();
@ -278,6 +294,7 @@ public class DataHelper {
}
/**
* Writes the props to the file, unsorted.
* Note that this does not escape the \r or \n that are unescaped in loadProps() above.
*/
public static void storeProps(Properties props, File file) throws IOException {

View File

@ -25,6 +25,8 @@ import net.i2p.util.Log;
*
* NOTE: Unused directly - see FloodOnlySearchJob extension which overrides almost everything.
* TODO: Comment out or delete what we don't use here.
*
* Note that this does NOT extend SearchJob.
*/
public class FloodSearchJob extends JobImpl {
protected Log _log;

View File

@ -258,6 +258,8 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
/**
* Ok, the initial set of searches to the floodfill peers timed out, lets fall back on the
* wider kademlia-style searches
*
* Unused - called only by FloodSearchJob which is overridden - don't use this.
*/
void searchFull(Hash key, List<Job> onFind, List<Job> onFailed, long timeoutMs, boolean isLease) {
synchronized (_activeFloodQueries) { _activeFloodQueries.remove(key); }

View File

@ -827,6 +827,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
* will fire the appropriate jobs on success or timeout (or if the kademlia search completes
* without any match)
*
* Unused - called only by FNDF.searchFull() from FloodSearchJob which is overridden - don't use this.
*/
SearchJob search(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, boolean isLease) {
if (!_initialized) return null;