public static void Q2P_McBlock_Handle(Session session, int opcode, object msg) { Q2P_McBlock q2p_McBlock = msg as Q2P_McBlock; Block mcbkl = BlockChainHelper.GetMcBlock(q2p_McBlock.height); R2P_McBlock r2p_McBlock = null; r2p_McBlock = new R2P_McBlock() { block = mcbkl != null?JsonHelper.ToJson(mcbkl) : "" }; session.Reply(q2p_McBlock, r2p_McBlock); }
public async Task <Block> QueryMcBlock(long height, string ipEndPoint = null) { Q2P_McBlock q2p_mcBlock = new Q2P_McBlock(); q2p_mcBlock.ActorId = nodeManager.GetMyNodeId(); q2p_mcBlock.height = height; Session session = null; if (ipEndPoint != null && ipEndPoint != "") { session = await networkInner.Get(NetworkHelper.ToIPEndPoint(ipEndPoint)); } if (session != null && !session.IsConnect()) { session = null; } Block blk = null; if (session == null) { NodeManager.NodeData node = nodeManager.GetRandomNode(); if (node != null) { session = await networkInner.Get(NetworkHelper.ToIPEndPoint(node.ipEndPoint)); } } if (session != null) { R2P_McBlock r2p_McBlock = (R2P_McBlock)await session.Query(q2p_mcBlock); if (r2p_McBlock != null && r2p_McBlock.block != "") { blk = JsonHelper.FromJson <Block>(r2p_McBlock.block); } } return(blk); }