mirror of
https://github.com/sot-tech/mochi.git
synced 2026-06-16 01:19:46 -07:00
implement incrementing user's snatches
This commit is contained in:
+16
-3
@@ -54,12 +54,12 @@ func (c *Conn) FindClient(peerID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Conn) IncrementSnatches(infohash string) error {
|
||||
func (c *Conn) IncrementTorrentSnatches(infohash string) error {
|
||||
c.torrentsM.Lock()
|
||||
defer c.torrentsM.Unlock()
|
||||
|
||||
t, ok := c.torrents[infohash]
|
||||
if !ok {
|
||||
t, exists := c.torrents[infohash]
|
||||
if !exists {
|
||||
return tracker.ErrTorrentDNE
|
||||
}
|
||||
t.Snatches++
|
||||
@@ -67,6 +67,19 @@ func (c *Conn) IncrementSnatches(infohash string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Conn) IncrementUserSnatches(userID string) error {
|
||||
c.usersM.Lock()
|
||||
defer c.usersM.Unlock()
|
||||
|
||||
u, exists := c.users[userID]
|
||||
if !exists {
|
||||
return tracker.ErrUserDNE
|
||||
}
|
||||
u.Snatches++
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Conn) TouchTorrent(infohash string) error {
|
||||
c.torrentsM.Lock()
|
||||
defer c.torrentsM.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user