public static ListDictionary decode_dict(byte[] x, ref int f)
{
ListDictionary r = new ListDictionary();
string lastkey = null;
while (x[f] != 'e')
{
string k = decode_string(x, ref f);
if (lastkey != null && lastkey.CompareTo(k) >= 0)
//throw new BitTorrentException("Dictionary contains duplicate key or is incorrectly sorted");
lastkey = k;
object v;
// Hack - certain keys are read as byte[]
if ((k != "pieces") && (k != "peer id"))
{
v = bdecode_rec(x, ref f);
}
else
{
v = decode_bytes(x, ref f);
}
r.Add(k, v);
}
f += 1;
return r;
}