Skip to content

Commit

Permalink
feat: add name and caps to datastore peer (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
minhd-vu authored Oct 16, 2024
1 parent d41559a commit 6b4ba3c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions p2p/database/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"math/big"
"strings"
"time"

"cloud.google.com/go/datastore"
Expand Down Expand Up @@ -105,6 +106,8 @@ type DatastoreTransaction struct {
}

type DatastorePeer struct {
Name string
Caps string
URL string
LastSeenBy string
TimeLastSeen time.Time
Expand Down Expand Up @@ -262,6 +265,8 @@ func (d *Datastore) WritePeers(ctx context.Context, peers []*p2p.Peer) {
for _, peer := range peers {
keys = append(keys, datastore.NameKey(PeersKind, peer.ID().String(), nil))
dsPeers = append(dsPeers, &DatastorePeer{
Name: peer.Fullname(),
Caps: strings.Join(peer.Info().Caps, ","),
URL: peer.Node().URLv4(),
LastSeenBy: d.sensorID,
TimeLastSeen: now,
Expand Down

0 comments on commit 6b4ba3c

Please sign in to comment.