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:
Lawrence, Rendall
2022-06-15 21:42:43 +03:00
parent 615bcb2050
commit 8430e1f31f
8 changed files with 580 additions and 62 deletions
+11 -3
View File
@@ -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.
//