第十阶段 stage 1(三):钱包物品化、连接钱包、空投逐个授权、矿机收款地址
This commit is contained in:
1 parent
f732304f38
commit
59dd3c05bc
20 files changed
+462
-55
No files matched your search
@@ -52,17 +52,20 @@ namespace Decentralized
|
||||
/// <summary>质押日息下调的新闻已经发过。</summary>
|
||||
public bool CraLowNews;
|
||||
public Network Network = new Network();
|
||||
/// <summary>链上钱包(硬件钱包,第一个是主钱包),各自的余额、污点、成本、冻结独立。</summary>
|
||||
/// <summary>已加载的链上钱包(硬件钱包拖到终端上加载),各自的余额、污点、成本、冻结独立;没有主钱包这回事,销毁后里面的币永久丢失。</summary>
|
||||
public List<Wallet> Wallets = new List<Wallet>();
|
||||
/// <summary>终端当前连接的钱包:Web3 页的交易、黑市、混币器都用它,用币付款的顾客、挖矿收益也进它。</summary>
|
||||
public int Current;
|
||||
/// <summary>终端当前连接的钱包的编号,-1 是没有连接:Web3 页的交易、黑市、混币器都用它,用币付款的顾客也进它。</summary>
|
||||
public int Current = -1;
|
||||
/// <summary>Poinbase 托管账户:银行存取、Poinbase 交易、出金审查都在这里。</summary>
|
||||
public Wallet Poinbase = new Wallet { Address = "poinbase" };
|
||||
|
||||
[JsonIgnore] public Wallet Hot => Wallets[Math.Max(0, Math.Min(Wallets.Count - 1, Current))];
|
||||
[JsonIgnore] public bool Connected => Current >= 0 && Current < Wallets.Count;
|
||||
|
||||
/// <summary>按地址找自己的钱包;找不到(钱包没了)退回当前钱包。</summary>
|
||||
public Wallet WalletAt(string address) => Wallets.Find(w => ChainAddress.Same(w.Address, address)) ?? Hot;
|
||||
/// <summary>当前连接的钱包;没有连接时是一个空的一次性钱包(读到的余额都是 0,写进去的东西不保留)。动手的操作要先看 <see cref="Connected"/>。</summary>
|
||||
[JsonIgnore] public Wallet Hot => Connected ? Wallets[Current] : new Wallet();
|
||||
|
||||
/// <summary>按地址找自己的钱包;找不到(钱包已销毁或从没有过)是一个一次性钱包,发给它的钱等于丢了。</summary>
|
||||
public Wallet WalletAt(string address) => Wallets.Find(w => ChainAddress.Same(w.Address, address)) ?? new Wallet { Address = address };
|
||||
|
||||
public Wallet Own(string address) => Wallets.Find(w => ChainAddress.Same(w.Address, address));
|
||||
|
||||
@@ -73,6 +76,7 @@ namespace Decentralized
|
||||
{
|
||||
var w = new Wallet { Address = ChainAddress.Make(Rng.NextUInt()), Poisoned = poisoned, Name = (++WalletSeq).ToString() };
|
||||
Wallets.Add(w);
|
||||
if (!Connected) Current = Wallets.Count - 1; // 第一个加载的钱包自动连接
|
||||
return w;
|
||||
}
|
||||
|
||||
@@ -115,6 +119,8 @@ namespace Decentralized
|
||||
public static readonly List<KeyValuePair<GameItem, ModuleBonus>> TonightCards = new List<KeyValuePair<GameItem, ModuleBonus>>();
|
||||
/// <summary>今晚已扣过电的矿机编号:每台矿机每晚只算一次(外力在白天触发夜间结算,不会重复登记显卡和扣电)。</summary>
|
||||
public static readonly HashSet<int> TonightDrawn = new HashSet<int>();
|
||||
/// <summary>今晚参与挖矿的显卡(或 ASIC 矿机)属于哪台机器:挖矿产出按机器设置的收款地址发。</summary>
|
||||
public static readonly Dictionary<GameItem, GameItem> TonightMachine = new Dictionary<GameItem, GameItem>();
|
||||
public static int TonightRigs, TonightPoweredRigs;
|
||||
public static double TonightKj;
|
||||
|
||||
@@ -133,7 +139,6 @@ namespace Decentralized
|
||||
if (Data.Market == null) Data.Market = Market.CreateDefault(StoreStation.GetDayCounter());
|
||||
// 旧存档里的商家地址没有校验位:换成合法地址
|
||||
foreach (var s in Data.Black.Sellers) if (!ChainAddress.Valid(s.Name)) s.Name = ChainAddress.Make(Data.Rng.NextUInt());
|
||||
if (Data.Wallets.Count == 0) Data.AddWallet(false);
|
||||
if (Data.Story == null) Data.Story = new StoryMods();
|
||||
StoryMods.Current = Data.Story;
|
||||
Log.Info($"状态已载入(第 {Data.Day} 天,PSC {Data.Market.Price:0.00})");
|
||||
|
||||
Reference in new issue
Block a user