mirror of
https://github.com/aljazceru/crawler_v2.git
synced 2025-12-17 07:24:21 +01:00
fixed double promotion bug
This commit is contained in:
@@ -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))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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{
|
||||||
|
|||||||
Reference in New Issue
Block a user