Skip to content

Commit

Permalink
fixed merge code failed
Browse files Browse the repository at this point in the history
  • Loading branch information
mamafunny committed Oct 14, 2024
1 parent 2e38c17 commit 5bb57c3
Show file tree
Hide file tree
Showing 37 changed files with 68 additions and 2,672 deletions.
4 changes: 0 additions & 4 deletions build-ubuntu-22.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

# install dev-dependencies
sudo apt-get update; \
<<<<<<< HEAD
sudo apt-get -y install dotnet6 git cmake ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libgmp-dev
=======
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libgmp-dev libc++-dev
>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec

(cd src/Miningcore && \
BUILDIR=${1:-../../build} && \
Expand Down
85 changes: 1 addition & 84 deletions src/Miningcore.Tests/Miningcore.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,85 +1,3 @@
<<<<<<< HEAD
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
</PropertyGroup>

<PropertyGroup>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<Platforms>AnyCPU</Platforms>
<AssemblyName>Miningcore.Tests</AssemblyName>
<RootNamespace>Miningcore.Tests</RootNamespace>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
<Compile Remove="JsonRpc\**" />
<EmbeddedResource Remove="JsonRpc\**" />
<None Remove="JsonRpc\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.4" />
<PackageReference Include="BenchmarkDotNet.Annotations" Version="0.13.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Microsoft.Reactive.Testing" Version="5.0.0" />
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="Npgsql" Version="7.0.7" />
<PackageReference Include="NSubstitute" Version="4.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Miningcore\Miningcore.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="test.runsettings">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<!-- Copy library binaries from Miningcore build output on Windows -->
<Target Name="CopyLibsWin" AfterTargets="AfterBuild" Condition="'$(IsWindows)' == 'true'">
<ItemGroup>
<Libs Include="$(ProjectDir)..\Miningcore\bin\$(Configuration)\net6.0\lib*.dll" />
</ItemGroup>

<Copy SourceFiles="@(Libs)" DestinationFolder="$(OutDir)" />
</Target>

<!-- Copy library binaries from Miningcore build output on Linux -->
<Target Name="CopyLibsLinux" AfterTargets="AfterBuild" Condition="'$(IsLinux)' == 'true'">
<ItemGroup>
<Libs Include="$(ProjectDir)..\Miningcore\bin\$(Configuration)\net6.0\lib*.so" />
</ItemGroup>

<Copy SourceFiles="@(Libs)" DestinationFolder="$(OutDir)" />
</Target>
</Project>
=======
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
Expand Down Expand Up @@ -159,5 +77,4 @@

<Copy SourceFiles="@(Libs)" DestinationFolder="$(OutDir)" />
</Target>
</Project>
>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec
</Project>
52 changes: 7 additions & 45 deletions src/Miningcore/Api/Controllers/PoolApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,16 @@ public async Task<GetPoolsResponse> Get(CancellationToken ct, [FromQuery] uint t
result.TotalBlocks = await cf.Run(con => blocksRepo.GetPoolBlockCountAsync(con, config.Id, ct));
result.TotalConfirmedBlocks = await cf.Run(con => blocksRepo.GetTotalConfirmedBlocksAsync(con, config.Id, ct));
result.TotalPendingBlocks = await cf.Run(con => blocksRepo.GetTotalPendingBlocksAsync(con, config.Id, ct));
<<<<<<< HEAD
// Get reward of the last confirmed block and set BlockReward
result.BlockReward = await cf.Run(con => blocksRepo.GetLastConfirmedBlockRewardAsync(con, config.Id, ct));
var lastBlockTime = await cf.Run(con => blocksRepo.GetLastPoolBlockTimeAsync(con, config.Id));
=======
// get reward of the last confirmed block and set BlockReward
result.BlockReward = await cf.Run(con => blocksRepo.GetLastConfirmedBlockRewardAsync(con, config.Id, ct));
var lastBlockTime = await cf.Run(con => blocksRepo.GetLastPoolBlockTimeAsync(con, config.Id, ct));
>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec
result.LastPoolBlockTime = lastBlockTime;
if(lastBlockTime.HasValue)
{
var startTime = lastBlockTime.Value;
<<<<<<< HEAD
var poolEffort = await cf.Run(con => shareRepo.GetEffortBetweenCreatedAsync(con, config.Id, startTime, clock.Now));
var poolEffort = await cf.Run(con => shareRepo.GetEffortBetweenCreatedAsync(con, config.Id, pool.ShareMultiplier, startTime, clock.Now, ct));
//kaspa effort fix start here
// If the effort is less than 1e-8, multiply it by 4e9
Expand All @@ -97,9 +89,6 @@ public async Task<GetPoolsResponse> Get(CancellationToken ct, [FromQuery] uint t
}
//kaspa effort fix end here
=======
var poolEffort = await cf.Run(con => shareRepo.GetEffortBetweenCreatedAsync(con, config.Id, pool.ShareMultiplier, startTime, clock.Now, ct));
>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec
if(poolEffort.HasValue)
result.PoolEffort = poolEffort.Value;
}
Expand Down Expand Up @@ -164,24 +153,15 @@ public async Task<GetPoolResponse> GetPoolInfoAsync(string poolId, CancellationT
response.Pool.TotalBlocks = await cf.Run(con => blocksRepo.GetPoolBlockCountAsync(con, pool.Id, ct));
response.Pool.TotalConfirmedBlocks = await cf.Run(con => blocksRepo.GetTotalConfirmedBlocksAsync(con, pool.Id, ct));
response.Pool.TotalPendingBlocks = await cf.Run(con => blocksRepo.GetTotalPendingBlocksAsync(con, pool.Id, ct));
<<<<<<< HEAD

// Get reward of the last confirmed block and set BlockReward
response.Pool.BlockReward = await cf.Run(con => blocksRepo.GetLastConfirmedBlockRewardAsync(con, pool.Id, ct));

var lastBlockTime = await cf.Run(con => blocksRepo.GetLastPoolBlockTimeAsync(con, pool.Id));
=======
// get reward of the last confirmed block and set BlockReward
response.Pool.BlockReward = await cf.Run(con => blocksRepo.GetLastConfirmedBlockRewardAsync(con, pool.Id, ct));
var lastBlockTime = await cf.Run(con => blocksRepo.GetLastPoolBlockTimeAsync(con, pool.Id, ct));
>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec
response.Pool.LastPoolBlockTime = lastBlockTime;

if(lastBlockTime.HasValue)
{
var startTime = lastBlockTime.Value;
<<<<<<< HEAD
var poolEffort = await cf.Run(con => shareRepo.GetEffortBetweenCreatedAsync(con, pool.Id, startTime, clock.Now));
var poolEffort = await cf.Run(con => shareRepo.GetEffortBetweenCreatedAsync(con, pool.Id, poolInstance.ShareMultiplier, startTime, clock.Now, ct));

//kaspa effort fix start here
// If the effort is less than 1e-8, multiply it by 4e9
Expand All @@ -191,9 +171,6 @@ public async Task<GetPoolResponse> GetPoolInfoAsync(string poolId, CancellationT
}
//kaspa effort fix end here

=======
var poolEffort = await cf.Run(con => shareRepo.GetEffortBetweenCreatedAsync(con, pool.Id, poolInstance.ShareMultiplier, startTime, clock.Now, ct));
>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec
if(poolEffort.HasValue)
response.Pool.PoolEffort = poolEffort.Value;
}
Expand Down Expand Up @@ -471,12 +448,11 @@ public async Task<MinerPerformanceStats[]> PagePoolMinersAsync(
stats.LastPaymentLink = string.Format(baseUrl, statsResult.LastPayment.TransactionConfirmationData);
}

<<<<<<< HEAD
var lastBlockTime = await cf.Run(con => blocksRepo.GetLastMinerBlockTimeAsync(con, pool.Id, address));
var lastBlockTime = await cf.Run(con => blocksRepo.GetLastPoolBlockTimeAsync(con, pool.Id, ct));
if(lastBlockTime.HasValue)
{
var startTime = lastBlockTime.Value;
var minerEffort = await cf.Run(con => shareRepo.GetMinerEffortBetweenCreatedAsync(con, pool.Id, address, startTime, clock.Now));
{
var startTime = lastBlockTime.Value;
var minerEffort = await cf.Run(con => shareRepo.GetMinerEffortBetweenCreatedAsync(con, pool.Id, address, startTime, clock.Now, ct));

//kaspa effort fix start here
// If the effort is less than 1e-8, multiply it by 4e9
Expand All @@ -486,27 +462,13 @@ public async Task<MinerPerformanceStats[]> PagePoolMinersAsync(
}
//kaspa effort fix end here

if(minerEffort.HasValue)
stats.MinerEffort = minerEffort.Value;
}

stats.PerformanceSamples = await GetMinerPerformanceInternal(perfMode, pool, address, ct);

// Add total confirmed and pending blocks
=======
var lastBlockTime = await cf.Run(con => blocksRepo.GetLastPoolBlockTimeAsync(con, pool.Id, ct));
if(lastBlockTime.HasValue)
{
var startTime = lastBlockTime.Value;
var minerEffort = await cf.Run(con => shareRepo.GetMinerEffortBetweenCreatedAsync(con, pool.Id, address, startTime, clock.Now, ct));
if(minerEffort.HasValue)
stats.MinerEffort = minerEffort.Value;
}

stats.PerformanceSamples = await GetMinerPerformanceInternal(perfMode, pool, address, ct);

// add total confirmed and pending blocks
>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec
var totalConfirmedBlocks = await cf.Run(con => statsRepo.GetMinerTotalConfirmedBlocksAsync(con, pool.Id, address, ct));
var totalPendingBlocks = await cf.Run(con => statsRepo.GetMinerTotalPendingBlocksAsync(con, pool.Id, address, ct));
stats.TotalConfirmedBlocks = totalConfirmedBlocks;
Expand Down
4 changes: 0 additions & 4 deletions src/Miningcore/Api/Responses/GetPoolsResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ public partial class PoolInfo
public uint TotalBlocks { get; set; }
public uint TotalConfirmedBlocks { get; set; }
public uint TotalPendingBlocks { get; set; }
<<<<<<< HEAD
public decimal BlockReward { get; set; } // BlockReward as decimal
=======
public decimal BlockReward { get; set; }
>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec
public DateTime? LastPoolBlockTime { get; set; }
public double PoolEffort { get; set; }
}
Expand Down
18 changes: 1 addition & 17 deletions src/Miningcore/Blockchain/Bitcoin/BitcoinJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ protected virtual Transaction CreateOutputTransaction()
if(coin.HasCoinbaseDevReward)
rewardToPool = CreateCoinbaseDevRewardOutputs(tx, rewardToPool);

<<<<<<< HEAD
if(coin.HasFoundation)
rewardToPool = CreateFoundationOutputs(tx, rewardToPool);

Expand All @@ -356,8 +355,6 @@ protected virtual Transaction CreateOutputTransaction()
if(coin.HasDeveloper)
rewardToPool = CreateDeveloperOutputs(tx, rewardToPool);

=======
>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec
// Remaining amount goes to pool
tx.Outputs.Add(rewardToPool, poolAddressDestination);

Expand Down Expand Up @@ -820,11 +817,7 @@ protected virtual Money CreateCoinbaseDevRewardOutputs(Transaction tx, Money rew
{
if(!string.IsNullOrEmpty(CBReward.ScriptPubkey))
{
<<<<<<< HEAD
Script payeeAddress = new (CBReward.ScriptPubkey.HexToByteArray());
=======
Script payeeAddress = new Script(CBReward.ScriptPubkey.HexToByteArray());
>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec
var payeeReward = CBReward.Value;
tx.Outputs.Add(payeeReward, payeeAddress);
}
Expand All @@ -835,7 +828,6 @@ protected virtual Money CreateCoinbaseDevRewardOutputs(Transaction tx, Money rew

#endregion // CoinbaseDevReward

<<<<<<< HEAD
#region Foundation

protected FoundationBlockTemplateExtra foundationParameters;
Expand Down Expand Up @@ -870,8 +862,6 @@ protected virtual Money CreateFoundationOutputs(Transaction tx, Money reward)

#endregion // Foundation

=======
>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec
#region API-Surface

public BlockTemplate BlockTemplate { get; protected set; }
Expand Down Expand Up @@ -970,18 +960,12 @@ public void Init(BlockTemplate blockTemplate, string jobId,
if (coin.HasMinerFund)
minerFundParameters = BlockTemplate.Extra.SafeExtensionDataAs<MinerFundTemplateExtra>("coinbasetxn", "minerfund");

<<<<<<< HEAD
if(coin.HasCoinbaseDevReward)
CoinbaseDevRewardParams = BlockTemplate.Extra.SafeExtensionDataAs<CoinbaseDevRewardTemplateExtra>();

if(coin.HasFoundation)
if(coin.HasFoundation)
foundationParameters = BlockTemplate.Extra.SafeExtensionDataAs<FoundationBlockTemplateExtra>();

=======
if(coin.HasCoinbaseDevReward)
CoinbaseDevRewardParams = BlockTemplate.Extra.SafeExtensionDataAs<CoinbaseDevRewardTemplateExtra>();

>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec
this.coinbaseHasher = coinbaseHasher;
this.headerHasher = headerHasher;
this.blockHasher = blockHasher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,12 @@ namespace Miningcore.Blockchain.Bitcoin.DaemonResponses
public class CoinbaseDevReward
{
public string ScriptPubkey { get; set; }
<<<<<<< HEAD
public long Value { get; set; }
=======
public long Value { get; set; }
>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec
}

public class CoinbaseDevRewardTemplateExtra
{
<<<<<<< HEAD
public JToken CoinbaseDevReward { get; set; }
}
}
=======
[JsonProperty("coinbasedevreward")]
public JToken CoinbaseDevReward { get; set; }
}
}
>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public class EthereumPoolConfigExtra
/// Useful to specify the real chain type when running geth
/// </summary>
public string ChainTypeOverride { get; set; }
<<<<<<< HEAD
=======

/// <summary>
/// There are several reports of bad actors taking advantage of the old "Ethash Stratum V1" protocol in order to perform multiple dangerous attacks like man-in-the-middle (MITM) attacks
Expand All @@ -25,7 +23,6 @@ public class EthereumPoolConfigExtra
/// "Ethash Stratum V1" protocol is disabled by default
/// </summary>
public bool EnableEthashStratumV1 { get; set; } = false;
>>>>>>> 69de0d393ec56f3e0535f3b09f6de93d6299beec

/// <summary>
/// getWork stream published via ZMQ
Expand Down
Loading

0 comments on commit 5bb57c3

Please sign in to comment.