Skip to content

Commit

Permalink
Merge pull request #3 from Adamant-im/dev-states
Browse files Browse the repository at this point in the history
State storing feature
  • Loading branch information
zyuhel authored Apr 18, 2018
2 parents d0d946b + 390251d commit 02437d3
Show file tree
Hide file tree
Showing 11 changed files with 1,188 additions and 4 deletions.
38 changes: 38 additions & 0 deletions api/http/states.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict';

var Router = require('../../helpers/router');
var httpApi = require('../../helpers/httpApi');


/**
* Binds api with modules and creates common url.
* - End point: `/api/states`
* - Private API:
* - post /normalize
* - post /finalize
*
* - Sanitized
* - get /get
* @memberof module:states
* @requires helpers/Router
* @requires helpers/httpApi
* @constructor
* @param {Object} statesModule - Module storing options state
* @param {scope} app - Network app.
*/
// Constructor
function StatesHttpApi (statesModule, app) {

var router = new Router();

router.map(statesModule.internal, {
'get /get': 'getTransactions',
'post /normalize': 'normalize',
'post /store': 'store'
});


httpApi.registerEndpoint('/api/states', app, router, statesModule.isLoaded);
}

module.exports = StatesHttpApi;
6 changes: 6 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ var config = {
multisignatures: './modules/multisignatures.js',
dapps: './modules/dapps.js',
chats: './modules/chats.js',
states: './modules/states.js',
crypto: './modules/crypto.js',
sql: './modules/sql.js',
cache: './modules/cache.js'
Expand All @@ -147,6 +148,7 @@ var config = {
blocks: { http: './api/http/blocks.js' },
dapps: { http: './api/http/dapps.js' },
chats: { http: './api/http/chats.js' },
states: { http: './api/http/states.js' },
delegates: { http: './api/http/delegates.js' },
loader: { http: './api/http/loader.js' },
multisignatures: { http: './api/http/multisignatures.js' },
Expand Down Expand Up @@ -462,6 +464,7 @@ d.run(function () {
logic: ['db', 'bus', 'schema', 'genesisblock', function (scope, cb) {
var Transaction = require('./logic/transaction.js');
var Chat = require('./logic/chat.js');
var State = require('./logic/state.js');
var Block = require('./logic/block.js');
var Account = require('./logic/account.js');
var Peers = require('./logic/peers.js');
Expand Down Expand Up @@ -495,6 +498,9 @@ d.run(function () {
}],
chat: ['db', 'bus', 'ed', 'schema', 'account', 'logger', function (scope, cb) {
new Chat(scope.db, scope.ed, scope.schema, scope.account, scope.logger, cb);
}],
state: ['db', 'bus', 'ed', 'schema', 'account', 'logger', function (scope, cb) {
new State(scope.db, scope.ed, scope.schema, scope.account, scope.logger, cb);
}],
block: ['db', 'bus', 'ed', 'schema', 'genesisblock', 'account', 'transaction', function (scope, cb) {
new Block(scope.ed, scope.schema, scope.transaction, cb);
Expand Down
4 changes: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"port": 36666,
"address": "0.0.0.0",
"version": "0.1.2",
"minVersion": ">=0.1.0",
"version": "0.2.0",
"minVersion": ">=0.2.0",
"fileLogLevel": "info",
"logFileName": "logs/adamant.log",
"consoleLogLevel": "none",
Expand Down
3 changes: 2 additions & 1 deletion helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ module.exports = {
dapp: 2500000000,
old_chat_message: 500000,
chat_message: 100000,
state_store: 100000,
profile_update: 5000000,
avatar_upload: 10000000
},
Expand Down Expand Up @@ -96,7 +97,7 @@ module.exports = {
10000000 // Milestone 8
],
offset: 2000000, // Start rewards at block (n)
distance: 6300000, // Distance between each milestone
distance: 6300000 // Distance between each milestone
},
signatureLength: 196,
// WARNING: When changing totalAmount you also need to change getBlockRewards(int) SQL function!
Expand Down
3 changes: 2 additions & 1 deletion helpers/transactionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ module.exports = {
DAPP: 5,
IN_TRANSFER: 6,
OUT_TRANSFER: 7,
CHAT_MESSAGE: 8
CHAT_MESSAGE: 8,
STATE: 9
};
Loading

0 comments on commit 02437d3

Please sign in to comment.