コード例 #1
0
 public async Task <AuthorizationAPIResult> ReceiveFeeAsync(ReceiveNodeProfitBlock receiveBlock)
 {
     if (!CheckServiceStatus())
     {
         return(null);
     }
     return(await _trans.ReceiveFeeAsync(receiveBlock));
 }
コード例 #2
0
        public static async Task <TransactionBlock> SyncNodeFeesAsync(DagSystem sys, SendTransferBlock send)
        {
            Console.WriteLine("CR Dividend: SyncNodeFeesAsync in...");
            var nodeid = send.AccountID;

            // must be first profiting account of nodes'
            var pfts = await sys.Storage.FindAllProfitingAccountForOwnerAsync(nodeid);

            var pft = pfts.First();

            var usf = await sys.Storage.FindUnsettledFeesAsync(nodeid, pft.AccountID);

            if (usf == null)
            {
                return(null);
            }

            Console.WriteLine("CR Dividend: SyncNodeFeesAsync, yes, have fee");

            var feesEndSb = await sys.Storage.FindServiceBlockByIndexAsync(usf.ServiceBlockEndHeight);

            TransactionBlock latestBlock = await sys.Storage.FindLatestBlockAsync(pft.AccountID) as TransactionBlock;

            var sb = await sys.Storage.GetLastServiceBlockAsync();

            var receiveBlock = new ReceiveNodeProfitBlock
            {
                AccountID   = pft.AccountID,
                ServiceHash = sb.Hash,
                //SourceHash = feesEndSb.Hash,      // no source like all genesis. set source to svc block vaoliate the rule.
                ServiceBlockStartHeight = usf.ServiceBlockStartHeight,
                ServiceBlockEndHeight   = usf.ServiceBlockEndHeight,
                Balances = latestBlock.Balances.ToDictionary(entry => entry.Key,
                                                             entry => entry.Value),
                Fee              = 0,
                FeeType          = AuthorizationFeeTypes.NoFee,
                FeeCode          = LyraGlobal.OFFICIALTICKERCODE,
                NonFungibleToken = null,

                // profit specified config
                Name           = ((IBrokerAccount)latestBlock).Name,
                OwnerAccountId = ((IBrokerAccount)latestBlock).OwnerAccountId,
                PType          = ((IProfiting)latestBlock).PType,
                ShareRito      = ((IProfiting)latestBlock).ShareRito,
                Seats          = ((IProfiting)latestBlock).Seats,
                RelatedTx      = send.Hash
            };

            receiveBlock.AddTag(Block.MANAGEDTAG, "");   // value is always ignored

            if (latestBlock.Balances.ContainsKey(LyraGlobal.OFFICIALTICKERCODE))
            {
                receiveBlock.Balances[LyraGlobal.OFFICIALTICKERCODE] += usf.TotalFees.ToBalanceLong();
            }
            else
            {
                receiveBlock.Balances.Add(LyraGlobal.OFFICIALTICKERCODE, usf.TotalFees.ToBalanceLong());
            }

            receiveBlock.InitializeBlock(latestBlock, sys.PosWallet.PrivateKey, AccountId: sys.PosWallet.AccountId);

            return(receiveBlock);
        }
コード例 #3
0
 public async Task <AuthorizationAPIResult> ReceiveFeeAsync(ReceiveNodeProfitBlock block)
 {
     return(await PostBlockAsync("ReceiveFee", block));
 }
コード例 #4
0
 public async Task <AuthorizationAPIResult> ReceiveFeeAsync(ReceiveNodeProfitBlock receiveBlock)
 {
     return(await Pre_PrepareAsync(receiveBlock).ConfigureAwait(false));
 }