Skip to content

Commit

Permalink
again
Browse files Browse the repository at this point in the history
  • Loading branch information
renaynay committed May 30, 2023
1 parent 3146bde commit 7822805
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libs/pidstore/pidstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
)

var (
storePrefix = datastore.NewKey("peer_id_store")
storePrefix = datastore.NewKey("pidstore")
peersKey = datastore.NewKey("peers")

log = logging.Logger("peer_id_store")
log = logging.Logger("pidstore")
)

// PeerIDStore is used to store/load peers to/from disk.
Expand All @@ -36,13 +36,13 @@ func (p *PeerIDStore) Load(ctx context.Context) ([]peer.ID, error) {

bin, err := p.ds.Get(ctx, peersKey)
if err != nil {
return nil, fmt.Errorf("peer_id_store: loading peers from datastore: %w", err)
return nil, fmt.Errorf("pidstore: loading peers from datastore: %w", err)
}

var peers []peer.ID
err = json.Unmarshal(bin, &peers)
if err != nil {
return nil, fmt.Errorf("peer_id_store: unmarshalling peer IDs: %w", err)
return nil, fmt.Errorf("pidstore: unmarshalling peer IDs: %w", err)
}

log.Info("Loaded peers from disk", "amount", len(peers))
Expand All @@ -55,11 +55,11 @@ func (p *PeerIDStore) Put(ctx context.Context, peers []peer.ID) error {

bin, err := json.Marshal(peers)
if err != nil {
return fmt.Errorf("peer_id_store: marshal peerlist: %w", err)
return fmt.Errorf("pidstore: marshal peerlist: %w", err)
}

if err = p.ds.Put(ctx, peersKey, bin); err != nil {
return fmt.Errorf("peer_id_store:: error writing to datastore: %w", err)
return fmt.Errorf("pidstore:: error writing to datastore: %w", err)
}

log.Info("Persisted peers successfully", "amount", len(peers))
Expand Down

0 comments on commit 7822805

Please sign in to comment.