Пример #1
0
        public async Task <BlockAPIResult> CreateProfitingAccountAsync(string Name, ProfitingType ptype, decimal shareRito, int maxVoter)
        {
            var tags = new Dictionary <string, string>
            {
                { Block.REQSERVICETAG, BrokerActions.BRK_PFT_CRPFT },
                { "name", Name },   // get by name. name can't duplicate
                { "ptype", ptype.ToString() },
                { "share", $"{shareRito}" },
                { "seats", $"{maxVoter}" }
            };
            var amounts = new Dictionary <string, decimal>
            {
                { LyraGlobal.OFFICIALTICKERCODE, PoolFactoryBlock.ProfitingAccountCreateFee }
            };
            var result = await SendExAsync(PoolFactoryBlock.FactoryAccount, amounts, tags);

            if (result.ResultCode != APIResultCodes.Success)
            {
                return new BlockAPIResult {
                           ResultCode = result.ResultCode
                }
            }
            ;

            for (int i = 0; i < 10; i++)
            {
                // then find by RelatedTx
                var blocks = await _node.GetBlocksByRelatedTxAsync((await GetLatestBlockAsync()).Hash);

                if (blocks.Successful())
                {
                    var txs = blocks.GetBlocks();
                    var gen = txs.FirstOrDefault(a => a is ProfitingBlock pb && pb.OwnerAccountId == AccountId);
                    if (gen != null)
                    {
                        var ret = new BlockAPIResult
                        {
                            ResultCode = APIResultCodes.Success,
                        };
                        ret.SetBlock(gen);
                        return(ret);
                    }
                }
                await Task.Delay(500);
            }

            return(new BlockAPIResult {
                ResultCode = APIResultCodes.ConsensusTimeout
            });
        }
Пример #2
0
 public async Task <MultiBlockAPIResult> GetBlocksByRelatedTxAsync(string Hash)
 {
     if (!CheckServiceStatus())
     {
         return(null);
     }
     return(await _node.GetBlocksByRelatedTxAsync(Hash));
 }