1
0
Fork 0

Merge remote-tracking branch 'upstream/master' into docker

merge-requests/1/head
Nuno Ferro 2019-02-20 15:41:20 +00:00
commit f474971dd1
31 changed files with 1047 additions and 155 deletions

Binary file not shown.

Binary file not shown.

297
Doc/Eng/API2.md Normal file
View File

@ -0,0 +1,297 @@
# API v2 (for exchanges)
Works with update version 0.897
The API is designed to make it easier to write third-party applications. Server-side cryptography and POW operations are performed. Therefore, it is not recommended for public access, because it is not protected from DDOS attacks. Use it if applications such as the exchange server are on the same private network.
This API is available if server is running http and hosting included constant USE_HARD_API_V2.
### Set the constants:
* HTTP_HOSTING_PORT:80
* USE_HARD_API_V2:1
Although the API is designed for use in POST requests, it can be used for GET requests in a limited mode.
Call format:
```js
{{Server}}/api/v2/{{MethodName}}
```
Example:
```js
http://127.0.0.1/api/v2/GenerateKeys
```
As a result, JSON is returned, which contains the required result field with the value:
* 0 - the request contains errors or the result is not possible to get (for example, there is no such account),
* 1 or >1 - successful execution of the query
text - the optional field contains a detailed description of the result
All methods support the Meta parameter, if it is specified, the same value is added to the query result. This is useful for organizing your own query routing, often used in micro-service architectures.
## GenerateKeys
1)**/api/v2/GenerateKeys** - create private key - public key pair
#### Parameters are not required
example:
```js
http://127.0.0.1/api/v2/GenerateKeys
```
return:
```js
{
"result": 1,
"PrivKey": "65C65BE3F436DE58C64461BDC1BF0E2D8AB06C2C4E92470B1F4CDEADB9B2C3FF",
"PubKey": "030809551AD9E0E275082C75EC82E9651BF062821EC6DFE31039B0EDE6A2ED26CC"
}
```
## CreateAccount
2)**/api/v2/CreateAccount** - create a new account (account). In Tere free account creation is possible only in the intervals of 10 seconds. The paid version is given in the example of 2 methods **Send**
#### Parameters:
* Name - account name up to 40 bytes
* PrivKey - private key in hex-format
* Wait - if the number 1 is set, the response to the request is not returned until the transaction is written to the blockchain (the response time to the request is increased to 18 seconds)
example:
```js
http://127.0.0.1/api/v2/CreateAccount
{
"Name": "PrivTest02",
"PrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
"Wait":1
}
```
return:
```js
{
"result": 190552,
"text": "Add to blockchain",
"TxID": "04711036904F1F2DDF49CC7B2F010000",
"BlockNum": 19889100
}
```
result - returns the id (number) of the created account
## Send
3)**/api/v2/Send** - sending coins from one account to another (you need to specify the private key of the sender's account)
#### Parameters:
* FromID - the account number of the sender
* FromPrivKey - sender private key in hex format
* ToID - the account number of the recipient, the number or public key in hex format (in this case, it will create a new account with the name specified in the first line of the description of the payment and the payment the account will be charged 10 Tera)
* Amount - sum, floating-point number, or object format {SumCOIN,SumCENT}
* Description - description of payment order (optional)
* Wait - if the number 1 is set, the response to the request is not returned until the transaction is written to the blockchain (the response time to the request is increased to 8 seconds)
example1:
```js
http://127.0.0.1/api/v2/Send
{
"FromID": 190085,
"FromPrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
"ToID":190165,
"Amount":10.5,
"Description":"Тест",
"Wait":1
}
```
return:
```js
{
"result": 1,
"text": "Add to blockchain",
"TxID": "C08A0C18C1ABF4062B149B7C2F010000",
"BlockNum": 19889307
}
```
example2 (создание нового счета):
```js
http://127.0.0.1/api/v2/Send
{
"FromID": 190059,
"FromPrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
"ToID22":190516,
"ToID":"0240EDF5ECB25D886FD58DB92A53914FAC975078C1C2EDD1AC292B70C7BC13461F",
"Amount":10,
"Description":"New account",
"Wait":1
}
```
return:
```js
{
"result": 190551,
"text": "Add to blockchain",
"TxID": "9DD4869C4515B2A3340E887A2F010000",
"BlockNum": 19888776
}
```
result - returns the id (number) of the created account
## GetBalance
4)**/api/v2/GetBalance** - get account balance
#### Parameters:
* AccountID - account number
example:
```js
http://127.0.0.1/api/v2/GetBalance
{
"AccountID": 9
}
```
return:
```js
{
"result": 1,
"SumCOIN": 5589146,
"SumCENT": 555765670,
"PubKey": "02769165A6F9950D023A415EE668B80BB96B5C9AE2035D97BDFB44F356175A44FF"
}
```
## GetTransaction
5)**/api/v2/GetTransaction** - get transaction (returns an object with the contents of the transaction)
#### Parameters:
* TxID - Transaction ID in hex format
example1:
```js
http://127.0.0.1/api/v2/GetTransaction
{
"TxID": "BE10810FDE7A1317D9DF51D62D010000"
}
```
return:
```js
{
"Type": 111,
"Version": 3,
"Reserve": 0,
"FromID": 190085,
"To": [
{
"PubKey": "",
"ID": 190165,
"SumCOIN": 1,
"SumCENT": 0
}
],
"Description": "New6",
"OperationID": 41,
"Body": "",
"Sign": "8C761F539A6A24427CF810A49140CA1FFBF0F3A48DCF58AEE0DD9E4A4E631E1A1B6DA86ED6E2EF92DBF537270AA02B5EAE3A7C822B3F70628CAD78525ED9E0F7",
"result": 1
}
```
example2:
```js
http://127.0.0.1/api/v2/GetTransaction
{
"TxID": "04711036904F1F2DDF49CC7B2F010000"
}
```
return:
```js
{
"Type": 100,
"Currency": 0,
"PubKey": "0240EDF5ECB25D886FD58DB92A53914FAC975078C1C2EDD1AC292B70C7BC13461F",
"Name": "PrivTest02",
"Adviser": 0,
"Smart": 0,
"Reserve": "000000",
"result": 190552
}
```
## GetHistoryTransactions
6)**/api/v2/GetHistoryTransactions** - to get the transaction history of the account
#### Parameters:
* AccountID - account (account) number)
* Count - maximum number of rows returned - history depth (default 100)
option to set parameters for organizing page navigation:
* NextPos - history line ID number (this value is taken from the last line of the previous result)
* Count - number of rows returned
Advanced setting:
* GetTxID - if set to 1, the transaction ID in hex-format is returned in the TxID field
* GetDescription - if set to 1, the transaction description is returned
example1:
```js
http://127.0.0.1/api/v2/GetHistoryTransactions
{
"AccountID": 190480
}
```
return:
```js
{
"result": 1,
"History": [
{
"Type": 1,
"BlockNum": 19994502,
"TrNum": 0,
"Pos": 498190,
"NextPos": 439090,
"Direct": "+",
"CorrID": 190478,
"SumCOIN": 1,
"SumCENT": 0
},
{
"Type": 1,
"BlockNum": 19993514,
"TrNum": 0,
"Pos": 439090,
"NextPos": 0,
"Direct": "+",
"CorrID": 190478,
"SumCOIN": 1,
"SumCENT": 0
}
],
"Tail": {
"NextPos": 498190,
"Reserv": {
"type": "Buffer",
"data": [
0,
0
]
},
"Num": 190480
}
}
```
example2:
```js
http://127.0.0.1/api/v2/GetHistoryTransactions
{
"NextPos": 439090
}
```

305
Doc/Rus/API2.md Normal file
View File

@ -0,0 +1,305 @@
# API v2 (для бирж и обменников)
Работает с версии обновления 0.897
API предназначено для облегчения написания сторонних приложений. На стороне сервера выполняется криптография и операции POW. Поэтому оно не рекомендуется для публичного доступа, т.к. нет защиты от DDOS атак. Используйте его, если приложения такие как сервер биржи находятся в одной приватной сети.
Данный API доступен если на ноде запущен http-хостинг и включена константа USE_HARD_API_V2.
### Для этого задайте константы:
* HTTP_HOSTING_PORT:80
* USE_HARD_API_V2:1
Несмотря на то что API разработано для использования в POST запросах, в ограниченном режиме его можно использовать для GET запросов.
Формат вызова
```js
{{Server}}/api/v2/{{MethodName}}
```
Пример:
```js
http://127.0.0.1/api/v2/GenerateKeys
```
В качестве результат возвращается JSON, который содержит обязательное поле result со значением:
* 0 - запрос содержит ошибки или результат не возможно получить (например нет такого счета),
* 1 или >1 - успешное выполнение запроса (в случае запросов создания новых счетов и режимом Wait:1 здесь возвращается номер созданного счета)
text - опциональное поле содержит подробное описание результата
Все методы поддерживают параметр Meta, если он задан, то это же значение добавляется в результат запроса. Это бывает полезно для организации собственной маршрутизации запросов, часто применяется в микро-сервисных архитектурах.
## GenerateKeys
1)**/api/v2/GenerateKeys** - создание пары приватный ключ - публичный ключ
#### Параметры не обязательны
example:
```js
http://127.0.0.1/api/v2/GenerateKeys
```
return:
```js
{
"result": 1,
"PrivKey": "65C65BE3F436DE58C64461BDC1BF0E2D8AB06C2C4E92470B1F4CDEADB9B2C3FF",
"PubKey": "030809551AD9E0E275082C75EC82E9651BF062821EC6DFE31039B0EDE6A2ED26CC"
}
```
## CreateAccount
2)**/api/v2/CreateAccount** - создание нового счета (аккаунта). В Тере бесплатное создание счета возможно только в промежутках из 10 секунд. Платный вариант приведен в примере 2 метода **Send**
#### Параметры:
* Name - имя счета до 40 байт
* PrivKey - приватный ключ в hex-формате
* Wait - если установлена цифра 1, то ответ на запрос не возвращается до тех пор пока транзакция не будет записана в блокчейн (время ответа на запрос увеличивается до 18 сек)
example:
```js
http://127.0.0.1/api/v2/CreateAccount
{
"Name": "PrivTest02",
"PrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
"Wait":1
}
```
return:
```js
{
"result": 190552,
"text": "Add to blockchain",
"TxID": "04711036904F1F2DDF49CC7B2F010000",
"BlockNum": 19889100
}
```
result - возвращает номер созданного аккаунта
## Send
3)**/api/v2/Send** - отправка монет с одного счета на другой (требуется указать приватный ключ счета отправителя)
#### Параметры:
* FromID - номер счета отправителя
* FromPrivKey - приватный ключ отправителя в hex-формате
* ToID - номер счета получателя, число или публичный ключ в hex-формате (в этом случае будет создан новый счет с именем заданным в первой строке описания платежа и в качестве оплаты создания счета спишется 10 Тера)
* Amount - сумма, число с плавающей точкой или объект в формате {SumCOIN,SumCENT}
* Description - описание платежка (необязательный параметр)
* Wait - если установлена цифра 1, то ответ на запрос не возвращается до тех пор пока транзакция не будет записана в блокчейн (время ответа на запрос увеличивается до 8 сек)
example1:
```js
http://127.0.0.1/api/v2/Send
{
"FromID": 190085,
"FromPrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
"ToID":190165,
"Amount":10.5,
"Description":"Тест",
"Wait":1
}
```
return:
```js
{
"result": 1,
"text": "Add to blockchain",
"TxID": "C08A0C18C1ABF4062B149B7C2F010000",
"BlockNum": 19889307
}
```
example2 (создание нового счета):
```js
http://127.0.0.1/api/v2/Send
{
"FromID": 190059,
"FromPrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
"ToID22":190516,
"ToID":"0240EDF5ECB25D886FD58DB92A53914FAC975078C1C2EDD1AC292B70C7BC13461F",
"Amount":10,
"Description":"New account",
"Wait":1
}
```
return:
```js
{
"result": 190551,
"text": "Add to blockchain",
"TxID": "9DD4869C4515B2A3340E887A2F010000",
"BlockNum": 19888776
}
```
result - возвращает номер созданного аккаунта
## GetBalance
4)**/api/v2/GetBalance** - получить баланс счета
#### Параметры:
* AccountID - номер счета
example:
```js
http://127.0.0.1/api/v2/GetBalance
{
"AccountID": 0
}
```
return:
```js
{
"result": 1,
"SumCOIN": 580222966,
"SumCENT": 527313901
}
```
## GetTransaction
5)**/api/v2/GetTransaction** - получить транзакцию (возвращает объект с содержимым транзакции)
#### Параметры:
* TxID - ИД транзакции в hex-формате
альтернативный вариант задания параметров:
* BlockNum - номер блока
* TrNum - номер транзакции в блоке
example1:
```js
http://127.0.0.1/api/v2/GetTransaction
{
"TxID": "BE10810FDE7A1317D9DF51D62D010000"
}
```
return:
```js
{
"Type": 111,
"Version": 3,
"Reserve": 0,
"FromID": 190085,
"To": [
{
"PubKey": "",
"ID": 190165,
"SumCOIN": 1,
"SumCENT": 0
}
],
"Description": "New6",
"OperationID": 41,
"Body": "",
"Sign": "8C761F539A6A24427CF810A49140CA1FFBF0F3A48DCF58AEE0DD9E4A4E631E1A1B6DA86ED6E2EF92DBF537270AA02B5EAE3A7C822B3F70628CAD78525ED9E0F7",
"result": 1,
"BlockNum": 19781201,
"TrNum": 0
}
```
example2:
```js
http://127.0.0.1/api/v2/GetTransaction
{
"TxID": "04711036904F1F2DDF49CC7B2F010000"
}
```
return:
```js
{
"Type": 100,
"Currency": 0,
"PubKey": "0240EDF5ECB25D886FD58DB92A53914FAC975078C1C2EDD1AC292B70C7BC13461F",
"Name": "PrivTest02",
"Adviser": 0,
"Smart": 0,
"Reserve": "000000",
"result": 190552,
"BlockNum": 19889100,
"TrNum": 1
}
```
## GetHistoryTransactions
6)**/api/v2/GetHistoryTransactions** - получить историю транзакций счета
#### Параметры:
* AccountID - номер счета (аккаунта)
* Count - максимальное число возвращаемых строк - глубина истории (по умолчанию 100)
вариант задания параметров для организации постраничной навигации:
* NextPos - номер ид строки истории (это значение берется из последней строки предыдущего результата)
* Count - число возвращаемых строк
Дополнительные параметры:
* GetTxID - если стоит 1 - то возвращается в поле TxID возвращается ID транзакции в 16 формате
* GetDescription - если стоит 1 - то возвращается описание транзакции в поле Description (если это описание доступно)
example1:
```js
http://127.0.0.1/api/v2/GetHistoryTransactions
{
"AccountID": 190480
}
```
return:
```js
{
"result": 1,
"History": [
{
"Type": 1,
"BlockNum": 19994502,
"TrNum": 0,
"Pos": 498190,
"NextPos": 439090,
"Direct": "+",
"CorrID": 190478,
"SumCOIN": 1,
"SumCENT": 0
},
{
"Type": 1,
"BlockNum": 19993514,
"TrNum": 0,
"Pos": 439090,
"NextPos": 0,
"Direct": "+",
"CorrID": 190478,
"SumCOIN": 1,
"SumCENT": 0
}
],
"Tail": {
"NextPos": 498190,
"Reserv": {
"type": "Buffer",
"data": [
0,
0
]
},
"Num": 190480
}
}
```
example2:
```js
http://127.0.0.1/api/v2/GetHistoryTransactions
{
"NextPos": 439090
}
```

View File

@ -55,9 +55,11 @@
"RESTART_PERIOD_SEC": 0, //авто рестарт ноды через заданный период в сек
"MAX_GRAY_CONNECTIONS_TO_SERVER": 10,//число серверов, к которым подключается нода в режиме серых ip
"TRANSACTION_PROOF_COUNT": 2000000, //число транзакций сохраняемых в базе данных для возможности отката цепочки назад
"MAX_CONNECTIONS_COUNT": 1000, //максимальное число нод, которые могут одновременно быть соединены с текущей нодой
//WATCHDOG
"WATCHDOG_BADACCOUNT": 1, //слежение за наличием ошибок тип "BAD ACCOUNT"
"COREY_WATCH_DOG": 1 //слежение за расcинхронизацией цепочки с общей сетью при майнинге
"COREY_WATCH_DOG": 2 //слежение за расcинхронизацией цепочки с общей сетью при майнинге
}
````

View File

@ -269,6 +269,7 @@ Version = 3 - поддержка переводов на счета со сма
* [Техническое WP - черновик](https://docs.google.com/document/d/1B6_qlAp2xs4aHkqOwyvRMCDJTjgeNiOJiGpIeT0VAzY/edit?usp=sharing)
* [Торрент блокчейна (каталог DATA/DB)](https://sourceforge.net/p/tera/code/ci/master/tree/Torrent/Tera-folder-DB.torrent?format=raw)
* [API](https://sourceforge.net/p/tera/code/ci/master/tree/Doc/Rus/API.md)
* [API2](https://sourceforge.net/p/tera/code/ci/master/tree/Doc/Rus/API2.md)
* [CONSTANTS](https://sourceforge.net/p/tera/code/ci/master/tree/Doc/Rus/CONSTANTS.MD)
* [Презентация - Проблематика блокчейна и пути решения](https://docs.google.com/presentation/d/1NvaGQTUpeP3y7CmHpaqFmaqWlCEMMoPdvCyylFVJ3lk/edit?usp=sharing)

View File

@ -73,6 +73,7 @@
.btlong
{
width: 160px;

View File

@ -100,7 +100,6 @@ function CreateHashBody(body,Num,Nonce)
window.DELTA_POWER_POW_TR = 0;
window.DELTA_FOR_TIME_TX = 0;
window.MIN_POWER_POW_TR = 0;
window.MIN_POWER_POW_ACC_CREATE = 0;
window.CONSENSUS_PERIOD_TIME = 1000;
window.FIRST_TIME_BLOCK = 1530446400000;
window.SetBlockChainConstant = function (Data)
@ -110,7 +109,6 @@ window.SetBlockChainConstant = function (Data)
Data.DELTA_CURRENT_TIME = 0;
window.DELTA_CURRENT_TIME2 = Data.DELTA_CURRENT_TIME - DeltaServerClient;
window.MIN_POWER_POW_TR = DELTA_POWER_POW_TR + Data.MIN_POWER_POW_TR;
window.MIN_POWER_POW_ACC_CREATE = Data.MIN_POWER_POW_ACC_CREATE;
window.FIRST_TIME_BLOCK = Data.FIRST_TIME_BLOCK;
window.CONSENSUS_PERIOD_TIME = Data.CONSENSUS_PERIOD_TIME;
window.GetCurrentBlockNumByTime = function ()

View File

@ -22,6 +22,8 @@ function SetAccountsData(Data,AccountsDataStr)
{
if(!Data || !Data.result)
return ;
if($("idBtRun"))
$("idBtRun").style.display = (Data.arr.length ? '' : 'none');
if(AccountsDataStr === WasAccountsDataStr)
return ;
WasAccountsDataStr = AccountsDataStr;
@ -603,7 +605,7 @@ function SendTrCreateAcc(Currency,PubKey,Description,Adviser,Smart,bFindAcc,bAdd
}
else
{
SendTransaction(Body, TR, MIN_POWER_POW_ACC_CREATE);
SendTransaction(Body, TR);
}
$("idAccountName").value = "";
CancelCreateAccount();

View File

@ -40,10 +40,10 @@ function SavePrivateKey()
if(Data && Data.result === 1)
{
if(Select.value === "private")
SelectStyle("styleBlue");
SelectStyle("styleContrast1");
else
if(Select.value === "public")
SelectStyle("styleGreen");
SelectStyle("styleContrast2");
SetVisibleEditKeys(0);
UpdatesData();
}

View File

@ -1513,7 +1513,7 @@
{
var Item=MapAccounts[$("idAccount").value];
if(Item)
$("idSumSend").value=FLOAT_FROM_COIN(Item.Value);
$("idSumSend").value=FLOAT_FROM_COIN(Item.Value).toStringF();
}
</script>
@ -1694,6 +1694,7 @@
<th id="Item.PrevValue.OperationID" class="num">Prev. Operation</th>
<th id="SUM_TO_STRING(Item.PrevValue)" class="sum">Prev. amount</th>
<th id="Item.PrevValue.NextPos" class="num">Prev. History</th>
</tr>
</table>
<INPUT type="button" onclick="ViewPrev(DefActs)" class="btdoit bt" value="<< Prev">

View File

@ -955,7 +955,7 @@
{
var Item=MapAccounts[$("idAccount").value];
if(Item)
$("idSumSend").value=FLOAT_FROM_COIN(Item.Value);
$("idSumSend").value=FLOAT_FROM_COIN(Item.Value).toStringF();
}
</script>

View File

@ -313,7 +313,7 @@ class STreeBuffer
SaveValue(Hash, Value)
{
if(typeof Hash !== this.KeyType)
throw "MUST ONLY HASH ARRAY: " + Hash;
throw "MUST ONLY TYPE=" + this.KeyType + " in " + Hash;
if(Value !== undefined)
{
var element = this.MetaTree1.find({hash:Hash});

View File

@ -1546,7 +1546,7 @@ module.exports = class CConsensus extends require("./block-loader")
BlockMining.Power = GetPowPower(BlockMining.PowHash)
ADD_TO_STAT("MAX:POWER", BlockMining.Power)
var Power = GetPowPower(BlockMining.PowHash);
var HashCount = (1 << Power) >>> 0;
var HashCount = Math.pow(2, Power);
ADD_HASH_RATE(HashCount)
AddInfoBlock(BlockMining, "Set POW: " + Power)
this.SetNoPOW(BlockMining.BlockNum + 8, 0, BlockMining.BlockNum)

View File

@ -753,7 +753,7 @@ module.exports = class CBlock extends require("./db/block-db")
if(CompareArr(BlockDB.TreeHash, Block.TreeHash) == 0)
{
Block.TreeEq = true
Block.BodyFileNum = BlockDB.BodyFileNum
Block.Reserv500 = BlockDB.Reserv500
Block.TrDataPos = BlockDB.TrDataPos
Block.TrDataLen = BlockDB.TrDataLen
continue;
@ -827,7 +827,7 @@ module.exports = class CBlock extends require("./db/block-db")
return ;
var startTime = process.hrtime();
if(this.LoadHistoryMessage)
ToLog("WRITE DATA Count:" + arr.length + " " + arr[0].BlockNum + "-" + arr[arr.length - 1].BlockNum)
ToLog("WRITE DATA Count:" + arr.length + " " + arr[0].BlockNum + "-" + arr[arr.length - 1].BlockNum, 2)
var CurrentBlockNum = GetCurrentBlockNumByTime();
var Block, FirstBlock;
for(var i = 0; i < arr.length; i++)
@ -856,7 +856,6 @@ module.exports = class CBlock extends require("./db/block-db")
{
if(IsZeroArr(Block.TreeHash))
{
Block.BodyFileNum = 0
Res = this.WriteBlockDB(Block)
}
else
@ -1124,7 +1123,6 @@ module.exports = class CBlock extends require("./db/block-db")
}
}
}
Block.BodyFileNum = this.GetChainFileNum(Block.chain)
Block.arrContent = arrContent
var Ret = this.WriteBodyDB(Block);
Block.TrCount = 0

View File

@ -8,17 +8,18 @@
* Telegram: https://web.telegram.org/#/im?p=@terafoundation
*/
global.UPDATE_CODE_VERSION_NUM = 886;
global.UPDATE_CODE_VERSION_NUM = 897;
global.MIN_CODE_VERSION_NUM = 884;
global.MINING_VERSION_NUM = 3;
global.InitParamsArg = InitParamsArg;
global.CONST_NAME_ARR = ["AUTO_COORECT_TIME", "DELTA_CURRENT_TIME", "COMMON_KEY", "NODES_NAME", "SERVER_PRIVATE_KEY_HEX", "USE_NET_FOR_SERVER_ADDRES",
"NET_WORK_MODE", "STAT_MODE", "MAX_STAT_PERIOD", "HTTP_PORT_NUMBER", "HTTP_PORT_PASSWORD", "HTTP_IP_CONNECT", "WALLET_NAME",
"WALLET_DESCRIPTION", "USE_HARD_API_V2", "COUNT_VIEW_ROWS", "USE_HINT", "ALL_VIEW_ROWS", "ALL_LOG_TO_CLIENT", "USE_MINING",
"MINING_START_TIME", "MINING_PERIOD_TIME", "POW_MAX_PERCENT", "COUNT_MINING_CPU", "SIZE_MINING_MEMORY", "POW_RUN_COUNT", "POW_RUN_COUNT_FIND",
"USE_AUTO_UPDATE", "RESTART_PERIOD_SEC", "MAX_GRAY_CONNECTIONS_TO_SERVER", "TRANSACTION_PROOF_COUNT", "UPDATE_NUM_COMPLETE",
"LIMIT_SEND_TRAFIC", "WATCHDOG_DEV", "ADDRLIST_MODE", "CheckPointDelta", "MIN_VER_STAT", "DEBUG_WALLET", "HTTP_HOSTING_PORT",
"HTTPS_HOSTING_DOMAIN", "HTTP_MAX_COUNT_ROWS", "WATCHDOG_BADACCOUNT", "COREY_WATCH_DOG", "MAX_CONNECTIONS_COUNT", ];
"WALLET_DESCRIPTION", "USE_HARD_API_V2", "COUNT_VIEW_ROWS", "USE_HINT", "ALL_VIEW_ROWS", "ALL_LOG_TO_CLIENT", "LOG_LEVEL",
"USE_MINING", "MINING_START_TIME", "MINING_PERIOD_TIME", "POW_MAX_PERCENT", "COUNT_MINING_CPU", "SIZE_MINING_MEMORY", "POW_RUN_COUNT",
"POW_RUN_COUNT_FIND", "USE_AUTO_UPDATE", "RESTART_PERIOD_SEC", "MAX_GRAY_CONNECTIONS_TO_SERVER", "TRANSACTION_PROOF_COUNT",
"UPDATE_NUM_COMPLETE", "LIMIT_SEND_TRAFIC", "WATCHDOG_DEV", "ADDRLIST_MODE", "CheckPointDelta", "MIN_VER_STAT", "DEBUG_WALLET",
"HTTP_HOSTING_PORT", "HTTPS_HOSTING_DOMAIN", "HTTP_MAX_COUNT_ROWS", "WATCHDOG_BADACCOUNT", "COREY_WATCH_DOG", "MAX_CONNECTIONS_COUNT",
];
global.USE_HARD_API_V2 = 0;
global.USE_TICKET = 0;
global.USE_CHECK_SENDING = 1;
@ -50,6 +51,7 @@ global.POW_RUN_COUNT = 5000;
global.POWRunPeriod = 1;
global.CheckPointDelta = 20;
global.ALL_LOG_TO_CLIENT = 1;
global.LOG_LEVEL = 1;
global.LIMIT_SEND_TRAFIC = 0;
global.COUNT_VIEW_ROWS = 20;
global.MIN_VER_STAT = 0;
@ -97,7 +99,6 @@ global.GENERATE_BLOCK_ACCOUNT = 0;
global.TOTAL_TER_MONEY = 1e9;
global.TRANSACTION_PROOF_COUNT = 1000 * 1000;
global.MIN_POWER_POW_ACC_CREATE = 16;
global.MIN_POWER_POW_ACC_CREATE_LAST = MIN_POWER_POW_ACC_CREATE + 3;
global.START_MINING = 2 * 1000 * 1000;
global.REF_PERIOD_MINING = 1 * 1000 * 1000;
global.DELTA_BLOCK_ACCOUNT_HASH = 1000;
@ -134,7 +135,6 @@ if(global.LOCAL_RUN)
global.TEST_TRANSACTION_GENERATE = 0;
global.MIN_POWER_POW_TR = 8;
global.MIN_POWER_POW_ACC_CREATE = 8;
global.MIN_POWER_POW_ACC_CREATE_LAST = 8;
NETWORK = "LOCAL";
global.ALL_VIEW_ROWS = 1;
}
@ -149,7 +149,6 @@ else
global.REF_PERIOD_MINING = 1000;
global.MIN_POWER_POW_TR = 8;
global.MIN_POWER_POW_ACC_CREATE = 8;
global.MIN_POWER_POW_ACC_CREATE_LAST = 8;
global.TRANSACTION_PROOF_COUNT = 200 * 1000;
global.MAX_SIZE_LOG = 20 * 1024 * 1024;
global.DELTA_BLOCK_ACCOUNT_HASH = 1000;

View File

@ -164,10 +164,6 @@ module.exports = class CDB extends require("../code")
}
return num > 0 ? num - 1 : 0;
}
GetChainFileNum(chain)
{
return 0;
}
WriteBlockDB(Block)
{
var startTime = process.hrtime();
@ -212,6 +208,34 @@ module.exports = class CDB extends require("../code")
}
return Ret;
}
WriteBodyResultDB(Block)
{
var arrTr = Block.arrContentResult;
if(Block.TrDataPos && Block.TrDataLen && Block.VersionBody && arrTr && arrTr.length)
{
var FileItem = BlockDB.OpenDBFile(FILE_NAME_BODY, 1);
var FD = FileItem.fd;
var Size = arrTr.length * 6;
var Position = Block.TrDataPos + Block.TrDataLen - Size;
if(FileItem.size < Position + Size)
{
TO_ERROR_LOG("DB", 241, "Error Position in WriteBodyResultDB on block: " + Block.BlockNum)
return false;
}
var BufWrite = BufLib.GetNewBuffer(Size);
for(var i = 0; i < arrTr.length; i++)
{
BufWrite.Write(arrTr[i], "uint")
}
var written = fs.writeSync(FD, BufWrite, 0, BufWrite.length, Position);
if(written !== BufWrite.length)
{
TO_ERROR_LOG("DB", 242, "Error write to file block-chain : " + written + " <> " + BufWrite.length)
return false;
}
}
return true;
}
WriteBodyDB(Block)
{
var FileItem = BlockDB.OpenDBFile(FILE_NAME_BODY, 1);
@ -233,9 +257,11 @@ module.exports = class CDB extends require("../code")
arrSize[i] = 2 + body.length
TrDataLen += arrSize[i]
}
Block.VersionBody = 1
TrDataLen += arrTr.length * 6
var BufWrite = BufLib.GetNewBuffer(TrDataLen);
BufWrite.Write(arrTr.length, "uint16")
BufWrite.Write(0, "uint16")
BufWrite.Write(Block.VersionBody, "uint16")
for(var i = 0; i < arrTr.length; i++)
{
var body = arrTr[i];
@ -337,8 +363,9 @@ module.exports = class CDB extends require("../code")
return false;
}
Block.arrContent = []
Block.arrContentResult = []
var TrCount = BufRead.Read("uint16");
var TrCountDapp = BufRead.Read("uint16");
Block.VersionBody = BufRead.Read("uint16")
if(TrCount <= MAX_TRANSACTION_COUNT)
{
for(var i = 0; i < TrCount; i++)
@ -348,6 +375,15 @@ module.exports = class CDB extends require("../code")
break;
Block.arrContent[i] = body
}
if(Block.VersionBody === 1)
{
var Size = TrCount * 6;
BufRead.len = Block.TrDataLen - Size
for(var i = 0; i < TrCount; i++)
{
Block.arrContentResult[i] = BufRead.Read("uint")
}
}
}
Block.TrCount = Block.arrContent.length
return true;
@ -475,14 +511,14 @@ module.exports = class CDB extends require("../code")
}
BlockHeaderToBuf(BufWrite, Block)
{
Block.BodyFileNum = 0
Block.Reserv500 = 0
var len = BufWrite.len;
BufWrite.Write(Block.TreeHash, "hash")
BufWrite.Write(Block.AddrHash, "hash")
BufWrite.Write(Block.PrevHash, "hash")
BufWrite.Write(Block.SumHash, "hash")
BufWrite.Write(Block.SumPow, "uint")
BufWrite.Write(Block.BodyFileNum, "uint")
BufWrite.Write(Block.Reserv500, "uint")
BufWrite.Write(Block.TrDataPos, "uint")
BufWrite.Write(Block.TrDataLen, "uint32")
BufWrite.len = len + BLOCK_HEADER_SIZE
@ -498,7 +534,7 @@ module.exports = class CDB extends require("../code")
Block.PrevHash = BufRead.Read("hash")
Block.SumHash = BufRead.Read("hash")
Block.SumPow = BufRead.Read("uint")
Block.BodyFileNum = BufRead.Read("uint")
Block.Reserv500 = BufRead.Read("uint")
Block.TrDataPos = BufRead.Read("uint")
Block.TrDataLen = BufRead.Read("uint32")
Block.TrCount = 0
@ -593,9 +629,15 @@ module.exports = class CDB extends require("../code")
if(App)
{
Tr.Script = App.GetScriptTransaction(Tr.body)
Tr.Verify = App.GetVerifyTransaction(BlockNum, Tr.Num, Tr.body)
if(Tr.Verify == 1)
Tr.Verify = App.GetVerifyTransaction(Block, BlockNum, Tr.Num, Tr.body)
if(Tr.Verify >= 1)
{
Tr.VerifyHTML = "<B style='color:green'>✔</B>"
if(Tr.Verify > 1)
{
Tr.VerifyHTML += "(" + Tr.Verify + ")"
}
}
else
if(Tr.Verify == - 1)
Tr.VerifyHTML = "<B style='color:red'>✘</B>"

View File

@ -52,7 +52,7 @@ module.exports = class CDBState extends require("./db")
var written = fs.writeSync(FI.fd, BufWrite, 0, BufWrite.length, Position);
if(written !== BufWrite.length)
{
TO_ERROR_LOG("DB-STATE", 10, "Error write to file:" + written + " <> " + BufWrite.length)
TO_ERROR_LOG("DB-ROW", 10, "Error write to file:" + written + " <> " + BufWrite.length)
return false;
}
if(RetBuf)

View File

@ -302,8 +302,8 @@ HTTPCaller.DappInfo = function (Params,responce,ObjectOnly)
ArrLog.push(Item);
}
var Ret = {result:1, DELTA_CURRENT_TIME:DELTA_CURRENT_TIME, MIN_POWER_POW_TR:MIN_POWER_POW_TR, FIRST_TIME_BLOCK:FIRST_TIME_BLOCK,
CONSENSUS_PERIOD_TIME:CONSENSUS_PERIOD_TIME, MIN_POWER_POW_ACC_CREATE:MIN_POWER_POW_ACC_CREATE_LAST, PRICE_DAO:PRICE_DAO(SERVER.BlockNumDB),
Smart:Smart, Account:Account, ArrWallet:WLData.arr, ArrEvent:EArr, ArrLog:ArrLog, };
CONSENSUS_PERIOD_TIME:CONSENSUS_PERIOD_TIME, PRICE_DAO:PRICE_DAO(SERVER.BlockNumDB), Smart:Smart, Account:Account, ArrWallet:WLData.arr,
ArrEvent:EArr, ArrLog:ArrLog, };
if(global.WALLET)
{
Ret.WalletIsOpen = (WALLET.WalletOpen !== false);
@ -367,7 +367,7 @@ HTTPCaller.ToLogServer = function (Str)
};
HTTPCaller.FindMyAccounts = function (Params)
{
WALLET.FindMyAccounts();
WALLET.FindMyAccounts(1);
return {result:1};
};
HTTPCaller.GetAccount = function (id)
@ -456,12 +456,11 @@ HTTPCaller.GetWalletInfo = function (Params)
ArrLog:ArrLogClient, MaxAccID:DApps.Accounts.GetMaxAccount(), MaxActNum:DApps.Accounts.GetActsMaxNum(), MaxDappsID:DApps.Smart.GetMaxNum(),
NeedRestart:global.NeedRestart, ip:SERVER.ip, port:SERVER.port, NET_WORK_MODE:global.NET_WORK_MODE, INTERNET_IP_FROM_STUN:global.INTERNET_IP_FROM_STUN,
HistoryMaxNum:MaxHistory, DELTA_CURRENT_TIME:DELTA_CURRENT_TIME, FIRST_TIME_BLOCK:FIRST_TIME_BLOCK, CONSENSUS_PERIOD_TIME:CONSENSUS_PERIOD_TIME,
MIN_POWER_POW_ACC_CREATE:MIN_POWER_POW_ACC_CREATE_LAST, DATA_PATH:(DATA_PATH.substr(1, 1) === ":" ? DATA_PATH : GetNormalPathString(process.cwd() + "/" + DATA_PATH)),
NodeAddrStr:SERVER.addrStr, STAT_MODE:global.STAT_MODE, HTTPPort:global.HTTP_PORT_NUMBER, HTTPPassword:HTTP_PORT_PASSWORD,
CONSTANTS:Constants, CheckPointBlockNum:CHECK_POINT.BlockNum, MiningAccount:global.GENERATE_BLOCK_ACCOUNT, CountMiningCPU:GetCountMiningCPU(),
CountRunCPU:global.ArrMiningWrk.length, MiningPaused:global.MiningPaused, HashRate:HashRateOneSec, MIN_POWER_POW_TR:MIN_POWER_POW_TR,
PRICE_DAO:PRICE_DAO(SERVER.BlockNumDB), NWMODE:global.NWMODE, PERIOD_ACCOUNT_HASH:PERIOD_ACCOUNT_HASH, MAX_ACCOUNT_HASH:DApps.Accounts.DBAccountsHash.GetMaxNum(),
TXBlockNum:TXBlockNum, };
DATA_PATH:(DATA_PATH.substr(1, 1) === ":" ? DATA_PATH : GetNormalPathString(process.cwd() + "/" + DATA_PATH)), NodeAddrStr:SERVER.addrStr,
STAT_MODE:global.STAT_MODE, HTTPPort:global.HTTP_PORT_NUMBER, HTTPPassword:HTTP_PORT_PASSWORD, CONSTANTS:Constants, CheckPointBlockNum:CHECK_POINT.BlockNum,
MiningAccount:global.GENERATE_BLOCK_ACCOUNT, CountMiningCPU:GetCountMiningCPU(), CountRunCPU:global.ArrMiningWrk.length, MiningPaused:global.MiningPaused,
HashRate:HashRateOneSec, MIN_POWER_POW_TR:MIN_POWER_POW_TR, PRICE_DAO:PRICE_DAO(SERVER.BlockNumDB), NWMODE:global.NWMODE, PERIOD_ACCOUNT_HASH:PERIOD_ACCOUNT_HASH,
MAX_ACCOUNT_HASH:DApps.Accounts.DBAccountsHash.GetMaxNum(), TXBlockNum:TXBlockNum, };
if(Params.Account)
Ret.PrivateKey = GetHexFromArr(WALLET.GetPrivateKey(WALLET.AccountMap[Params.Account]));
else
@ -953,7 +952,7 @@ HTTPCaller.TruncateBlockChain = function (Param)
var MinBlock = DApps.Accounts.GetMinBlockAct();
if(MinBlock > StartNum)
{
ToLog("Cant Truncate BlockChain. Very long length. Max length=" + (SERVER.BlockNumDB - MinBlock));
ToLog("Cant Truncate BlockChain. Very long length. Max length=" + (SERVER.BlockNumDB - MinBlock), 0);
return {result:0, sessionid:sessionid};
}
SERVER.TruncateBlockDB(StartNum);
@ -1360,8 +1359,8 @@ if(global.HTTP_PORT_NUMBER)
if(!ClientIPMap[remoteAddress])
{
ClientIPMap[remoteAddress] = 1;
ToLog("CONNECT TO HTTP ACCESS FROM: " + remoteAddress);
ToLog("Path: " + Path);
ToLog("CONNECT TO HTTP ACCESS FROM: " + remoteAddress, 0);
ToLog("Path: " + Path, 0);
}
if(CheckPassword && global.HTTP_PORT_PASSWORD)
{

View File

@ -27,9 +27,10 @@ function ToLogClient(t,e,r)
{
t && (ToLogFile(file_name_log, t), e || (e = ""), ArrLogClient.push({text:GetStrOnlyTime() + " " + t, key:e, final:r}), 13 < ArrLogClient.length && ArrLogClient.shift());
};
CheckSizeLogFile(file_name_error, file_name_errorPrev), global.ToLog = function (t)
CheckSizeLogFile(file_name_error, file_name_errorPrev), global.ToLog = function (t,e)
{
global.ALL_LOG_TO_CLIENT ? ToLogClient(t, void 0, void 0) : ToLogFile(file_name_log, t);
void 0 === e && (e = 1), e && e > global.LOG_LEVEL || (global.ALL_LOG_TO_CLIENT ? ToLogClient(t, void 0, void 0) : ToLogFile(file_name_log,
t));
}, global.SmallAddr = function (t)
{
return t.substr(0, 5);

View File

@ -357,16 +357,10 @@ module.exports = class CTransport extends require("./connect")
ADD_TO_STAT("USEPACKET")
var CurTime = GetCurrentTime();
Meta.Node.LastTime = CurTime - 0
if(Meta.MethodTiming.Process)
if(Meta.MethodTiming.Process && Meta.MethodTiming.Process.Worker)
{
var Data = this.DataFromF(Meta);
try
{
Meta.MethodTiming.Process.Worker.send({cmd:Meta.Method, Data:Data, addrStr:Meta.Node.addrStr, Context:Meta.Context})
}
catch(e)
{
}
Meta.MethodTiming.Process.Worker.send({cmd:Meta.Method, Data:Data, addrStr:Meta.Node.addrStr, Context:Meta.Context})
}
else
{

View File

@ -92,6 +92,7 @@ module.exports = class CSmartContract extends require("./block-exchange")
{
DApps[key].OnWriteBlockStart(Block)
}
var arrContentResult = [];
var BlockNum = Block.BlockNum;
var arr = Block.arrContent;
if(arr)
@ -106,26 +107,46 @@ module.exports = class CSmartContract extends require("./block-exchange")
var App = DAppByType[type];
if(App)
{
App.ResultTx = 0
DApps.Accounts.BeginTransaction()
var StrHex = GetHexFromArr(sha3(arr[i]));
var item = global.TreeFindTX.LoadValue(StrHex);
global.CurTrItem = item
if(item)
global.CurTrItem = item.TX
else
global.CurTrItem = undefined
var Result = App.OnWriteTransaction(Block, arr[i], BlockNum, i);
var SetResult = Result;
if(Result === true)
{
if(App.ResultTx)
SetResult = App.ResultTx
if(!DApps.Accounts.CommitTransaction(BlockNum, i))
SetResult = 0
}
else
{
DApps.Accounts.RollBackTransaction()
SetResult = 0
}
if(SetResult === true)
SetResult = 1
arrContentResult[i] = SetResult
if(item)
{
var ResultStr = Result;
if(Result === true)
if(Result === true || typeof Result === "number")
{
ResultStr = "Add to blockchain"
if(type === global.TYPE_TRANSACTION_FILE)
ResultStr += ": file/" + BlockNum + "/" + i
}
ToLogClient(ResultStr, item, true)
item.cmd = "RetFindTX"
item.ResultStr = "" + ResultStr
item.bFinal = 1
item.Result = SetResult
process.send(item)
}
if(Result === true)
DApps.Accounts.CommitTransaction(BlockNum, i)
else
DApps.Accounts.RollBackTransaction()
global.CurTrItem = undefined
}
}
@ -136,6 +157,8 @@ module.exports = class CSmartContract extends require("./block-exchange")
this.DeleteBlockFromHashTree(Block2)
this.AddBlockToHashTree(Block)
}
if(arrContentResult.length)
process.send({cmd:"WriteBodyResult", BlockNum:Block.BlockNum, arrContentResult:arrContentResult})
for(var key in DApps)
{
DApps[key].OnWriteBlockFinish(Block)

View File

@ -108,7 +108,7 @@ class CApp
{
this.AccountMap = {}
}
this.FindMyAccounts()
this.FindMyAccounts(0)
if(bGo)
this.SaveWallet()
}
@ -230,10 +230,12 @@ class CApp
{
this.AccountMap[Data.Num] = 0
}
FindMyAccounts()
FindMyAccounts(bClean)
{
if(IsZeroArr(this.PubKeyArr))
return ;
if(bClean)
this.AccountMap = {}
DApps.Accounts.FindAccounts([this.PubKeyArr], this.AccountMap, 0)
}
GetAccountKey(Num)

View File

@ -13,6 +13,10 @@ const fs = require('fs');
const DBRow = require("../core/db/db-row");
const MAX_SUM_TER = 1e9;
const MAX_SUM_CENT = 1e9;
const DBLib = require("../core/db/db");
global.HistoryDB = new DBLib();
const FILE_NAME_HISTORY = "history-body";
var WorkStructHistory = {};
global.TYPE_TRANSACTION_CREATE = 100;
const TYPE_TRANSACTION_TRANSFER = 105;
const TYPE_TRANSACTION_TRANSFER2 = 110;
@ -141,9 +145,13 @@ class AccountApp extends require("./dapp")
}"
this.ACCOUNT_ROW_SIZE = 6 + 33 + 40 + (6 + 4 + 6 + 84) + 6 + 6 + 9
this.DBState = new MerkleDBRow("accounts-state", this.ACCOUNT_ROW_SIZE, this.FORMAT_ACCOUNT_ROW, bReadOnly)
this.DBAct = new DBRow("accounts-act", 6 + 6 + (6 + 4 + 6 + 6 + 84) + 1 + 11, "{ID:uint, BlockNum:uint,PrevValue:{SumCOIN:uint,SumCENT:uint32, Reserve0:uint, OperationID:uint,Smart:uint32,Data:arr80}, Mode:byte, TrNum:uint16, Reserve: arr9}",
this.DBAct = new DBRow("accounts-act", 6 + 6 + (6 + 4 + 6 + 6 + 84) + 1 + 11, "{ID:uint, BlockNum:uint,PrevValue:{SumCOIN:uint,SumCENT:uint32, NextPos:uint, OperationID:uint,Smart:uint32,Data:arr80}, Mode:byte, TrNum:uint16, Reserve: arr9}",
bReadOnly)
this.DBActPrev = new DBRow("accounts-act-prev", this.DBAct.DataSize, this.DBAct.Format, bReadOnly)
this.FORMAT_STATE_HISTORY = "{NextPos:uint,Reserv:arr2}"
this.DBStateHistory = new DBRow("history-state", 8, this.FORMAT_STATE_HISTORY, bReadOnly)
HistoryDB.OpenDBFile(FILE_NAME_HISTORY, !bReadOnly)
this.HistoryFormatArr = ["{Type:byte, BlockNum:uint32,TrNum:uint16, NextPos:uint}", "{Type:byte, BlockNum:uint32,TrNum:uint16, NextPos:uint, Direct:str1,CorrID:uint, SumCOIN:uint,SumCENT:uint32}"]
if(global.READ_ONLY_DB)
return ;
this.DBAccountsHash = new DBRow("accounts-hash2", 6 + 32 + 32 + 10, "{BlockNum:uint, Hash:hash, SumHash:hash, Reserve: arr10}",
@ -163,6 +171,7 @@ class AccountApp extends require("./dapp")
return ;
this.DBState.MerkleTree = undefined
this.DBState.Truncate( - 1)
this.DBStateHistory.Truncate( - 1)
this.DBAct.Truncate( - 1)
this.DBActPrev.Truncate( - 1)
this.DBAccountsHash.Truncate( - 1)
@ -187,6 +196,8 @@ class AccountApp extends require("./dapp")
this.DBAccountsHash.Close()
if(this.DBStateTX)
this.DBStateTX.Close()
if(this.DBStateHistory)
this.DBStateHistory.Close()
}
ClearDataBase()
{
@ -363,8 +374,16 @@ class AccountApp extends require("./dapp")
}
}
}
GetVerifyTransaction(BlockNum, TrNum, Body)
GetVerifyTransaction(Block, BlockNum, TrNum, Body)
{
if(Block.VersionBody === 1)
{
var Result = Block.arrContentResult[TrNum];
if(!Result)
return - 1;
else
return Result;
}
var Type = Body[0];
var Find = 0;
switch(Type)
@ -544,7 +563,7 @@ class AccountApp extends require("./dapp")
if(BlockNum < 2800000)
MinPower = MIN_POWER_POW_ACC_CREATE + 2
else
MinPower = MIN_POWER_POW_ACC_CREATE_LAST
MinPower = MIN_POWER_POW_ACC_CREATE + 3
if(power < MinPower)
return "Error min power POW for create account (update client)";
}
@ -571,6 +590,7 @@ class AccountApp extends require("./dapp")
{
WALLET.OnCreateAccount(Account)
}
this.ResultTx = Account.Num
return true;
}
TRTransferMoney(Block, Body, BlockNum, TrNum, format_money_transfer, workstructtransfer)
@ -679,6 +699,7 @@ class AccountApp extends require("./dapp")
Account.PubKey = Item.PubKey
Account.Name = name
this.WriteStateTR(Account, TrNum)
this.ResultTx = Account.Num
Item.ID = Account.Num
this.SendMoneyTR(Block, Data.Num, Account.Num, {SumCOIN:Item.SumCOIN, SumCENT:Item.SumCENT}, BlockNum, TrNum, TR.Description,
TR.Description, 1)
@ -819,6 +840,12 @@ class AccountApp extends require("./dapp")
var Data = this.DBState.Read(Item.ID);
Data.Value = Item.PrevValue
this.DBState.Write(Data)
var History = this.DBStateHistory.Read(Item.ID);
if(History)
{
History.NextPos = Item.PrevValue.NextPos
this.DBStateHistory.Write(History)
}
}
}
if(bWas)
@ -826,6 +853,7 @@ class AccountApp extends require("./dapp")
if(NumTruncateState)
{
this.DBState.Truncate(NumTruncateState - 1)
this.DBStateHistory.Truncate(NumTruncateState - 1)
}
DBAct.Truncate(StartNum - 1)
}
@ -1116,6 +1144,16 @@ class AccountApp extends require("./dapp")
{
var BlockNum = Block.BlockNum;
var DBChanges = this.DBChanges;
for(var i = 0; i < DBChanges.BlockHistory.length; i++)
{
var Data = DBChanges.BlockHistory[i];
var Account = DBChanges.BlockMap[Data.CurID];
Data.Type = 1
Data.NextPos = Account.Value.NextPos
Account.Value.NextPos = this.SaveHistory(Data)
if(WALLET.AccountMap[Data.CurID] !== undefined)
WALLET.OnDoHistoryAct(Data, BlockNum)
}
var arr = [];
for(var key in DBChanges.BlockMap)
{
@ -1136,10 +1174,18 @@ class AccountApp extends require("./dapp")
var BackLog = {Num:undefined, ID:Account.Num, BlockNum:BlockNum, PrevValue:Account.BackupValue, TrNum:Account.ChangeTrNum,
Mode:Account.New};
this.DBAct.Write(BackLog)
}
for(var i = 0; i < arr.length; i++)
{
var Account = arr[i];
this.DBState.Write(Account)
}
for(var i = 0; i < DBChanges.BlockHistory.length; i++)
WALLET.OnDoHistoryAct(DBChanges.BlockHistory[i], BlockNum)
for(var i = 0; i < arr.length; i++)
{
var Account = arr[i];
var History = {Num:Account.Num, NextPos:Account.Value.NextPos};
this.DBStateHistory.Write(History)
}
for(var i = 0; i < DBChanges.BlockEvent.length; i++)
{
var Data = DBChanges.BlockEvent[i];
@ -1164,7 +1210,7 @@ class AccountApp extends require("./dapp")
{
var DBChanges = this.DBChanges;
if(DBChanges.RollBackTransaction)
return ;
return false;
DBChanges.BlockMaxAccount = DBChanges.TRMaxAccount
for(var key in DBChanges.TRMap)
{
@ -1184,6 +1230,7 @@ class AccountApp extends require("./dapp")
DBChanges.BlockEvent.push(DBChanges.TREvent[i])
}
global.TickCounter = 0
return true;
}
OnWriteNewAccountTR(Data, BlockNum, TrNum)
{
@ -1229,13 +1276,17 @@ class AccountApp extends require("./dapp")
return undefined;
BData.Num = Num
Value = BData.Value
BData.BackupValue = {SumCOIN:Value.SumCOIN, SumCENT:Value.SumCENT, OperationID:Value.OperationID, Smart:Value.Smart, Data:Value.Data}
var BHistory = this.DBStateHistory.Read(Num);
if(BHistory)
Value.NextPos = BHistory.NextPos
BData.BackupValue = {SumCOIN:Value.SumCOIN, SumCENT:Value.SumCENT, OperationID:Value.OperationID, Smart:Value.Smart, Data:Value.Data,
NextPos:Value.NextPos}
BlockMap[Num] = BData
}
Value = BData.Value
Data = {Num:Num, Currency:BData.Currency, PubKey:BData.PubKey, Name:BData.Name, BlockNumCreate:BData.BlockNumCreate, Adviser:BData.Adviser,
Value:{SumCOIN:Value.SumCOIN, SumCENT:Value.SumCENT, OperationID:Value.OperationID, Smart:Value.Smart, Data:CopyArr(Value.Data)},
BackupValue:BData.BackupValue}
Value:{SumCOIN:Value.SumCOIN, SumCENT:Value.SumCENT, OperationID:Value.OperationID, Smart:Value.Smart, Data:CopyArr(Value.Data),
NextPos:Value.NextPos}, BackupValue:BData.BackupValue}
TRMap[Num] = Data
}
return Data;
@ -1263,10 +1314,11 @@ class AccountApp extends require("./dapp")
throw "Not enough money on the account ID:" + FromID;
}
this.WriteStateTR(FromData, TrNum)
if(WALLET.AccountMap[FromID] !== undefined)
if(FromID > 15)
{
this.DBChanges.TRHistory.push({Direct:"-", FromID:FromID, ToID:ToID, SumCOIN:CoinSum.SumCOIN, SumCENT:CoinSum.SumCENT, Description:DescriptionFrom,
FromOperationID:FromData.Value.OperationID, Currency:FromData.Currency})
this.DBChanges.TRHistory.push({Direct:"-", Receive:0, CurID:FromID, CorrID:ToID, BlockNum:BlockNum, TrNum:TrNum, FromID:FromID,
ToID:ToID, SumCOIN:CoinSum.SumCOIN, SumCENT:CoinSum.SumCENT, Description:DescriptionFrom, FromOperationID:FromData.Value.OperationID,
Currency:FromData.Currency})
}
var ToData = this.ReadStateTR(ToID);
if(!ToData)
@ -1275,10 +1327,11 @@ class AccountApp extends require("./dapp")
}
ADD(ToData.Value, CoinSum)
this.WriteStateTR(ToData, TrNum)
if(WALLET.AccountMap[ToID] !== undefined)
if(ToID > 15)
{
this.DBChanges.TRHistory.push({Direct:"+", FromID:FromID, ToID:ToID, SumCOIN:CoinSum.SumCOIN, SumCENT:CoinSum.SumCENT, Description:DescriptionTo,
FromOperationID:FromData.Value.OperationID, Currency:ToData.Currency})
this.DBChanges.TRHistory.push({Direct:"+", Receive:1, CurID:ToID, CorrID:FromID, BlockNum:BlockNum, TrNum:TrNum, FromID:FromID,
ToID:ToID, SumCOIN:CoinSum.SumCOIN, SumCENT:CoinSum.SumCENT, Description:DescriptionTo, FromOperationID:FromData.Value.OperationID,
Currency:ToData.Currency})
}
FromData.Value.OperationID += OperationCount
if(FromData.Value.Smart)
@ -1325,6 +1378,66 @@ class AccountApp extends require("./dapp")
var sigObj = secp256k1.sign(hash, Buffer.from(PrivKey));
return sigObj.signature;
}
SaveHistory(Data)
{
var FileItem = HistoryDB.OpenDBFile(FILE_NAME_HISTORY, 1);
var FD = FileItem.fd;
var Position = FileItem.size;
if(!Position)
Position = 100
var BufWrite = BufLib.GetBufferFromObject(Data, this.HistoryFormatArr[Data.Type], 100, WorkStructHistory);
var written = fs.writeSync(FD, BufWrite, 0, BufWrite.length, Position);
if(written !== BufWrite.length)
{
TO_ERROR_LOG("DB-HISTORY", 10, "Error write to file:" + written + " <> " + BufWrite.length)
throw "Error write to FILE_NAME_HISTORY";
return false;
}
if(Position >= FileItem.size)
{
FileItem.size = Position + written
}
return Position;
}
GetHistory(Num, Count, StartPos)
{
var Position = StartPos;
var FileItem = HistoryDB.OpenDBFile(FILE_NAME_HISTORY, 0);
var FD = FileItem.fd;
if(Position === undefined)
{
var Account = this.DBStateHistory.Read(Num);
if(!Account)
{
return [];
}
Position = Account.NextPos
}
var arr = [];
while(Count > 0 && Position)
{
Count--
var BufRead = BufLib.GetNewBuffer(100);
var bytesRead = fs.readSync(FD, BufRead, 0, BufRead.length, Position);
if(bytesRead < 13)
{
ToLog("bytesRead<13 Position=" + Position)
break;
}
var Type = BufRead[0];
var format = this.HistoryFormatArr[Type];
if(!format)
{
ToLog("Error from history, type = " + Type)
break;
}
var Item = BufLib.GetObjectFromBuffer(BufRead, format, WorkStructHistory);
Item.Pos = Position
Position = Item.NextPos
arr.push(Item)
}
return arr;
}
};
module.exports = AccountApp;
var App = new AccountApp;

View File

@ -31,7 +31,7 @@ class DApp
{
return "";
}
GetVerifyTransaction(BlockNum, TrNum, Body)
GetVerifyTransaction(Block, BlockNum, TrNum, Body)
{
return 1;
}

View File

@ -33,7 +33,7 @@ class FileApp extends require("./dapp")
ConvertBufferToStr(TR)
return JSON.stringify(TR, "", 2);
}
GetVerifyTransaction(BlockNum, TrNum, Body)
GetVerifyTransaction(Block, BlockNum, TrNum, Body)
{
return 1;
}

View File

@ -147,7 +147,7 @@ class SmartApp extends require("./dapp")
}
catch(e)
{
Result = e
Result = "" + e
}
return Result;
}
@ -169,7 +169,7 @@ class SmartApp extends require("./dapp")
ConvertBufferToStr(TR)
return JSON.stringify(TR, "", 2);
}
GetVerifyTransaction(BlockNum, TrNum, Body)
GetVerifyTransaction(Block, BlockNum, TrNum, Body)
{
return 1;
}

View File

@ -9,38 +9,34 @@
*/
const crypto = require('crypto');
WebApi2.GenerateKeys = function (Params)
{
var KeyPair = crypto.createECDH('secp256k1');
var PrivKey = sha3(crypto.randomBytes(32));
KeyPair.setPrivateKey(Buffer.from(PrivKey));
var PubKey = KeyPair.getPublicKey('', 'compressed');
return {result:1, PrivKey:GetHexFromArr(PrivKey), PubKey:GetHexFromArr(PubKey), Meta:Params ? Params.Meta : undefined};
};
WebApi2.CreateAccount = function (Params,response)
{
if(typeof Params === "object" && Params.Name && Params.PubKey)
if(typeof Params === "object" && Params.Name && Params.PrivKey)
{
var TR = {Type:TYPE_TRANSACTION_CREATE, Currency:Params.Currency, PubKey:GetArrFromHex(Params.PubKey), Name:Params.Name, Smart:Params.Smart,
};
var KeyPair = crypto.createECDH('secp256k1');
KeyPair.setPrivateKey(Buffer.from(GetArrFromHex(Params.PrivKey)));
var PubKey = KeyPair.getPublicKey('', 'compressed');
var TR = {Type:TYPE_TRANSACTION_CREATE, Currency:Params.Currency, PubKey:PubKey, Name:Params.Name, Smart:Params.Smart, };
var Body = BufLib.GetBufferFromObject(TR, FORMAT_CREATE, 1000, {}, 1);
Body = Body.slice(0, Body.len + 12);
SendTransaction(Body, TR, MIN_POWER_POW_ACC_CREATE_LAST, function (result,TR,Body)
SendTransaction(Body, TR, Params.Wait, function (result,text)
{
var Result = {result:result < 1 ? 0 : 1, text:TR._text, TxID:GetHexFromArr(TR._TxID.slice(0, TR_TICKET_HASH_LENGTH + 6)), BlockNum:TR._BlockNum,
var Result = {result:result, text:text, TxID:GetHexFromArr(TR._TxID.slice(0, TR_TICKET_HASH_LENGTH + 6)), BlockNum:TR._BlockNum,
Meta:Params.Meta, };
var Str = JSON.stringify(Result);
response.end(Str);
});
return null;
}
return {result:0, Meta:Params.Meta};
};
WebApi2.GetBalance = function (Params,response)
{
if(typeof Params === "object")
{
var arr = DApps.Accounts.GetRowsAccounts(ParseNum(Params.AccountID), 1);
if(arr.length)
{
var Value = arr[0].Value;
var Result = {result:1, SumCOIN:Value.SumCOIN, SumCENT:Value.SumCENT, Meta:Params.Meta, };
return Result;
}
}
return {result:0, Meta:Params.Meta};
return {result:0, Meta:Params ? Params.Meta : undefined};
};
var MapSendID = {};
WebApi2.Send = function (Params,response)
@ -92,15 +88,30 @@ WebApi2.Send = function (Params,response)
TR.Sign = DApps.Accounts.GetSignTransferTx(TR, GetArrFromHex(Params.FromPrivKey));
var Body = BufLib.GetBufferFromObject(TR, FORMAT_MONEY_TRANSFER3, MAX_TRANSACTION_SIZE, {}, 1);
Body = Body.slice(0, Body.len + 12);
SendTransaction(Body, TR, undefined, function (result,TR,Body)
SendTransaction(Body, TR, Params.Wait, function (result,text)
{
var Result = {result:result < 1 ? 0 : 1, text:TR._text, TxID:GetHexFromArr(TR._TxID.slice(0, TR_TICKET_HASH_LENGTH + 6)), BlockNum:TR._BlockNum,
var Result = {result:result, text:text, TxID:GetHexFromArr(TR._TxID.slice(0, TR_TICKET_HASH_LENGTH + 6)), BlockNum:TR._BlockNum,
Meta:Params.Meta, };
var Str = JSON.stringify(Result);
response.end(Str);
});
return null;
};
WebApi2.GetBalance = function (Params,response)
{
if(typeof Params === "object")
{
var arr = DApps.Accounts.GetRowsAccounts(ParseNum(Params.AccountID), 1);
if(arr.length)
{
var Value = arr[0].Value;
var Result = {result:1, SumCOIN:Value.SumCOIN, SumCENT:Value.SumCENT, PubKey:GetHexFromArr(arr[0].PubKey), Meta:Params.Meta,
};
return Result;
}
}
return {result:0, Meta:Params ? Params.Meta : undefined};
};
WebApi2.GetTransaction = function (Params)
{
if(typeof Params === "object" && Params.TxID)
@ -108,44 +119,82 @@ WebApi2.GetTransaction = function (Params)
var Arr = GetArrFromHex(Params.TxID);
var BlockNum = ReadUintFromArr(Arr, TR_TICKET_HASH_LENGTH);
var Block = SERVER.ReadBlockDB(BlockNum);
if(Block)
if(Block && Block.arrContent)
{
Arr = Arr.slice(0, TR_TICKET_HASH_LENGTH);
for(var i = 0; i < Block.arrContent.length; i++)
{
var Body = Block.arrContent[i];
var Nonce = ReadUintFromArr(Body, Body.length - 6);
var Arr2 = CreateTxID(Body, BlockNum, Nonce);
Arr2 = Arr2.slice(0, TR_TICKET_HASH_LENGTH);
var Arr2 = GetTxID(BlockNum, Body);
if(CompareArr(Arr2, Arr) === 0)
{
var TR = DApps.Accounts.GetObjectTransaction(Body);
if(TR)
{
ConvertBufferToStr(TR);
TR.result = 1;
TR.Meta = Params.Meta;
return TR;
}
return GetTransactionFromBody(Params, Block, i, Body);
}
}
}
}
return {result:0, Meta:Params.Meta};
else
{
if(typeof Params === "object" && Params.BlockNum && Params.TrNum !== undefined)
{
var Block = SERVER.ReadBlockDB(Params.BlockNum);
if(Block && Block.arrContent)
{
var Body = Block.arrContent[Params.TrNum];
if(Body)
{
return GetTransactionFromBody(Params, Block, Params.TrNum, Body);
}
}
}
}
return {result:0, Meta:Params ? Params.Meta : undefined};
};
WebApi2.GetHistoryTransactions = function (Params)
{
};
WebApi2.GenerateKeys = function (Params)
{
var KeyPair = crypto.createECDH('secp256k1');
var PrivKey = sha3(crypto.randomBytes(32));
KeyPair.setPrivateKey(Buffer.from(PrivKey));
var PubKey = KeyPair.getPublicKey('', 'compressed');
return {result:1, PrivKey:GetHexFromArr(PrivKey), PubKey:GetHexFromArr(PubKey), Meta:Params.Meta};
if(typeof Params === "object" && Params.AccountID)
{
if(!Params.Count)
Params.Count = 100;
var arr = DApps.Accounts.GetHistory(Params.AccountID, Params.Count, Params.NextPos);
if(Params.GetTxID || Params.GetDescription)
{
for(var i = 0; i < arr.length; i++)
{
var Item = arr[i];
var Block = SERVER.ReadBlockDB(Item.BlockNum);
if(!Block || (!Block.arrContent))
continue;
var Body = Block.arrContent[Item.TrNum];
if(!Body)
continue;
if(Params.GetTxID)
{
Item.TxID = GetHexFromArr(GetTxID(Item.BlockNum, Body));
}
if(Params.GetDescription)
{
var TR = DApps.Accounts.GetObjectTransaction(Body);
if(TR)
{
Item.Description = TR.Description;
}
}
}
}
var Result = {result:arr.length > 0 ? 1 : 0, History:arr, Tail:DApps.Accounts.DBStateHistory.Read(Params.AccountID), Meta:Params ? Params.Meta : undefined};
return Result;
}
return {result:0, Meta:Params ? Params.Meta : undefined};
};
var DELTA_FOR_TIME_TX = 1;
function GetTxID(BlockNum,Body)
{
var Nonce = ReadUintFromArr(Body, Body.length - 6);
var Arr2 = CreateTxID(Body, BlockNum, Nonce);
return Arr2.slice(0, TR_TICKET_HASH_LENGTH + 6);
};
function CreateTxID(body,BlockNum,Nonce)
{
body.writeUIntLE(BlockNum, body.length - 12, 6);
@ -198,7 +247,7 @@ function CreateHashBodyPOWInnerMinPower(TR,arr,MinPow,startnonce)
}
};
function SendTransaction(Body,TR,SumPow,F)
function SendTransaction(Body,TR,Wait,F)
{
if(Body.length > 16000)
{
@ -207,6 +256,8 @@ function SendTransaction(Body,TR,SumPow,F)
F(1, TR, Body);
return ;
}
global.GlobalRunID++;
let WebID = global.GlobalRunID;
CreateNonceAndSend(0, 0);
function CreateNonceAndSend(startnonce,NumNext)
@ -218,8 +269,8 @@ function CreateNonceAndSend(startnonce,NumNext)
F(0, TR, Body);
return ;
}
var nonce = CreateHashBodyPOWInnerMinPower(TR, Body, SumPow, startnonce);
process.RunRPC("AddTransactionFromWeb", GetHexFromArr(Body), function (Err,text)
var nonce = CreateHashBodyPOWInnerMinPower(TR, Body, undefined, startnonce);
process.RunRPC("AddTransactionFromWeb", {WebID:WebID, HexValue:GetHexFromArr(Body)}, function (Err,text)
{
TR._result = Err ? 0 : 1;
TR._text = text;
@ -239,7 +290,33 @@ function CreateNonceAndSend(startnonce,NumNext)
return ;
}
}
F(TR._result, TR, Body);
if(Wait && TR._result)
{
global.GlobalRunMap[WebID] = F;
}
else
{
F(TR._result < 1 ? 0 : 1, text);
}
});
};
};
function GetTransactionFromBody(Params,Block,TrNum,Body)
{
var TR = DApps.Accounts.GetObjectTransaction(Body);
if(TR)
{
ConvertBufferToStr(TR);
TR.result = 1;
TR.Meta = Params.Meta;
if(Block.VersionBody === 1 && Block.arrContentResult)
{
TR.result = Block.arrContentResult[TrNum];
}
TR.BlockNum = Block.BlockNum;
TR.TrNum = TrNum;
return TR;
}
return {result:0, Meta:Params ? Params.Meta : undefined};
};

View File

@ -126,13 +126,13 @@ function OnMessageWeb(msg)
}
};
function AddTransactionFromWeb(HexValue)
function AddTransactionFromWeb(Params)
{
var body = GetArrFromHex(HexValue);
var body = GetArrFromHex(Params.HexValue);
if(global.TX_PROCESS && global.TX_PROCESS.Worker)
{
var StrHex = GetHexFromArr(sha3(body));
global.TX_PROCESS.Worker.send({cmd:"FindTX", TX:StrHex});
global.TX_PROCESS.Worker.send({cmd:"FindTX", TX:StrHex, Web:1, WebID:Params.WebID});
}
var Res = SERVER.AddTransaction({body:body}, 1);
var text = AddTrMap[Res];
@ -226,14 +226,6 @@ function StartChildProcess(Item)
ITEM.Worker = undefined;
}
}
try
{
ITEM.Worker.send({cmd:"Alive"});
}
catch(e)
{
ITEM.Worker = undefined;
}
if(!ITEM.Worker)
{
ITEM.LastAlive = (Date.now()) + ITEM.PeriodAlive * 3;
@ -278,10 +270,27 @@ function StartChildProcess(Item)
}
ToLogClient(msg.Str, msg.StrKey, msg.bFinal);
break;
case "RetFindTX":
if(WebProcess && WebProcess.Worker)
{
WebProcess.Worker.send(msg);
if(msg.Web)
break;
}
ToLogClient(msg.ResultStr, msg.TX, msg.bFinal);
break;
case "online":
if(ITEM.Worker)
ToLog("RUNING " + ITEM.Name + " : " + msg.message + " pid: " + ITEM.Worker.pid);
break;
case "WriteBodyResult":
var Block = SERVER.ReadBlockDB(msg.BlockNum);
if(Block)
{
Block.arrContentResult = msg.arrContentResult;
SERVER.WriteBodyResultDB(Block);
}
break;
default:
if(ITEM.OnMessage)
{
@ -290,6 +299,20 @@ function StartChildProcess(Item)
break;
}
});
ITEM.Worker.on('error', function (err)
{
ToError("ERROR IN " + ITEM.Name + " Err : " + err);
ITEM.Worker = undefined;
});
ITEM.Worker.on('close', function (code)
{
ToError("CLOSE " + ITEM.Name);
ITEM.Worker = undefined;
});
}
if(ITEM.Worker)
{
ITEM.Worker.send({cmd:"Alive"});
}
}, 500);
ITEM.RunRPC = function (Name,Params,F)
@ -873,7 +896,7 @@ function TestSignLib(MaxTime)
{
ToLog("*************** WARNING: VERY SLOW LIBRARY: secp256k1 ***************");
ToLog("You can only process: " + Num + " transactions");
ToLog("Install all dependent packages and run the installation command:\ncd Source/node_modules/secp256k1 \nnode-gyp build");
ToLog("Install all dependent packages, see detail: https://www.npmjs.com/package/secp256k1");
return 0;
}
}

View File

@ -57,7 +57,7 @@ process.on('message', function (msg)
process.send({cmd:"retcall", id:msg.id, Err:Err, Params:Ret});
break;
case "FindTX":
global.TreeFindTX.SaveValue(msg.TX, msg.TX);
global.TreeFindTX.SaveValue(msg.TX, msg);
break;
case "SetSmartEvent":
global.TreeFindTX.SaveValue("Smart:" + msg.Smart, 1);

View File

@ -86,6 +86,21 @@ process.on('message', function (msg)
ToLogClient0(msg.Str, msg.StrKey, msg.bFinal);
break;
}
case "RetFindTX":
{
if(msg.WebID)
{
var F = global.GlobalRunMap[msg.WebID];
if(F)
{
delete global.GlobalRunMap[msg.WebID];
F(msg.Result, msg.ResultStr);
break;
}
}
ArrLogClient.push({text:msg.ResultStr, key:msg.TX, final:msg.bFinal, });
break;
}
}
});
@ -96,7 +111,7 @@ function CheckAlive()
var Delta = Date.now() - LastAlive;
if(Delta > CHECK_STOP_CHILD_PROCESS)
{
ToLog("HOSTING: ALIVE TIMEOUT Stop and exit: " + Delta + "/" + global.CHECK_STOP_CHILD_PROCESS);
ToLog("HOSTING: ALIVE TIMEOUT Stop and exit: " + Delta + "/" + global.CHECK_STOP_CHILD_PROCESS, 0);
process.exit(0);
return ;
}
@ -106,7 +121,7 @@ process.on('uncaughtException', function (err)
ToError(err.stack);
ToLog(err.stack);
TO_ERROR_LOG("HOSTING", 777, err);
ToLog("-----------------HOSTING EXIT------------------");
ToLog("-----------------HOSTING EXIT------------------", 0);
process.exit();
});
process.on('error', function (err)
@ -154,7 +169,7 @@ if(global.HTTPS_HOSTING_DOMAIN)
}
if(GetNewSert)
{
ToLog("Start get new SERT");
ToLog("Start get new SERT", 0);
var opts = {domains:[global.HTTPS_HOSTING_DOMAIN], email:'progr76@gmail.com', agreeTos:true, communityMember:true, };
greenlock.register(opts).then(function (certs)
{
@ -194,7 +209,7 @@ function MainHTTPFunction(request,response)
else
{
var Str = "Error postDataChunk.length=" + postDataChunk.length;
ToLog(Str);
ToLog(Str, 0);
Response.writeHead(405, {'Content-Type':'text/html'});
Response.end(Str);
}
@ -406,8 +421,7 @@ HostingCaller.GetCurrentInfo = function (Params)
{
var Ret = {result:1, VersionNum:global.UPDATE_CODE_VERSION_NUM, MaxNumBlockDB:SERVER.GetMaxNumBlockDB(), CurBlockNum:GetCurrentBlockNumByTime(),
MaxAccID:DApps.Accounts.GetMaxAccount(), MaxDappsID:DApps.Smart.GetMaxNum(), NETWORK:global.NETWORK, CurTime:Date.now(), DELTA_CURRENT_TIME:DELTA_CURRENT_TIME,
MIN_POWER_POW_TR:MIN_POWER_POW_TR, FIRST_TIME_BLOCK:FIRST_TIME_BLOCK, CONSENSUS_PERIOD_TIME:CONSENSUS_PERIOD_TIME, MIN_POWER_POW_ACC_CREATE:MIN_POWER_POW_ACC_CREATE_LAST,
};
MIN_POWER_POW_TR:MIN_POWER_POW_TR, FIRST_TIME_BLOCK:FIRST_TIME_BLOCK, CONSENSUS_PERIOD_TIME:CONSENSUS_PERIOD_TIME, };
if(typeof Params === "object" && Params.Diagram == 1)
{
var arrNames = ["MAX:ALL_NODES", "MAX:HASH_RATE_G"];
@ -601,7 +615,7 @@ HostingCaller.SendTransactionHex = function (Params,response)
{
if(typeof Params !== "object" || !Params.Hex)
return {result:0, text:"object requre"};
process.RunRPC("AddTransactionFromWeb", Params.Hex, function (Err,text)
process.RunRPC("AddTransactionFromWeb", {HexValue:Params.Hex}, function (Err,text)
{
var Result = {result:!Err, text:text};
var Str = JSON.stringify(Result);
@ -715,8 +729,8 @@ HostingCaller.DappStaticCall = function (Params)
return {result:0};
return HTTPCaller.DappStaticCall(Params);
};
var GlobalRunID = 0;
var GlobalRunMap = {};
global.GlobalRunID = 0;
global.GlobalRunMap = {};
process.RunRPC = function (Name,Params,F)
{
if(F)