Set up -> Stream is Working
This commit is contained in:
@@ -15,8 +15,10 @@ import (
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
"cloud.o-forge.io/core/oc-lib/models/peer"
|
||||
"github.com/google/uuid"
|
||||
"github.com/libp2p/go-libp2p"
|
||||
pubsubs "github.com/libp2p/go-libp2p-pubsub"
|
||||
"github.com/libp2p/go-libp2p/core/crypto"
|
||||
pp "github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
|
||||
@@ -53,6 +55,7 @@ func InitNode(isNode bool, isIndexer bool) (*Node, error) {
|
||||
fmt.Sprintf("/ip4/0.0.0.0/tcp/%d", conf.GetConfig().NodeEndpointPort),
|
||||
),
|
||||
)
|
||||
logger.Info().Msg("Host open on " + h.ID().String())
|
||||
if err != nil {
|
||||
return nil, errors.New("no host no node")
|
||||
}
|
||||
@@ -72,7 +75,9 @@ func InitNode(isNode bool, isIndexer bool) (*Node, error) {
|
||||
logger.Info().Msg("connect to indexers...")
|
||||
common.ConnectToIndexers(node.Host, 0, 5, node.PeerID) // TODO : make var to change how many indexers are allowed.
|
||||
logger.Info().Msg("claims my node...")
|
||||
node.claimInfo(conf.GetConfig().Name, conf.GetConfig().Hostname)
|
||||
if _, err := node.claimInfo(conf.GetConfig().Name, conf.GetConfig().Hostname); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
logger.Info().Msg("subscribe to decentralized search flow...")
|
||||
node.SubscribeToSearch(node.PS)
|
||||
logger.Info().Msg("run garbage collector...")
|
||||
@@ -189,25 +194,21 @@ func (d *Node) claimInfo(
|
||||
if endPoint == "" {
|
||||
return nil, errors.New("no endpoint found for peer")
|
||||
}
|
||||
|
||||
peerID, err := oclib.GenerateNodeID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
peerID := uuid.New().String()
|
||||
priv, err := common.LoadKeyFromFilePrivate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pub, err := common.LoadKeyFromFilePublic()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pubBytes, err := crypto.MarshalPublicKey(pub)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pubBytes, _ := pub.Raw()
|
||||
|
||||
now := time.Now()
|
||||
now := time.Now().UTC()
|
||||
expiry := now.Add(150 * time.Second)
|
||||
|
||||
rec := &indexer.PeerRecord{
|
||||
@@ -236,10 +237,11 @@ func (d *Node) claimInfo(
|
||||
if err := d.publishPeerRecord(rec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if pk, err := rec.Verify(); err != nil {
|
||||
/*if pk, err := rec.Verify(); err != nil {
|
||||
fmt.Println("Verify")
|
||||
return nil, err
|
||||
} else {
|
||||
_, p, err := rec.ExtractPeer(peerID, peerID, pk)
|
||||
return p, err
|
||||
}
|
||||
} else {*/
|
||||
_, p, err := rec.ExtractPeer(peerID, peerID, pub)
|
||||
return p, err
|
||||
//}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user