forked from LightCountry/TokenPay
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
不能同时使用TRX动态地址和ETH动态地址的bug修复、增加ETH系其他链的支持
- Loading branch information
Light
committed
Mar 3, 2023
1 parent
92b84cc
commit 67cc11f
Showing
32 changed files
with
854 additions
and
716 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#`EVMChains.json`说明 | ||
|
||
### 1. ETH系区块链配置参数说明 | ||
| 字段 | 类型 | 说明 | | ||
| ---- | ---- | ---- | | ||
| Enable | bool | 是否启用此区块链,支持的值: `true`、`false` | | ||
| ChainName | string | 区块链名称 | | ||
| ChainNameEN | string | 区块链英文名称 | | ||
| BaseCoin | string | 基本币名称 | | ||
| Decimals | int | 基本币精度,如:18表示小数点后有18位,6表示小数点后有6位 | | ||
| ApiHost | string | api请求地址 | | ||
| ApiKey | string | api请求的授权key | | ||
| ERC20Name | string | ERC20代币名称,比如币安的就叫`BEP-20`,而不叫`ERC20`,所以特意加了这个 | | ||
| ERC20 | object[] | 要支持的代币 | | ||
|
||
|
||
### 2. ETH系区块链配置代币说明 | ||
| 字段 | 类型 | 说明 | | ||
| ---- | ---- | ---- | | ||
| Name | string | 代币名称,不管是哪条链的USDT,都是写USDT。USDC同理,此参数会用于向OKX服务器查询币价,`填写了错误的名称会导致无法自动获取币价` | | ||
| ContractAddress | string | 合约地址,错误的合约地址将导致收款无法回调 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace CoinListenBot.BgServices.Base | ||
{ | ||
public abstract class BaseBackgroundService : IHostedService, IDisposable | ||
{ | ||
private Task? _executingTask; | ||
protected readonly string? jobName; | ||
protected readonly ILogger? __logger; | ||
private readonly CancellationTokenSource _stoppingCts = new CancellationTokenSource(); | ||
|
||
protected BaseBackgroundService() | ||
{ | ||
} | ||
protected BaseBackgroundService(string JobName, ILogger logger) | ||
{ | ||
__logger = logger; | ||
jobName = JobName; | ||
} | ||
protected abstract Task ExecuteAsync(CancellationToken stoppingToken); | ||
|
||
public virtual Task StartAsync(CancellationToken cancellationToken) | ||
{ | ||
if (jobName != null && __logger != null) | ||
__logger.LogInformation("后台任务 {JobName} 已启动", jobName); | ||
|
||
_executingTask = ExecuteAsync(_stoppingCts.Token); | ||
|
||
if (_executingTask.IsCompleted) | ||
{ | ||
return _executingTask; | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
public virtual async Task StopAsync(CancellationToken cancellationToken) | ||
{ | ||
if (_executingTask == null) | ||
{ | ||
return; | ||
} | ||
|
||
try | ||
{ | ||
if (jobName != null && __logger != null) | ||
__logger.LogInformation("后台任务 {JobName} 已停止", jobName); | ||
_stoppingCts.Cancel(); | ||
} | ||
finally | ||
{ | ||
await Task.WhenAny(_executingTask, Task.Delay(Timeout.Infinite, cancellationToken)); | ||
} | ||
|
||
} | ||
|
||
public virtual void Dispose() | ||
{ | ||
_stoppingCts.Cancel(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.