satellite/overlay: delete unused method
Change-Id: I87828fcac4f4a9fb08c86af188aa6ea28c5c64af
This commit is contained in:
parent
ad9b0dfc40
commit
9e3fd4d514
@ -47,8 +47,6 @@ var ErrLowDifficulty = errs.Class("node id difficulty too low")
|
||||
//
|
||||
// architecture: Database
|
||||
type DB interface {
|
||||
// GetOnlineNodesForGetDelete returns a map of nodes for the supplied nodeIDs
|
||||
GetOnlineNodesForGetDelete(ctx context.Context, nodeIDs []storj.NodeID, onlineWindow time.Duration, asOf AsOfSystemTimeConfig) (map[storj.NodeID]*SelectedNode, error)
|
||||
// GetOnlineNodesForAuditRepair returns a map of nodes for the supplied nodeIDs.
|
||||
// The return value contains necessary information to create orders as well as nodes'
|
||||
// current reputation status.
|
||||
@ -396,13 +394,6 @@ func (service *Service) Get(ctx context.Context, nodeID storj.NodeID) (_ *NodeDo
|
||||
return service.db.Get(ctx, nodeID)
|
||||
}
|
||||
|
||||
// GetOnlineNodesForGetDelete returns a map of nodes for the supplied nodeIDs.
|
||||
func (service *Service) GetOnlineNodesForGetDelete(ctx context.Context, nodeIDs []storj.NodeID) (_ map[storj.NodeID]*SelectedNode, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
return service.db.GetOnlineNodesForGetDelete(ctx, nodeIDs, service.config.Node.OnlineWindow, service.config.Node.AsOfSystemTime)
|
||||
}
|
||||
|
||||
// CachedGetOnlineNodesForGet returns a map of nodes from the download selection cache from the suppliedIDs.
|
||||
func (service *Service) CachedGetOnlineNodesForGet(ctx context.Context, nodeIDs []storj.NodeID) (_ map[storj.NodeID]*SelectedNode, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
@ -388,47 +388,6 @@ func TestNodeInfo(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetOnlineNodesForGetDelete(t *testing.T) {
|
||||
testplanet.Run(t, testplanet.Config{
|
||||
SatelliteCount: 1, StorageNodeCount: 2, UplinkCount: 0,
|
||||
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||
// pause chores that might update node data
|
||||
planet.Satellites[0].RangedLoop.RangedLoop.Service.Loop.Stop()
|
||||
planet.Satellites[0].Repair.Repairer.Loop.Pause()
|
||||
for _, node := range planet.StorageNodes {
|
||||
node.Contact.Chore.Pause(ctx)
|
||||
}
|
||||
|
||||
// should not return anything if nodeIDs aren't in the nodes table
|
||||
actualNodes, err := planet.Satellites[0].Overlay.Service.GetOnlineNodesForGetDelete(ctx, []storj.NodeID{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 0, len(actualNodes))
|
||||
actualNodes, err = planet.Satellites[0].Overlay.Service.GetOnlineNodesForGetDelete(ctx, []storj.NodeID{testrand.NodeID()})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 0, len(actualNodes))
|
||||
|
||||
expectedNodes := make(map[storj.NodeID]*overlay.SelectedNode, len(planet.StorageNodes))
|
||||
nodeIDs := make([]storj.NodeID, len(planet.StorageNodes)+1)
|
||||
for i, node := range planet.StorageNodes {
|
||||
nodeIDs[i] = node.ID()
|
||||
dossier, err := planet.Satellites[0].Overlay.Service.Get(ctx, node.ID())
|
||||
require.NoError(t, err)
|
||||
expectedNodes[dossier.Id] = &overlay.SelectedNode{
|
||||
ID: dossier.Id,
|
||||
Address: dossier.Address,
|
||||
LastNet: dossier.LastNet,
|
||||
LastIPPort: dossier.LastIPPort,
|
||||
}
|
||||
}
|
||||
// add a fake node ID to make sure GetOnlineNodesForGetDelete doesn't error and still returns the expected nodes.
|
||||
nodeIDs[len(planet.StorageNodes)] = testrand.NodeID()
|
||||
|
||||
actualNodes, err = planet.Satellites[0].Overlay.Service.GetOnlineNodesForGetDelete(ctx, nodeIDs)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, expectedNodes, actualNodes)
|
||||
})
|
||||
}
|
||||
|
||||
func TestKnownReliable(t *testing.T) {
|
||||
testplanet.Run(t, testplanet.Config{
|
||||
SatelliteCount: 1, StorageNodeCount: 6, UplinkCount: 1,
|
||||
|
@ -266,62 +266,6 @@ func (cache *overlaycache) Get(ctx context.Context, id storj.NodeID) (dossier *o
|
||||
return convertDBNode(ctx, node)
|
||||
}
|
||||
|
||||
// GetOnlineNodesForGetDelete returns a map of nodes for the supplied nodeIDs.
|
||||
func (cache *overlaycache) GetOnlineNodesForGetDelete(ctx context.Context, nodeIDs []storj.NodeID, onlineWindow time.Duration, asOf overlay.AsOfSystemTimeConfig) (nodes map[storj.NodeID]*overlay.SelectedNode, err error) {
|
||||
for {
|
||||
nodes, err = cache.getOnlineNodesForGetDelete(ctx, nodeIDs, onlineWindow, asOf)
|
||||
if err != nil {
|
||||
if cockroachutil.NeedsRetry(err) {
|
||||
continue
|
||||
}
|
||||
return nodes, err
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
return nodes, err
|
||||
}
|
||||
|
||||
func (cache *overlaycache) getOnlineNodesForGetDelete(ctx context.Context, nodeIDs []storj.NodeID, onlineWindow time.Duration, asOf overlay.AsOfSystemTimeConfig) (_ map[storj.NodeID]*overlay.SelectedNode, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
var rows tagsql.Rows
|
||||
rows, err = cache.db.Query(ctx, cache.db.Rebind(`
|
||||
SELECT last_net, id, address, last_ip_port, noise_proto, noise_public_key, debounce_limit, features
|
||||
FROM nodes
|
||||
`+cache.db.impl.AsOfSystemInterval(asOf.Interval())+`
|
||||
WHERE id = any($1::bytea[])
|
||||
AND disqualified IS NULL
|
||||
AND exit_finished_at IS NULL
|
||||
AND last_contact_success > $2
|
||||
`), pgutil.NodeIDArray(nodeIDs), time.Now().Add(-onlineWindow))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() { err = errs.Combine(err, rows.Close()) }()
|
||||
|
||||
nodes := make(map[storj.NodeID]*overlay.SelectedNode)
|
||||
for rows.Next() {
|
||||
var node overlay.SelectedNode
|
||||
node.Address = &pb.NodeAddress{}
|
||||
|
||||
var lastIPPort sql.NullString
|
||||
var noise noiseScanner
|
||||
err = rows.Scan(&node.LastNet, &node.ID, &node.Address.Address, &lastIPPort, &noise.Proto, &noise.PublicKey, &node.Address.DebounceLimit, &node.Address.Features)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if lastIPPort.Valid {
|
||||
node.LastIPPort = lastIPPort.String
|
||||
}
|
||||
node.Address.NoiseInfo = noise.Convert()
|
||||
|
||||
nodes[node.ID] = &node
|
||||
}
|
||||
|
||||
return nodes, Error.Wrap(rows.Err())
|
||||
}
|
||||
|
||||
// GetOnlineNodesForAuditRepair returns a map of nodes for the supplied nodeIDs.
|
||||
func (cache *overlaycache) GetOnlineNodesForAuditRepair(ctx context.Context, nodeIDs []storj.NodeID, onlineWindow time.Duration) (nodes map[storj.NodeID]*overlay.NodeReputation, err error) {
|
||||
for {
|
||||
|
Loading…
Reference in New Issue
Block a user