Limit alternative sources

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

Locked
Big Muscle
Posts: 72
Joined: 2004-01-23 14:45

Limit alternative sources

Post by Big Muscle » 2004-01-31 04:26

How can I limit max. alternative sources (in source code)???

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-01-31 18:02

If you look at where DC++ reads $Sr and trace it through the code, you'll end up in

void QueueManager::onAction(SearchManagerListener::Types type, SearchResult* sr)
in QueueManager.cpp at line 1220 (in BCDC's source).

Is this enough to get you going, or would you like more help?

Big Muscle
Posts: 72
Joined: 2004-01-23 14:45

Post by Big Muscle » 2004-02-01 03:22

I have found this:

bool QueueManager::addSource(QueueItem* qi, const string& aFile, User::Ptr aUser, bool addBad) throw(QueueException, FileException) {
QueueItem::Source* s = NULL;
// if qi->getSources.getSize()<15
{
bool wantConnection = (qi->getPriority() != QueueItem::PAUSED);
if(qi->isSource(aUser, aFile)) {

but if I use if qi->getSources.getSize()<15 then it says SyntaxError: qi , but in other function it is normally used.

Big Muscle
Posts: 72
Joined: 2004-01-23 14:45

Post by Big Muscle » 2004-02-01 04:36

I tried to limit it in function addSource, but if it finds a new source, it downloads a filelist from all user and it adds only limit number of users to the queue. How can I do so that it doesn't download a filelist for all sources ?

Sorry for my English :wink:

Gratch06
Posts: 141
Joined: 2003-05-25 01:48
Location: USA

Post by Gratch06 » 2004-02-01 05:34

Code: Select all

bool QueueManager::addSource(QueueItem* qi, const string& aFile, User::Ptr aUser, bool addBad) throw(QueueException, FileException) {
	QueueItem::Source* s = NULL;
//	if (qi->getSources.getSize()<15) 
	{
	bool wantConnection = (qi->getPriority() != QueueItem::PAUSED);
	if(qi->isSource(aUser, aFile)) {
That should work a bit better. Before, you were doing an "if qi->getSources.getSize() then do the command <15, which is obviously not a command, and your compiler would rightly argue. I haven't looked at what you are trying to accomplish, so I don't even know if you are going in the right direction, but that'll fix your syntax error at least.

Big Muscle
Posts: 72
Joined: 2004-01-23 14:45

Post by Big Muscle » 2004-02-01 06:02

Now it works. I added it into onAction function. I am making segment downloading and if I use it, it adds 200 sources for file. Now it uses only 10 sources :-)

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-02-01 12:11

Big Muscle wrote:Now it works. I added it into onAction function. I am making segment downloading and if I use it, it adds 200 sources for file. Now it uses only 10 sources :-)
Segmented downloading? Please, do not fucking do that.

You have to use hashes and verify against them to be safe. (And you don't seem like you're doing that.)

The last thing Direct Connect needs is corrupted files, and if your client corrupts transfers though a half-assed multi-source implentation, you will make a lot of people angry at you.

nerochiaro
Posts: 2
Joined: 2004-01-28 05:25
Location: Italy
Contact:

Post by nerochiaro » 2004-02-02 03:47

GargoyleMT wrote: You have to use hashes and verify against them to be safe. (And you don't seem like you're doing that.)
The last thing Direct Connect needs is corrupted files.
Isn't it equally easy to get corrupted files by using the function which resumes a stopped d/l from a different source ?
I'm quite new to DC++, but AFAIK it seems that it looks just at the file size to decide if a file is a valid alternative source.
I don't see what possible damage (regarding corrupt files) segmented d/l can do if compared to the present implementation.
Or am i missing something obvious ?
peace,
--
nerochiaro

psf8500
Posts: 23
Joined: 2003-03-04 18:51
Contact:

Post by psf8500 » 2004-02-02 05:55

When resuming DC++ rolls back a few bytes to check for validity. This gives some protection against corrupt downloads.
With segmented downloading this wont be possible.

Hashes would make it even safer.

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-02-08 15:01

psf8500 wrote:With segmented downloading this wont be possible.
It is possible, assuming you write downloaded data to temp file per source (or keep other meta-data about what segments were downloaded from what source), and then overlap segments a bit, and do a "rollback-style" comparison on each. That, near as I can figure, is not how anyone has written their multi-source clone yet.

(That still doesn't prevent in-line corruption of the transfer [such as a tree hash will detect], but those protections should ensure that corruption doesn't happen because you're downloading from incompatible sources.)

Locked