Firehose working

This commit is contained in:
pippellia-btc
2025-05-29 17:05:57 +02:00
parent de56ecd913
commit 768cec8fea
4 changed files with 196 additions and 0 deletions

View File

@@ -101,6 +101,15 @@ func (r RedisDB) NodeByKey(ctx context.Context, pubkey string) (*graph.Node, err
return parseNode(fields)
}
// Exists checks for the existance of the pubkey
func (r RedisDB) Exists(ctx context.Context, pubkey string) (bool, error) {
exists, err := r.client.HExists(ctx, KeyKeyIndex, pubkey).Result()
if err != nil {
return false, fmt.Errorf("failed to check existance of pubkey %s: %w", pubkey, err)
}
return exists, nil
}
func (r RedisDB) ensureExists(ctx context.Context, IDs ...graph.ID) error {
if len(IDs) == 0 {
return nil

View File

@@ -5,6 +5,7 @@ import (
"errors"
"github/pippellia-btc/crawler/pkg/graph"
"github/pippellia-btc/crawler/pkg/pagerank"
"github/pippellia-btc/crawler/pkg/pipe"
"github/pippellia-btc/crawler/pkg/walks"
"reflect"
"testing"
@@ -375,6 +376,7 @@ func TestInterfaces(t *testing.T) {
var _ walks.Walker = RedisDB{}
var _ pagerank.VisitCounter = RedisDB{}
var _ pagerank.PersonalizedLoader = RedisDB{}
var _ pipe.PubkeyChecker = RedisDB{}
}
// ------------------------------------- HELPERS -------------------------------