Hmm... need to escape other stuff, like paths? Doubt it, since it
isn't run through the command parser.


! Now everyone gets locally unchoked even if they don't send us a remote unchoke.

    // Some peers unchoke us even though we're not interested, so we
    // need to ensure it doesn't get added to the queue.
    if (!m_downInterested)
      return true;

Hmm... somehow we don't send uninterested to Qi/ci peers. And might
forget we're interested in certain peers, though being in the queue
indicates we are interested.

- Add a bencode pool that gets passed with calles to VariableMap.


l/Qn/cn remains so, even for a seeder.


Look at XMLRPC, should be relatively easy.

- Add the min time between unchokes.

- Check if we do enough checking during receive of unchoke, so as not
  to cause us to use slots when we're not really interested.

- Improve the choking weighing for downloads.


=== API CHANGES ===

Remove std::string from exceptions.



- what do you think about the DhtStatistics class?

+    torrent::dht_manager()->set_can_receive(false); 
Hmm...

tracker_base
+  const std::string&  status() const                        { return m_status; }
Don't use a string.



*** IDEA ***

Create tools for avoiding std::string use in favor of cstr. Like
autobuild cstr for arguments from std::string and const cstr's and
other knownlength stuff.


!!! Review DHT.

- Hmmm... check down interested before adding to the queue?

! If we have unchoke weight 0, then it might leave open slots during ticks.



- Set a bad timeout for select... add some kind of sanity check.

- the goto restart might cause write-done to be set after read_peer.

- Remove the interested/choked/etc from PCB and allow const access to PB.

Bad peer: very slow upload, when choked, sends HAVE messages at high rate.


=== TODO ===

- Solve the gausian curve error diff.

! Feature: Allow rtorrent to be temporary paused by touching an
  external file.

! When creating dirs/files lazily, only create the first
  file/dir. That should cover most potential errors.

===


- Swap interested between up and down.


- Do something about the max_memory_usage docs. Make it explicit that
  the user should tweak their ulimit instead of rtorrent's settings?

- Rename max_memory_usage to max_...?

- Add a check that tries to set/unset the soft ulimit if unlimited,
  just to check that the user doesn't fsck us?

  Consider also using this to detect max vmem.


! The sorting doesn't make it certain that we will go through peers in
  a proper (random) order. Use stable sort, weight based on time since
  unchoke, or something.


Replace known max length stringstreams printf.

== Constructive Ideas on new Download (/upload) Resource Allocator ==

- For each run, start with caching a single integer 'weight'. This
  weight will be divided into 'tiers' denoted by the MSB, while the
  weight is the lower 3 bytes.

  But how would this allow us to do optimistic unchoking? 

* Optimize the choke manager container usage. It needs to do fast
  removal of elements within the containers.

? The order decideds how large a chance it is that we select from that
  range? Or do we have a high-selectation order, med, low, and none?

  Also, change the order of the elements.

! When we do the randomize unchoke based on the table thing, consider
  various ways of f.ex only calling random once, and just doing a
  certain number of an order.

  That is, beh... randomize only getting the remainder.

== Rant ==

To implement scheduling libtorrent should support semi-automatic
adjustment of download slots. To get there, I need some experience
with an easier target; automatic adjustment of upload slots.

Though automatic upload slot adjusting might not be the best initial
target.

Perhaps I should consider implementing the download slot thing
first. Anyway, ideas:

- Add priority to connections, about what kind of rarity pieces, and
  what download they are on.

- Need to fix the pipe-lining code too.

- Might want to require download throttle to be set, though I assume
  it should be possible without it. Anyway, one of the first things I
  need to implement, is a way to detect if we're close to full
  bandwidth usage. This needs to take into account that upload and
  congestion varies.

- Obviously we need to put the 30 second cycles into use.

- Might use an vector of the last N ticks and how our performance was.

- Prefer peers which send rare pieces.


- Add default check disk space.

- Hmm... Handle relative paths properly in the symlink thingie.

Hmm... could one make something like APR's memory pools by replacing
new/delete? Hmm... Probably exists... but what about making some polls
for auto-release?


- Write a document of some kind on how to write smaller maps with
  const char*. Search the net too.

- Add variable(s) for creating new variables.

- preloading should perhaps check the piped requests.

- Move permission, etc, from File to the new OpenFile's value_type?


- Consider if this would benefit from allowing custom open-file
  functions to be defined per File. Not necessarily right now, but in
  the future. Anyway, add a way to make it configurable if we want to
  create the file or throw.



- Move file/dir creation into open_file or similar.

- Later re-add a function for creating all directories in a torrent at
  open.



- Allow flags when starting/opening that do extra error checking or
  ignore them.

- When it does the missing files thing, it actually creates the missing file... bad.



- Add helper functions for setting the various max open stuff.

- Check diskspace before opening a new/incomplete torrent. Should we
  add the start with flags thing now as a renamed function, then add a
  flag that checks for diskspace/existing files.

- Add DownloadList thing to the API. Make the old torrent api use this
  API. This should contain DownloadWrappers for now.

- See if we can embed data in the curl handle, like the curlget pointer.

- Fix HttpQueue?

- Check how many peers we received, and only reconnect if we got less
  than request size. Won't work.

- Fix erasing in HashQueue.

- Allow print_attr to skip lines.

- Move signals to their respective classes in the interface.

- Allow setting the source port. Also move stuff like bind address.

! Consider single file multi-file torrents. Add an option for this?

| Configurable tracker request behavior.

- New global torrent class.

- Fix the resume interface.

- Tracker dump does not show failed tracker connects.

