Skip to content

Commit

Permalink
fix: crawler update (#230)
Browse files Browse the repository at this point in the history
* fixed bug and updated db

* fixed bug and updated db

* updated peer update time

* removed enr
  • Loading branch information
sadiq1971 authored Oct 31, 2022
1 parent d0a1880 commit d253c50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 5 additions & 1 deletion models/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
LodestarClient ClientName = "lodestar"
NimbusClient ClientName = "nimbus"
TrinityClient ClientName = "trinity"
GrandineClient ClientName = "grandine"
OthersClient ClientName = "others"
)

Expand All @@ -49,6 +50,7 @@ func init() {
LodestarClient: {"lodestar", "js-libp2p"},
NimbusClient: {"nimbus"},
TrinityClient: {"trinity"},
GrandineClient: {"grandine", "rust"},
}
}

Expand Down Expand Up @@ -128,7 +130,7 @@ func (s *Sync) String() string {
return StatusUnsynced
}

// Peer holds all information of a eth2 peer
// Peer holds all information of an eth2 peer
type Peer struct {
ID peer.ID `json:"id" bson:"_id"`
NodeID string `json:"node_id" bson:"node_id"`
Expand All @@ -142,6 +144,7 @@ type Peer struct {
Attnets common.AttnetBits `json:"enr_attnets,omitempty" bson:"attnets"`

ForkDigest common.ForkDigest `json:"fork_digest" bson:"fork_digest"`
ForkDigestStr string `json:"fork_digest_str" bson:"fork_digest_str"`
NextForkEpoch Epoch `json:"next_fork_epoch" bson:"next_fork_epoch"`
NextForkVersion common.Version `json:"next_fork_version" bson:"next_fork_version"`

Expand Down Expand Up @@ -188,6 +191,7 @@ func NewPeer(node *enode.Node, eth2Data *common.Eth2Data) (*Peer, error) {
UDPPort: node.UDP(),
Addrs: addrStr,
ForkDigest: eth2Data.ForkDigest,
ForkDigestStr: eth2Data.ForkDigest.String(),
NextForkVersion: eth2Data.NextForkVersion,
NextForkEpoch: Epoch(eth2Data.NextForkEpoch),
Attnets: attnetsVal,
Expand Down
3 changes: 1 addition & 2 deletions store/peerstore/mongo/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ func (s *mongoStore) Create(ctx context.Context, peer *models.Peer) error {
}
return err
}
// if found update the peer with the latest data
return s.Update(ctx, peer)
return nil
}

func (s *mongoStore) Update(ctx context.Context, peer *models.Peer) error {
Expand Down

0 comments on commit d253c50

Please sign in to comment.