tera/src/system/names.ts

40 lines
1.1 KiB
TypeScript

/*
* @project: TERA
* @version: Development (beta)
* @license: MIT (not for evil)
* @copyright: Yuriy Ivanov (Vtools) 2017-2019 [progr76@gmail.com]
* Web: https://terafoundation.org
* Twitter: https://twitter.com/terafoundation
* Telegram: https://t.me/terafoundation
*/
"use strict";
const NAMES_TYPE_TRANSACTION = 10;
import DApp from './dapp'
export default class NameApp extends DApp {
Server
KeyValueMap;
CurrentNameArr;
constructor() {
super()
this.KeyValueMap = {}
this.CurrentNameArr = ""
global.NAMES = this
}
OnWriteTransaction(Block, Body, BlockNum, TrNum) {
return;
if (Body[0] === NAMES_TYPE_TRANSACTION) {
var StrKey = global.GetHexFromAddres(Body.slice(1, 33));
if (!this.KeyValueMap[StrKey]) {
this.KeyValueMap[StrKey] = Body.slice(33)
if (global.CompareArr(Body.slice(33), this.Server.addrArr) === 0)
this.CurrentNameArr = Body.slice(1, 33)
}
}
}
};
var Name = new NameApp();
global.DApps.Names = Name;
global.DAppByType[NAMES_TYPE_TRANSACTION] = Name;