refactor: extracting global constants

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2019-07-13 18:48:51 +08:00
parent 1509b956a9
commit 207db65a07
17 changed files with 286 additions and 264 deletions

View File

@@ -18,6 +18,7 @@ import * as fs from 'fs'
import * as querystring from 'querystring'
import * as crypto from 'crypto';
import { STreeBuffer } from './base';
import { TYPE_TRANSACTION } from '../constant/account';
var BlockTree = new STreeBuffer(300 * 1000, global.CompareItemHashSimple, "number");
var ContenTypeMap = {};
@@ -222,7 +223,7 @@ function SendToResponceFile(response, Block, TrNum) {
var Body = Block.arrContent[TrNum];
if (Body && Body.data)
Body = Body.data;
if (Body && Body[0] === global.TYPE_TRANSACTION_FILE) {
if (Body && Body[0] === TYPE_TRANSACTION.TYPE_TRANSACTION_FILE) {
var TR = global.DApps.File.GetObjectTransaction(Body);
if (TR.ContentType.toLowerCase().indexOf("html") >= 0)
response.writeHead(200, { 'Content-Type': "text/plain" });
@@ -269,7 +270,7 @@ function SendToResponceDappFile(response, Block, TrNum) {
var Body = Block.arrContent[TrNum];
if (Body) {
var Type = Body[0];
if (Type === global.TYPE_TRANSACTION_FILE) {
if (Type === TYPE_TRANSACTION.TYPE_TRANSACTION_FILE) {
var TR = global.DApps.File.GetObjectTransaction(Body);
Result = { result: 1, Type: Type, ContentType: TR.ContentType, Name: TR.Name, Body: TR.Data.toString('utf8') };
} else {