MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / cacheGetPeers

Function cacheGetPeers

client/driver.go:610–631  ·  view source on GitHub ↗
(dbID proto.DatabaseID, privKey *asymmetric.PrivateKey)

Source from the content-addressed store, hash-verified

608}
609
610func cacheGetPeers(dbID proto.DatabaseID, privKey *asymmetric.PrivateKey) (peers *proto.Peers, err error) {
611 var ok bool
612 var rawPeers interface{}
613 var cacheHit bool
614
615 defer func() {
616 log.WithFields(log.Fields{
617 "db": dbID,
618 "hit": cacheHit,
619 }).WithError(err).Debug("cache get peers for database")
620 }()
621
622 if rawPeers, ok = peerList.Load(dbID); ok {
623 if peers, ok = rawPeers.(*proto.Peers); ok {
624 cacheHit = true
625 return
626 }
627 }
628
629 // get peers using non-cache method
630 return getPeers(dbID, privKey)
631}
632
633func getPeers(dbID proto.DatabaseID, privKey *asymmetric.PrivateKey) (peers *proto.Peers, err error) {
634 defer func() {

Callers 1

newConnFunction · 0.85

Calls 4

WithFieldsFunction · 0.92
DebugMethod · 0.80
WithErrorMethod · 0.80
getPeersFunction · 0.70

Tested by

no test coverage detected