fixed double promotion bug

This commit is contained in:
pippellia-btc
2025-06-10 16:43:08 +02:00
parent 0ae6b223b7
commit b856f03605
2 changed files with 10 additions and 22 deletions

View File

@@ -7,7 +7,6 @@ import (
"github/pippellia-btc/crawler/pkg/graph" "github/pippellia-btc/crawler/pkg/graph"
"github/pippellia-btc/crawler/pkg/pipe" "github/pippellia-btc/crawler/pkg/pipe"
"github/pippellia-btc/crawler/pkg/redb" "github/pippellia-btc/crawler/pkg/redb"
"github/pippellia-btc/crawler/pkg/walks"
"log" "log"
"os" "os"
"os/signal" "os/signal"
@@ -49,10 +48,9 @@ func main() {
if len(config.InitPubkeys) == 0 { if len(config.InitPubkeys) == 0 {
panic("init pubkeys are empty: impossible to initialize") panic("init pubkeys are empty: impossible to initialize")
} }
log.Println("initialize from empty database...") log.Println("initialize from empty database...")
nodes := make([]graph.ID, len(config.InitPubkeys))
nodes := make([]graph.ID, len(config.InitPubkeys))
for i, pk := range config.InitPubkeys { for i, pk := range config.InitPubkeys {
nodes[i], err = db.AddNode(ctx, pk) nodes[i], err = db.AddNode(ctx, pk)
if err != nil { if err != nil {
@@ -62,15 +60,11 @@ func main() {
pubkeys <- pk // add to queue pubkeys <- pk // add to queue
} }
walks, err := walks.Generate(ctx, db, nodes...) for _, node := range nodes {
if err != nil { if err := pipe.Promote(db, node); err != nil {
panic(err) panic(err)
} }
if err := db.AddWalks(ctx, walks...); err != nil {
panic(err)
} }
log.Printf("correctly added %d init pubkeys", len(config.InitPubkeys)) log.Printf("correctly added %d init pubkeys", len(config.InitPubkeys))
} }

View File

@@ -7,7 +7,6 @@ import (
"github/pippellia-btc/crawler/pkg/graph" "github/pippellia-btc/crawler/pkg/graph"
"github/pippellia-btc/crawler/pkg/pipe" "github/pippellia-btc/crawler/pkg/pipe"
"github/pippellia-btc/crawler/pkg/redb" "github/pippellia-btc/crawler/pkg/redb"
"github/pippellia-btc/crawler/pkg/walks"
"log" "log"
"os" "os"
"os/signal" "os/signal"
@@ -57,10 +56,9 @@ func main() {
if len(config.InitPubkeys) == 0 { if len(config.InitPubkeys) == 0 {
panic("init pubkeys are empty: impossible to initialize") panic("init pubkeys are empty: impossible to initialize")
} }
log.Println("initialize from empty database...") log.Println("initialize from empty database...")
nodes := make([]graph.ID, len(config.InitPubkeys))
nodes := make([]graph.ID, len(config.InitPubkeys))
for i, pk := range config.InitPubkeys { for i, pk := range config.InitPubkeys {
nodes[i], err = db.AddNode(ctx, pk) nodes[i], err = db.AddNode(ctx, pk)
if err != nil { if err != nil {
@@ -70,15 +68,11 @@ func main() {
pubkeys <- pk // add to queue pubkeys <- pk // add to queue
} }
walks, err := walks.Generate(ctx, db, nodes...) for _, node := range nodes {
if err != nil { if err := pipe.Promote(db, node); err != nil {
panic(err) panic(err)
} }
if err := db.AddWalks(ctx, walks...); err != nil {
panic(err)
} }
log.Printf("correctly added %d init pubkeys", len(config.InitPubkeys)) log.Printf("correctly added %d init pubkeys", len(config.InitPubkeys))
pipe.Kinds = []int{ pipe.Kinds = []int{