Skip to content

Commit

Permalink
Revert "MWEB support and syncing issues fix for LTC"
Browse files Browse the repository at this point in the history
This reverts commit 08f08db.
  • Loading branch information
xiaolin1579 committed Oct 20, 2023
1 parent 08f08db commit 39b17d7
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 89 deletions.
3 changes: 1 addition & 2 deletions examples/litecoin_dash_pool.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@
"payoutSchemeConfig": {
"factor": 2.0
}
},
"addressType": "litecoin"
}
},
{
"id": "dash1",
Expand Down
3 changes: 1 addition & 2 deletions examples/litecoin_pool.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
"payoutSchemeConfig": {
"factor": 2.0
}
},
"addressType": "litecoin"
}
}]
}
5 changes: 0 additions & 5 deletions src/Miningcore/Blockchain/Bitcoin/BitcoinConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ public enum BitcoinAddressType
/// Bitcoin Cash
/// </summary>
BCash,

/// <summary>
/// Litecoin
/// </summary>
Litecoin
}

public enum BitcoinTransactionCategory
Expand Down
14 changes: 1 addition & 13 deletions src/Miningcore/Blockchain/Bitcoin/BitcoinJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ protected virtual Transaction CreateOutputTransaction()
if (coin.HasCommunityAddress)
rewardToPool = CreateCommunityAddressOutputs(tx, rewardToPool);

if(coin.HasCoinbaseDevReward)
if (coin.HasCoinbaseDevReward)
rewardToPool = CreateCoinbaseDevRewardOutputs(tx, rewardToPool);

if(coin.HasFounderReward)
Expand Down Expand Up @@ -434,18 +434,6 @@ protected virtual byte[] SerializeBlock(byte[] header, byte[] coinbase)
// POS coins require a zero byte appended to block which the daemon replaces with the signature
if(isPoS)
bs.ReadWrite((byte) 0);

// if pool supports MWEB, we have to append the MWEB data to the block
// https://github.com/litecoin-project/litecoin/blob/0.21/doc/mweb/mining-changes.md
if(coin.HasMWEB)
{
var separator = new byte[] { 0x01 };
var mweb = BlockTemplate.Extra.SafeExtensionDataAs<MwebBlockTemplateExtra>();
var mwebRaw = mweb.Mweb.HexToByteArray();

bs.ReadWrite(ref separator);
bs.ReadWrite(ref mwebRaw);
}

return stream.ToArray();
}
Expand Down
49 changes: 2 additions & 47 deletions src/Miningcore/Blockchain/Bitcoin/BitcoinJobManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using Org.BouncyCastle.Crypto.Parameters;

namespace Miningcore.Blockchain.Bitcoin;

Expand All @@ -34,61 +33,17 @@ protected override object[] GetBlockTemplateParams()
{
var result = base.GetBlockTemplateParams();

if(coin.HasMWEB)
{
result = new object[]
{
new
{
rules = new[] {"segwit", "mweb"},
}
};
}

if(coin.BlockTemplateRpcExtraParams != null)
{
if(coin.BlockTemplateRpcExtraParams.Type == JTokenType.Array)
result = result.Concat(coin.BlockTemplateRpcExtraParams.ToObject<object[]>() ?? Array.Empty<object>()).ToArray();
else
result = result.Concat(new[] { coin.BlockTemplateRpcExtraParams.ToObject<object>()}).ToArray();
result = result.Concat(new []{ coin.BlockTemplateRpcExtraParams.ToObject<object>()}).ToArray();
}

return result;
}

protected override async Task EnsureDaemonsSynchedAsync(CancellationToken ct)
{
using var timer = new PeriodicTimer(TimeSpan.FromSeconds(5));

var syncPendingNotificationShown = false;

do
{
var response = await rpc.ExecuteAsync<BlockTemplate>(logger,
BitcoinCommands.GetBlockTemplate, ct, GetBlockTemplateParams());

var isSynched = response.Error == null;

if(isSynched)
{
logger.Info(() => "All daemons synched with blockchain");
break;
}
else
{
logger.Debug(() => $"Daemon reports error: {response.Error?.Message}");
}

if(!syncPendingNotificationShown)
{
logger.Info(() => "Daemon is still syncing with network. Manager will be started once synced.");
syncPendingNotificationShown = true;
}

await ShowDaemonSyncProgressAsync(ct);
} while(await timer.WaitForNextTickAsync(ct));
}

protected async Task<RpcResponse<BlockTemplate>> GetBlockTemplateAsync(CancellationToken ct)
{
var result = await rpc.ExecuteAsync<BlockTemplate>(logger,
Expand Down Expand Up @@ -116,7 +71,7 @@ protected override void PostChainIdentifyConfigure()
if(poolConfig.EnableInternalStratum == true && coin.HeaderHasherValue is IHashAlgorithmInit hashInit)
{
if(!hashInit.DigestInit(poolConfig))
logger.Error(() => $"{hashInit.GetType().Name} initialization failed");
logger.Error(()=> $"{hashInit.GetType().Name} initialization failed");
}
}

Expand Down
7 changes: 1 addition & 6 deletions src/Miningcore/Blockchain/Bitcoin/BitcoinJobManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,7 @@ protected override async Task<bool> AreDaemonsHealthyAsync(CancellationToken ct)

var response = await rpc.ExecuteAsync<BlockchainInfo>(logger, BitcoinCommands.GetBlockchainInfo, ct);

if(response.Error != null)
{
logger.Error(() => $"Daemon reports: {response.Error.Message}");
return false;
}
return true;
return response.Error == null;
}

protected override async Task<bool> AreDaemonsConnectedAsync(CancellationToken ct)
Expand Down
1 change: 1 addition & 0 deletions src/Miningcore/Blockchain/Bitcoin/BitcoinUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ public static IDestination LitecoinAddressToDestination(string address, Network
Debug.Assert(result.GetAddress(litecoin).ToString() == address);
return result;
}

}
6 changes: 0 additions & 6 deletions src/Miningcore/Blockchain/Bitcoin/DaemonResponses/Mweb.cs

This file was deleted.

11 changes: 4 additions & 7 deletions src/Miningcore/Configuration/ClusterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public enum CoinFamily

[EnumMember(Value = "conceal")]
Conceal,

[EnumMember(Value = "cryptonote")]
Cryptonote,

Expand Down Expand Up @@ -261,9 +261,6 @@ public class BitcoinNetworkParams
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public JToken BlockTemplateRpcExtraParams { get; set; }

[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool HasMWEB { get; set; }

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public Dictionary<string, BitcoinNetworkParams> Networks { get; set; }

Expand Down Expand Up @@ -504,13 +501,13 @@ public partial class ConcealCoinTemplate : CoinTemplate
/// </summary>
[JsonProperty(Order = -4, DefaultValueHandling = DefaultValueHandling.Include)]
public int HashVariant { get; set; }

/// <summary>
/// Conceal network hashrate = `Difficulty / DifficultyTarget`
/// See: parameter -> DIFFICULTY_TARGET in src/CryptoNoteConfig.h
/// </summary>
public ulong DifficultyTarget { get; set; }

/// <summary>
/// Smallest unit for Blockreward formatting
/// </summary>
Expand Down Expand Up @@ -901,7 +898,7 @@ public partial class ClusterPaymentProcessingConfig
/// <summary>
/// Indentifier used in coinbase transactions to identify the pool
/// </summary>
public string CoinbaseString { get; set; }
public string CoinbaseString { get; set; }
}

public partial class PersistenceConfig
Expand Down
1 change: 0 additions & 1 deletion src/Miningcore/coins.json
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,6 @@
}
]
},
"hasMWEB": true,
"shareMultiplier": 65536,
"explorerBlockLink": "https://chainz.cryptoid.info/ltc/block.dws?$height$.htm",
"explorerTxLink": "https://chainz.cryptoid.info/ltc/tx.dws?{0}.htm",
Expand Down

0 comments on commit 39b17d7

Please sign in to comment.