Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Seed Time
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2.08 Support

2023-05-16 07:30:39
Hi,

I would like to be able to see the total seed time for each user for each torrent in pages like the snatched page, but it seems the seed time shown there gets mangled after a few hours and starts saying a torrent has been seeded for 3 days when it was uploaded about 24 hours ago.

Looking at the code I can see ltime should be the seed time for an individual torrent for an individual user, but it seems to be muddied by $elapsed being added to it in the DB.

Totalseedtime is there, so it must have had some reason for being, while ltime appears to have been intended to show seed times on individual torrents but that's not what shows in the snatched page.

Can someone enlighten me on how it should work, and why totalseedtime is being calculated anyway? :)

Thanks,
TW
2023-05-16 21:29:49
i saw this at me also  . If you give a FORCE CLEAN it adds on all users the clean interval what i assume is the default one. So every time you give foce clean itwill add at least 30 mins in seed time.
In my side i did notfind the issue . i assume it is on snatched file
2023-05-18 01:11:11
Thanks for replying, Djlive.
I think the snatched is OK, but the announce looks odd to me.

$elapsed = ($self['seeder'] == 'yes') ? $site_config['announce_interval'] - floor(($self['ez'] - time()) / 60) : 0;

Why would the amount of time seeding involve the last active time? It doesn't matter if the torrent is active or not, it can seed without anyone downloading it. (I'm making the assumption that last active time was the last time someone downloaded or uploaded from the peer).
Shouldn't $elapsed = the announce interval if the peer is seeding the torrent, and 0 if the peer is not seeding the torrent?

Something like this:
$elapsed = ($self['seeder'] == 'yes') ? $site_config['announce_interval'] : 0;

Assuming an announce interval of 30 minutes, this would allow 1800 seconds to be added to ltime for each announce where the torrent is seeding, and 0 seconds for each announce where the torrent isn't seeding.

Does that sound right?

It means the peer would get a full 30 minutes seeding for a torrent that has been on site for maybe 5 minutes, but that would be far more accurate than what it is currently using.



EDIT
Well, that didn't work. I have a torrent that has been onsite for 10 minutes and ltime is more than 1 hour.
It's possible that when it was uploaded it announced, therefore getting 30 minutes added to ltime, then an announce happened in the 10 minutes after it was uploaded, and another 30 minutes was added. If it gets another 30 minutes in 30 minutes, it may be useable, otherwise it's back to the drawing board.
Last edited by TheophanusW on 2023-05-18 01:47:17
2023-05-18 22:15:37
Its bad design.

Peers seeding torrents should be counted by reference in the peers table (user id, passkey, etc) as a total seed count, as they currently exist. That is the way. Row removed, one less seed for that peer.

And announce should automatically delete peer when client stops. Not completed, only stopped. Paused should retain table row, but deny inbound connections - eg. fsockopen()

event=completed assumes seed state, and it is seed state as clients rush the event state to seeding status by design automatically, so that gives you a large window of determining that state or not. Otherwise, the row should be removed for that torrent when event=stopped is detected in announce.

That is a lot of overhead math and there is much faster methods to that even if I deemed it relevant to good design.

You have to remember, this is old code from 2007-2012, and basically left frozen in time. Your best using the MVC version or rolling your own codebase yourself. Its sorts all this crap out and runs on any version of PHP, not exactly the case for V3 as-is.
2023-05-18 22:19:09
Also you want to make sure you have the cleanup.php script and have it triggered to run every 30mins or so (or 6 hours on thousands of torrents). Bump it up over time as the database grows.

The cleanup script will take care of all of this, peers, ratio warnings, comments, etc. Its best to run this on a cronjob and store it back a directory ../ before root, for security.
2023-05-18 23:09:14
Thanks STorrents2020,

Cleanup runs every 15 minutes at the moment (the userbase is very small) and it does take care of the things you have mentioned, but the seedtime is calculated incorrectly.
As you've said, I think I'll have to impliment something of my own for that.
It would be good to store things like the cleanup in a folder above root, I'll look into that. :)
2023-05-19 07:13:57
No problem. I can tell you know a thing or two. So naturally I feed what I know. I run my own codebase, but its a early migration away from V3 and its 95% in-house. We all start somewhere. I agree, the peer time to take into effect is faulty and I personally should consult that myself on my copy of cleanup.

Get into PECL Parallel processing (PHP 8.1+), it uses all your CPU cores to run all the jobs simultaneously, way faster on a larger tables like torrent table (LONGBLOB, no physical meta files).  

Here is a sample of just that, with locks so if the job its too heavy, it pushes it to the end of the queue so the rest of the jobs are fired first (ratiowarn is always locked for later, huge table).

run_jobs.php

<?
// Cleanup V2 - PECL Parallel support
$tasks = [
   'cleancache' => [1],
   'seedbonus' => [],
   'comments' => [],
   'checkexpiredwarns' => [],
   'cleanlogs' => [1],
'cleannotifs' => [1],
'cleanshoutbox' => [1],
   'autopromote' => [],
   'autofreeleech' => [],
   'autodemote' => [],
   'pendingusers' => [],
   'privseeders' => [],
'checkdead' => [],
   'startsync' => [],
'ratiowarn' => [] // Heavy
];

$classFiles = [
   'Extensions',
   'Cleanup'
];

$results = [];
$runtime = new \parallel\Runtime;

foreach ($tasks as $taskName => $taskParams) {
   $future = $runtime->run(function () use ($taskName, $taskParams, $classFiles) {
       spl_autoload_register(function ($className) use ($classFiles) {
           if (!empty($classFiles) && in_array($className, $classFiles)) {
               include_once "classes/$className.php";
           }
       });
       $cleanup = new \Cleanup;
       $lockName = "cleanup_$taskName";
       if ($cleanup->acquireLock($lockName)) {
           if (method_exists($cleanup, $taskName)) {
               call_user_func_array([$cleanup, $taskName], $taskParams);
               echo "Task '$taskName' completed.\n";
           }
           $cleanup->query_params('DELETE FROM locks WHERE name = :name', array(
'name' => $lockName
));
       } else {
           echo "Task '$taskName' skipped due to a lock.\n";
       }
   });
}

echo "All tasks completed.\n";


Cleanup.php

interface Tasks
{
   public function seedbonus();
   public function comments();
   public function checkexpiredwarns();
   public function ratiowarn();
   public function cleanlogs();
   public function autopromote();
   public function autofreeleech();
   public function autodemote();
   public function checkdead();
   public function pendingusers();
   public function privseeders();
   public function startsync();
   public function cleanshoutbox();
public function cleancache();
public function cleannotifs();
public function acquireLock($name);
}

class Cleanup extends Extensions implements Tasks
{
public function acquireLock($name) {
       $lock = $this->query_params('INSERT INTO locks (name, created_at, updated_at) VALUES (:name, NOW(), NOW()) ON DUPLICATE KEY UPDATE updated_at = NOW()', array(
'name' => $name
));
       return $lock;
   }


The code formatting sucks on here but you get the idea.
2023-05-19 07:29:47
That looks great, STorents2020.
I like the modular approach and allowing other other tasks to run instead of getting bogged down on a task that takes a long time. :)
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 3
  • Members: 0
  • Guests online: 3
  • Comments: 3
  • Messages: 1,728