async public static Task <MyJson.JsonNode_Object> handle(int height) { var queryArr = Mongo.Find(Collection, "index", height); if (queryArr.Count == 0) { var blockData = await Rpc.getblock(Config.NeoCliJsonRPCUrl, height); blockData.Remove("confirmations"); blockData.Remove("nextblockhash"); Collection.InsertOne(BsonDocument.Parse(blockData.ToString())); //Mongo.SetSystemCounter(collectionType, height); return(blockData); } else { BsonDocument queryB = queryArr[0].AsBsonDocument; var jsonWriterSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.Strict }; MyJson.JsonNode_Object block = MyJson.Parse(queryB.ToJson(jsonWriterSettings)) as MyJson.JsonNode_Object; return(block); } }
public static void handleTxItem(int blockindex, DateTime blockTime, MyJson.JsonNode_Object item) { string txid = item["txid"].AsString(); var vout_tx = item["vout"].AsList(); var vint_tx = item["vin"].AsList(); if (vout_tx.Count > 0) { foreach (MyJson.JsonNode_Object voutitem in vout_tx) { var addr = voutitem["address"].AsString(); handleAddress.handle(blockindex, addr, txid, blockTime); } } if(vint_tx.Count>0) { foreach (MyJson.JsonNode_Object vinitem in vint_tx) { string voutTx = vinitem["txid"].AsString(); int voutN = vinitem["vout"].AsInt(); var quryarr = Mongo.Find(handleTx.Collection, "txid", voutTx); var voutarr = quryarr[0]["vout"].AsBsonArray; foreach (var _vout in voutarr) { if ((int)_vout["n"] == voutN) { var addr = _vout["address"].AsString; handleAddress.handle(blockindex, addr, txid, blockTime); } } } } }
public static void handle(int blockindex, DateTime blockTime, string txid, int n, MyJson.JsonNode_Object notification) { string findStr = "{{txid:'{0}',n:{1}}}"; findStr = string.Format(findStr, txid, n); BsonDocument findB = BsonDocument.Parse(findStr); var quaryArr = Collection.Find(findB).ToList(); if (quaryArr.Count == 0) { //获取nep5资产信息测试 string nep5AssetID = notification["contract"].AsString(); //var findBsonNEP5AssetBson = BsonDocument.Parse("{assetid:'" + nep5AssetID + "'}"); //var queryNEP5AssetBson = handleNep5.Collection.Find(findBsonNEP5AssetBson).ToList(); var queryNEP5AssetBson = Mongo.Find(handleNep5.Collection, "assetid", nep5AssetID); var NEP5decimals = queryNEP5AssetBson[0].decimals; NEP5.Transfer tf = new NEP5.Transfer(blockindex, txid, n, notification, NEP5decimals); Collection.InsertOne(tf); } else { NEP5.Transfer tf = quaryArr[0]; } //Task.Run(()=> //{ // handleAddress.HandleNotifyItem(blockindex,tf.from, txid, blockTime); // handleAddress.HandleNotifyItem(blockindex, tf.to, txid, blockTime); //}); }
public static void handle(MyJson.JsonNode_Object blockData) { int blockindex = blockData["index"].AsInt(); var blockTx = blockData["tx"].AsList(); var blockTimeTS = blockData["time"].AsInt(); DateTime blockTime = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), TimeZoneInfo.Local).AddSeconds(blockTimeTS); foreach (MyJson.JsonNode_Object txItem in blockTx) { if (txItem["type"].AsString() == "InvocationTransaction") { string txid = txItem["txid"].AsString(); MyJson.JsonNode_Object resNotify; var quaryArr = Mongo.Find(Collection, "txid", txid); if (quaryArr.Count == 0) { resNotify = Rpc.getapplicationlog(Config.NeoCliJsonRPCUrl, txid).Result; if (resNotify != null) { Collection.InsertOne(BsonDocument.Parse(resNotify.ToString())); } } else { resNotify = MyJson.Parse(quaryArr[0].ToJson()) as MyJson.JsonNode_Object; } //todo handleNep5 handleNep5.handle(blockindex, blockTime, txid, resNotify); } } }
public static void handle(string assetID) { //var findBsonNEP5AssetBson = BsonDocument.Parse("{id:'" + assetID + "'}"); //var queryNEP5AssetBson = Collection.Find(findBsonNEP5AssetBson).ToList(); var queryNEP5AssetBson = Mongo.Find(Collection, "id", assetID); if (queryNEP5AssetBson.Count == 0) { var resasset = Rpc.getassetstate(Config.NeoCliJsonRPCUrl, assetID).Result; if (resasset.AsString() != string.Empty) { Collection.InsertOne(BsonDocument.Parse(resasset.ToString())); } } }
public static void handle(MyJson.JsonNode_Object blockData) { int blockindex = blockData["index"].AsInt(); var blockTx = blockData["tx"].AsList(); var blockTimeTS = blockData["time"].AsInt(); DateTime blockTime = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), TimeZoneInfo.Local).AddSeconds(blockTimeTS); //List<BsonDocument> listbson = new List<BsonDocument>(); for (int i = 0; i < blockTx.Count; i++) { var item = blockTx[i] as MyJson.JsonNode_Object; { item.SetDictValue("txindex", i); item.AsDict().SetDictValue("blockindex", blockindex); } var quaryArr = Mongo.Find(Collection, "txid", item["txid"].AsString()); if (quaryArr.Count == 0) { //listbson.Add(BsonDocument.Parse(item.ToString())); Collection.InsertOne(BsonDocument.Parse(item.ToString())); //Mongo.SetSystemCounter(collectionType, blockindex, i); } if (assetCheck.CheckTxAsset(item)) { Task task1 = Task.Factory.StartNew(() => { handleAsset.handleTxItem(blockindex, blockTime, item); }); Task task2 = Task.Factory.StartNew(() => { HandleUtxo.handleTxItem(blockindex, blockTime, item); }); Task task3 = Task.Factory.StartNew(() => { handleNotify.handleTxItem(blockindex, blockTime, item); }); Task.WaitAll(task1, task2, task3); //handleAddress.handleTxItem(blockindex, blockTime, item); } } //if(listbson.Count>0) //{ // Collection.InsertMany(listbson); //} }
public static void handleTxItem(int blockindex, DateTime blockTime, MyJson.JsonNode_Object txItem) { if (txItem["type"].AsString() == "InvocationTransaction") { string txid = txItem["txid"].AsString(); var quaryArr = Mongo.Find(Collection, "txid", txid); MyJson.JsonNode_Object targetNotify; if (quaryArr.Count == 0) { targetNotify = Rpc.getapplicationlog(Config.NeoCliJsonRPCUrl, txid).Result; if (targetNotify != null) { Collection.InsertOne(BsonDocument.Parse(targetNotify.ToString())); } } else { quaryArr[0].Remove("_id"); targetNotify = MyJson.Parse(quaryArr[0].ToJson()) as MyJson.JsonNode_Object; } //todo handleNep5 if (targetNotify != null) { var executionItem = targetNotify["executions"].AsList()[0].AsDict(); var besucced = executionItem["vmstate"].AsString(); if (besucced != "FAULT, BREAK") { var ntfArr = executionItem["notifications"].AsList(); if (ntfArr.Count > 0) { for (int i = 0; i < ntfArr.Count; i++) { var ntfItem = ntfArr[i] as MyJson.JsonNode_Object; if (NEP5.beTransfer(ntfItem) && assetCheck.checkNotifyAsset(ntfItem)) { handleNEP5Asset.handle(ntfItem); handleNEP5Transfer.handle(blockindex, blockTime, txid, i, ntfItem); } } } } } } }
public static void handle(MyJson.JsonNode_Object blockData) { int blockindex = blockData["index"].AsInt(); var blockTx = blockData["tx"].AsList(); decimal totalSysFee = 0; foreach (MyJson.JsonNode_Object item in blockTx) { var fee = decimal.Parse(item["sys_fee"].AsString()); totalSysFee += fee; } //var blockSysfeeFindBson = BsonDocument.Parse("{index:" + (blockindex - 1) + "}"); //var blockSysfeeQuery = Collection.Find(blockSysfeeFindBson).ToList(); var blockSysfeeQuery = Mongo.Find(Collection, "index", (blockindex - 1).ToString()); if (blockSysfeeQuery.Count > 0) { totalSysFee += blockSysfeeQuery[0].totalSysfee; } BlockSysfee bsf = new BlockSysfee(blockindex, totalSysFee); Collection.InsertOne(bsf); }
static void handle(int blockindex, string VoutVin_addr, string VoutVin_txid, DateTime blockTime) { //var findBson = BsonDocument.Parse("{addr:'" + VoutVin_addr + "'}"); //var queryAddr = Collection.Find(findBson).ToList(); var queryAddr = Mongo.Find(Collection, "addr", VoutVin_addr); Address addressItem; if (queryAddr.Count == 0) { Address addr = new Address { addr = VoutVin_addr, firstuse = new AddrUse { txid = VoutVin_txid, blockindex = blockindex, blocktime = blockTime }, lastuse = new AddrUse { txid = VoutVin_txid, blockindex = blockindex, blocktime = blockTime }, txcount = 1 }; Collection.InsertOne(addr); addressItem = addr; } else { Address addr = queryAddr[0]; addr = queryAddr[0]; if (addr.lastuse.txid != VoutVin_txid) { addr.txcount++; if (addr.lastuse.blockindex < blockindex) { addr.lastuse = new AddrUse { txid = VoutVin_txid, blockindex = blockindex, blocktime = blockTime }; } var findBson = BsonDocument.Parse("{addr:'" + VoutVin_addr + "'}"); Collection.ReplaceOne(findBson, addr); } addr.lastuse = new AddrUse { txid = VoutVin_txid, blockindex = blockindex, blocktime = blockTime }; addressItem = addr; } //handle addresstx handleAddressTx.handle(addressItem); }