github.com/elastos/Elastos.ELA.SideChain.ETH@v0.2.2/oracle/crosschain_oracle.js (about) 1 "use strict"; 2 3 const express = require("express"); 4 5 const common = require("./common"); 6 const getBlkNum = require("./getblknum"); 7 const sendrechargetransaction = require("./sendrechargetransaction"); 8 const getTxInfo = require("./gettxinfo"); 9 const getBlkLogs = require("./getblklogs"); 10 const getExistTxs = require("./getexisttxs"); 11 const GetIllegalEvidenceByHeight=require("./getillegalevidencebyheight"); 12 const CheckIllegalEvidence=require("./checkillegalevidence"); 13 const Smallcrosschaintransaction=require("./smallcrosschaintransaction"); 14 const FailedDepositTransactions=require("./faileddeposittransactions"); 15 const GetFailedDepositTxByHash=require("./getfaileddeposittransactionbyhash"); 16 const FailedWithdrawTxByHash=require("./receivedInvaliedwithrawtx"); 17 const ProcessedFailedWithdrawTxs=require("./processedinvalidwithdrawtx"); 18 19 const app = express(); 20 21 var bodyParser = require('body-parser'); 22 app.use(bodyParser.json({limit: '150mb'})); 23 24 app.use(express.json()); 25 26 app.post("/", async function(req, res) { 27 try { 28 let json_data = req.body; 29 console.log("JSON Data Received: "); 30 console.log(json_data); 31 console.log("============================================================"); 32 if (json_data["method"] === "getblockcount") { 33 await getBlkNum(res); 34 return; 35 } 36 if (json_data["method"] === "sendrechargetransaction") { 37 await sendrechargetransaction(json_data, res); 38 return; 39 } 40 if (json_data["method"] === "getwithdrawtransaction") { 41 await getTxInfo(json_data, res); 42 return; 43 } 44 if (json_data["method"] === "getwithdrawtransactionsbyheight") { 45 await getBlkLogs(json_data, res); 46 return; 47 } 48 if (json_data["method"] === "getexistdeposittransactions") { 49 await getExistTxs(json_data, res); 50 return; 51 } 52 if (json_data["method"] === "getillegalevidencebyheight") { 53 await GetIllegalEvidenceByHeight(json_data, res); 54 return; 55 } 56 if (json_data["method"] === "checkillegalevidence") { 57 await CheckIllegalEvidence(json_data, res); 58 return; 59 } 60 if (json_data["method"] === "sendsmallcrosstransaction") { 61 await Smallcrosschaintransaction(json_data, res) 62 return; 63 } 64 if (json_data["method"] === "getfaileddeposittransactions") { 65 await FailedDepositTransactions(json_data, res) 66 return; 67 } 68 if (json_data["method"] === "getfaileddeposittransactionbyhash") { 69 await GetFailedDepositTxByHash(json_data, res) 70 return; 71 } 72 if (json_data["method"] === "sendinvalidwithdrawtransaction") { 73 await FailedWithdrawTxByHash(json_data, res) 74 return; 75 } 76 if (json_data["method"] === "getprocessedinvalidwithdrawtransactions") { 77 await ProcessedFailedWithdrawTxs(json_data, res) 78 return; 79 } 80 } catch (err) { 81 common.reterr(err, res); 82 return; 83 } 84 res.json({"result": "received"}); 85 }); 86 87 let server = app.listen('20632'); 88 server.timeout = 360000; 89 console.log("Server started..."); 90 91 process.on("SIGINT", () => { 92 console.log("Shutting down..."); 93 process.exit(); 94 });