func (s *Service) ResolveAddress(addr hash.Hash) (*AddressInfo, error) {
	var info *AddressInfo
	// Fetch from cache if available
	if s.addressCache != nil {
		res, ok := s.addressCache.Get(addr.String())
		if ok {
			info = res.(*AddressInfo)
			logrus.Debugf("Resolving cached %s", addr.String())
		}
	}

	if info == nil {
		logrus.Debugf("Resolving address %s", addr.String())
		var err error
		info, err = s.repo.ResolveAddress(addr)
		if err != nil {
			logrus.Debugf("Error while resolving address %s: %s", addr.String(), err)
			return nil, err
		}

		// Store in cache if available
		if s.addressCache != nil {
			_ = s.addressCache.Add(addr.String(), info)
		}
	}

	// Resolve routing info, we often need it
	ri, err := s.repo.ResolveRouting(info.RoutingID)
	if err != nil {
		logrus.Debugf("Error while resolving routing %s for address %s: %s", info.RoutingID, addr.String(), err)
		return nil, err
	}
	info.RoutingInfo = *ri

	return info, err
}
// ResolveAddress resolves an address.
ResolveAddress resolves an address.
// ResolveAddress resolves an address .
func (s *Service) ResolveAddress(addr hash.Hash) (*AddressInfo, error) {
	var info *AddressInfo
	if s.addressCache != nil {
		res, ok := s.addressCache.Get(addr.String())
		if ok {
			info = res.(*AddressInfo)
			logrus.Debugf("Resolving cached %s", addr.String())
		}
	}
	if info == nil {
		logrus.Debugf("Resolving address %s", addr.String())
		var err error
		info, err = s.repo.ResolveAddress(addr)
		if err != nil {
			logrus.Debugf("Error while resolving address %s: %s", addr.String(), err)
			return nil, err
		}
		if s.addressCache != nil {
			_ = s.addressCache.Add(addr.String(), info)
		}
	}
	ri, err := s.repo.ResolveRouting(info.RoutingID)
	if err != nil {
		logrus.Debugf("Error while resolving routing %s for address %s: %s", info.RoutingID, addr.String(), err)
		return nil, err
	}
	info.RoutingInfo = *ri
	return info, err
}
func ( s * Service ) ResolveAddress ( addr hash . Hash ) ( * AddressInfo , error ) { var info * AddressInfo if s . addressCache != nil { res , ok := s . addressCache . Get ( addr . String ( ) ) if ok { info = res . ( * AddressInfo ) logrus . Debugf ( " " , addr . String ( ) ) } } if info == nil { logrus . Debugf ( " " , addr . String ( ) ) var err error info , err = s . repo . ResolveAddress ( addr ) if err != nil { logrus . Debugf ( " " , addr . String ( ) , err ) return nil , err } if s . addressCache != nil { _ = s . addressCache . Add ( addr . String ( ) , info ) } } ri , err := s . repo . ResolveRouting ( info . RoutingID ) if err != nil { logrus . Debugf ( " " , info . RoutingID , addr . String ( ) , err ) return nil , err } info . RoutingInfo = * ri return info , err }
ResolveAddress resolves an address.
ResolveAddress resolves an address .
// Fetch from cache if available // Store in cache if available // Resolve routing info, we often need it