mirror of
https://github.com/sot-tech/mochi.git
synced 2026-06-21 11:48:27 -07:00
Initial work on implementing postgresql storage
Generated placeholders to use raw sql queries with `pgx` driver and implemented put/del peer and announce functions * inline GCAware and StatisticsAware to PeerStorage * fix redis doc configuration sample * update dependencies
This commit is contained in:
@@ -390,7 +390,7 @@ func (ps *peerStore) getPeers(shard *peerShard, ih bittorrent.InfoHash, maxCount
|
||||
return
|
||||
}
|
||||
|
||||
func (ps *peerStore) AnnouncePeers(ih bittorrent.InfoHash, seeder bool, numWant int, v6 bool) (peers []bittorrent.Peer, err error) {
|
||||
func (ps *peerStore) AnnouncePeers(ih bittorrent.InfoHash, forSeeder bool, numWant int, v6 bool) (peers []bittorrent.Peer, err error) {
|
||||
select {
|
||||
case <-ps.closed:
|
||||
panic("attempted to interact with stopped memory store")
|
||||
@@ -398,12 +398,12 @@ func (ps *peerStore) AnnouncePeers(ih bittorrent.InfoHash, seeder bool, numWant
|
||||
}
|
||||
logger.Trace().
|
||||
Stringer("infoHash", ih).
|
||||
Bool("seeder", seeder).
|
||||
Bool("forSeeder", forSeeder).
|
||||
Int("numWant", numWant).
|
||||
Bool("v6", v6).
|
||||
Msg("announce peers")
|
||||
|
||||
peers = ps.getPeers(ps.shards[ps.shardIndex(ih, v6)], ih, numWant, seeder)
|
||||
peers = ps.getPeers(ps.shards[ps.shardIndex(ih, v6)], ih, numWant, forSeeder)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -499,6 +499,14 @@ func (*dataStore) Preservable() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (*peerStore) GCAware() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (*peerStore) StatisticsAware() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// GC deletes all Peers from the PeerStorage which are older than the
|
||||
// cutoff time.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user