Skip to content

Commit

Permalink
remove obsolete code
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Nov 25, 2024
1 parent cda2d4d commit 8b8137a
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 200 deletions.
12 changes: 2 additions & 10 deletions src/BeehiveManager/Areas/Api/Controllers/ChainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,9 @@ namespace Etherna.BeehiveManager.Areas.Api.Controllers
[ApiController]
[ApiVersion("0.3")]
[Route("api/v{api-version:apiVersion}/[controller]")]
public class ChainController : ControllerBase
public class ChainController(IChainControllerService service)
: ControllerBase
{
// Fields.
private readonly IChainControllerService service;

// Constructor.
public ChainController(IChainControllerService service)
{
this.service = service;
}

// Get.

/// <summary>
Expand Down

This file was deleted.

30 changes: 3 additions & 27 deletions src/BeehiveManager/Areas/Api/Controllers/LoadBalancerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,13 @@ namespace Etherna.BeehiveManager.Areas.Api.Controllers
[ApiController]
[ApiVersion("0.3")]
[Route("api/v{api-version:apiVersion}/[controller]")]
public class LoadBalancerController : ControllerBase
public class LoadBalancerController(ILoadBalancerControllerService service)
: ControllerBase
{
// Fields.
private readonly ILoadBalancerControllerService service;

// Constructor.
public LoadBalancerController(ILoadBalancerControllerService service)
{
this.service = service;
}

// Get.

/// <summary>
/// Select an healthy bee node
/// Select a healthy bee node
/// </summary>
/// <response code="200">Bee node info</response>
[HttpGet]
Expand Down Expand Up @@ -90,22 +82,6 @@ public async Task<BeeNodeDto> SelectDownloadNodeAsync(
return beeNode;
}

/// <summary>
/// Select best node for download a specific content
/// </summary>
/// <response code="200">Selected Bee node</response>
[HttpGet("soc/{address}")]
[Obsolete("Dropped feature, no more necessary")]
[SimpleExceptionFilter]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<BeeNodeDto> SelectSocNodeAsync()
{
var beeNode = await service.SelectHealthyNodeAsync();
WriteNodeInfoInHeaders(beeNode); //nginx optimization
return beeNode;
}

// Helpers.
private void WriteNodeInfoInHeaders(BeeNodeDto beeNode)
{
Expand Down
11 changes: 1 addition & 10 deletions src/BeehiveManager/Areas/Api/Controllers/NodesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,8 @@ namespace Etherna.BeehiveManager.Areas.Api.Controllers
[ApiController]
[ApiVersion("0.3")]
[Route("api/v{api-version:apiVersion}/[controller]")]
public class NodesController : ControllerBase
public class NodesController(INodesControllerService service) : ControllerBase
{
// Fields.
private readonly INodesControllerService service;

// Constructor.
public NodesController(INodesControllerService service)
{
this.service = service;
}

// Get.

/// <summary>
Expand Down
11 changes: 1 addition & 10 deletions src/BeehiveManager/Areas/Api/Controllers/PinningController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,8 @@ namespace Etherna.BeehiveManager.Areas.Api.Controllers
[ApiController]
[ApiVersion("0.3")]
[Route("api/v{api-version:apiVersion}/[controller]")]
public class PinningController : ControllerBase
public class PinningController(IPinningControllerService service) : ControllerBase
{
// Fields.
private readonly IPinningControllerService service;

// Constructor.
public PinningController(IPinningControllerService service)
{
this.service = service;
}

// Get.

/// <summary>
Expand Down
46 changes: 3 additions & 43 deletions src/BeehiveManager/Areas/Api/Controllers/PostageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,20 @@
using Etherna.BeeNet.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Threading.Tasks;

namespace Etherna.BeehiveManager.Areas.Api.Controllers
{
[ApiController]
[ApiVersion("0.3")]
[Route("api/v{api-version:apiVersion}/[controller]")]
public class PostageController : ControllerBase
public class PostageController(
IPostageControllerService service)
: ControllerBase
{
// Fields.
private readonly ILoadBalancerControllerService loadBalancerService;
private readonly IPostageControllerService service;

// Constructor.
public PostageController(
ILoadBalancerControllerService loadBalancerService,
IPostageControllerService service)
{
this.loadBalancerService = loadBalancerService;
this.service = service;
}

// Get.

/// <summary>
/// Find bee node info by an owned postage batch Id
/// </summary>
/// <param name="id">Id of the postage batch</param>
/// <response code="200">Bee node info</response>
[HttpGet("batches/{id}/node")]
[Obsolete("Use instead API in LoadBalancerController")]
[SimpleExceptionFilter]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<BeeNodeDto> FindBeeNodeOwnerOfPostageBatchAsync(
[Required] string id)
{
var beeNodeInfo = await loadBalancerService.FindBeeNodeOwnerOfPostageBatchAsync(id);

// Copy response in headers (Nginx optimization).
HttpContext.Response.Headers.Append("bee-node-id", beeNodeInfo.Id);
HttpContext.Response.Headers.Append("bee-node-gateway-port", beeNodeInfo.GatewayPort.ToString(CultureInfo.InvariantCulture));
HttpContext.Response.Headers.Append("bee-node-hostname", beeNodeInfo.Hostname.ToString(CultureInfo.InvariantCulture));
HttpContext.Response.Headers.Append("bee-node-scheme", beeNodeInfo.ConnectionScheme);

return beeNodeInfo;
}

// Post.

/// <summary>
Expand Down Expand Up @@ -119,7 +81,5 @@ public async Task<string> TopUpPostageBatchAsync(
[Required] string id,
[Required] long amount) =>
(await service.TopUpPostageBatchAsync(id, BzzBalance.FromPlurLong(amount))).ToString();

// Delete.
}
}
30 changes: 0 additions & 30 deletions src/BeehiveManager/Areas/Api/DtoModels/EtherAddressDto.cs

This file was deleted.

13 changes: 2 additions & 11 deletions src/BeehiveManager/Areas/Api/Services/ChainControllerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,9 @@

namespace Etherna.BeehiveManager.Areas.Api.Services
{
public class ChainControllerService : IChainControllerService
public class ChainControllerService(IBeeNodeLiveManager liveManager)
: IChainControllerService
{
// Fields.
private readonly IBeeNodeLiveManager liveManager;

// Constructor.
public ChainControllerService(
IBeeNodeLiveManager liveManager)
{
this.liveManager = liveManager;
}

// Methods.
public ChainStateDto? GetChainState() =>
liveManager.ChainState is null ? null :
Expand Down

0 comments on commit 8b8137a

Please sign in to comment.