Example #1
0
        public static Tuple <InteropBlock, InteropTransaction[]> MakeInteropBlock(Logger logger, NeoBlock block,
                                                                                  NeoAPI api, string[] swapAddresses, string coldStorage)
        {
            List <Hash> hashes = new List <Hash>();
            //logger.Debug($"Read block {block.Height} with hash {block.Hash}");

            // if the block has no swap tx, it's currently not of interest
            bool blockOfInterest = false;
            List <InteropTransaction> interopTransactions = new List <InteropTransaction>();

            foreach (var tx in block.transactions)
            {
                if (tx.type == TransactionType.InvocationTransaction ||
                    tx.type == TransactionType.ContractTransaction)
                {
                    var interopTx = MakeInteropTx(logger, tx, api, swapAddresses, coldStorage);
                    if (interopTx.Hash != Hash.Null)
                    {
                        interopTransactions.Add(interopTx);
                        hashes.Add(Hash.FromBytes(tx.Hash.ToArray()));
                        blockOfInterest = true;
                    }
                }
            }

            InteropBlock iBlock = (blockOfInterest)
                ? new InteropBlock("neo", "neo", Hash.Parse(block.Hash.ToString()), hashes.ToArray())
                : new InteropBlock("neo", "neo", Hash.Null, hashes.ToArray());

            return(Tuple.Create(iBlock, interopTransactions.ToArray()));
        }