mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-29 15:46:15 -06:00
reduce number of inbox forwarding create calls by partially implementing Exists()
This commit is contained in:
parent
2aee3a2605
commit
3aa9abe5f3
3 changed files with 4 additions and 4 deletions
|
|
@ -65,7 +65,7 @@ func (f *federatingDB) Create(ctx context.Context, asType vocab.Type) error {
|
|||
|
||||
// Cache entry for this create activity ID for later
|
||||
// checks in the Exist() function if we see it again.
|
||||
f.createdIDs.Set(ap.GetJSONLDId(asType).String(), struct{}{})
|
||||
f.activityIDs.Set(ap.GetJSONLDId(asType).String(), struct{}{})
|
||||
|
||||
switch name := asType.GetTypeName(); name {
|
||||
case ap.ActivityBlock:
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ type federatingDB struct {
|
|||
|
||||
// tracks Activity IDs we have handled creates for,
|
||||
// for use in the Exists() function during forwarding.
|
||||
createdIDs simple.Cache[string, struct{}]
|
||||
activityIDs simple.Cache[string, struct{}]
|
||||
}
|
||||
|
||||
// New returns a DB that satisfies the pub.Database
|
||||
|
|
@ -84,6 +84,6 @@ func New(
|
|||
intFilter: intFilter,
|
||||
spamFilter: spamFilter,
|
||||
}
|
||||
fdb.createdIDs.Init(0, 1000)
|
||||
fdb.activityIDs.Init(0, 1000)
|
||||
return &fdb
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,5 +25,5 @@ import (
|
|||
// Exists is an implementation of pub.Database{}.Exists(), optimized specifically for
|
||||
// the only usecase in which go-fed/activity/pub actually calls it. Do not use otherwise!
|
||||
func (f *federatingDB) Exists(ctx context.Context, id *url.URL) (exists bool, err error) {
|
||||
return f.createdIDs.Has(id.String()), nil
|
||||
return f.activityIDs.Has(id.String()), nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue