mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2025-01-14 02:30:05 +08:00
commit
9827ee0860
@ -3,11 +3,12 @@ package pstoreds
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/libp2p/go-libp2p-core/record"
|
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p-core/record"
|
||||||
|
|
||||||
ds "github.com/ipfs/go-datastore"
|
ds "github.com/ipfs/go-datastore"
|
||||||
"github.com/ipfs/go-datastore/query"
|
"github.com/ipfs/go-datastore/query"
|
||||||
logging "github.com/ipfs/go-log"
|
logging "github.com/ipfs/go-log"
|
||||||
@ -17,7 +18,7 @@ import (
|
|||||||
pb "github.com/libp2p/go-libp2p-peerstore/pb"
|
pb "github.com/libp2p/go-libp2p-peerstore/pb"
|
||||||
"github.com/libp2p/go-libp2p-peerstore/pstoremem"
|
"github.com/libp2p/go-libp2p-peerstore/pstoremem"
|
||||||
|
|
||||||
"github.com/hashicorp/golang-lru"
|
lru "github.com/hashicorp/golang-lru"
|
||||||
b32 "github.com/multiformats/go-base32"
|
b32 "github.com/multiformats/go-base32"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "github.com/multiformats/go-multiaddr"
|
||||||
)
|
)
|
||||||
@ -316,6 +317,8 @@ func (ab *dsAddrBook) storeSignedPeerRecord(p peer.ID, envelope *record.Envelope
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
pr.Lock()
|
||||||
|
defer pr.Unlock()
|
||||||
pr.CertifiedRecord = &pb.AddrBookRecord_CertifiedRecord{
|
pr.CertifiedRecord = &pb.AddrBookRecord_CertifiedRecord{
|
||||||
Seq: rec.Seq,
|
Seq: rec.Seq,
|
||||||
Raw: envelopeBytes,
|
Raw: envelopeBytes,
|
||||||
@ -334,6 +337,8 @@ func (ab *dsAddrBook) GetPeerRecord(p peer.ID) *record.Envelope {
|
|||||||
log.Errorf("unable to load record for peer %s: %v", p.Pretty(), err)
|
log.Errorf("unable to load record for peer %s: %v", p.Pretty(), err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
pr.RLock()
|
||||||
|
defer pr.RUnlock()
|
||||||
if pr.CertifiedRecord == nil || len(pr.CertifiedRecord.Raw) == 0 || len(pr.Addrs) == 0 {
|
if pr.CertifiedRecord == nil || len(pr.CertifiedRecord.Raw) == 0 || len(pr.Addrs) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user