constants: minor.

This commit is contained in:
Christopher Jeffrey 2017-01-06 21:14:11 -08:00
parent 3236c367b1
commit d396cdd0fd
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 30 additions and 8 deletions

View File

@ -33,7 +33,7 @@ var Logger = require('../node/logger');
var IP = require('../utils/ip');
var encoding = require('../utils/encoding');
var consensus = require('../protocol/consensus');
var USER_VERSION = require('../../package.json').version;
var pkg = require('../../package.json');
/**
* RPC
@ -324,7 +324,7 @@ RPC.prototype.getinfo = co(function* getinfo(args) {
balance = yield this.wallet.getBalance();
return {
version: USER_VERSION,
version: pkg.version,
protocolversion: this.pool.protoVersion,
walletversion: 0,
balance: Amount.btc(balance.unconfirmed, true),
@ -377,7 +377,7 @@ RPC.prototype.getnetworkinfo = co(function* getnetworkinfo(args) {
throw new RPCError('getnetworkinfo');
return {
version: USER_VERSION,
version: pkg.version,
subversion: this.pool.userAgent,
protocolversion: this.pool.protoVersion,
localservices: this.pool.address.services,
@ -2728,7 +2728,7 @@ RPC.prototype.dumpwallet = co(function* dumpwallet(args) {
file = toString(args[0]);
time = util.date();
out = [
util.fmt('# Wallet Dump created by BCoin %s', USER_VERSION),
util.fmt('# Wallet Dump created by BCoin %s', pkg.version),
util.fmt('# * Created on %s', time),
util.fmt('# * Best block at time of backup was %d (%s),',
this.chain.height, this.chain.tip.rhash()),

View File

@ -7,7 +7,7 @@
'use strict';
var USER_VERSION = require('../../package.json').version;
var pkg = require('../../package.json');
/**
* Default protocol version.
@ -85,7 +85,7 @@ exports.REQUIRED_SERVICES = 0
* @default
*/
exports.USER_AGENT = '/bcoin:' + USER_VERSION + '/';
exports.USER_AGENT = '/bcoin:' + pkg.version + '/';
/**
* Max message size (~4mb with segwit, formerly 2mb)

View File

@ -27,6 +27,28 @@ exports.COIN = 100000000;
exports.MAX_MONEY = 21000000 * exports.COIN;
/**
* Base block subsidy (consensus).
* Note to shitcoin implementors: if you
* increase this to anything greater than
* 33 bits, getReward will have to be
* modified to handle the shifts.
* @const {Amount}
* @default
*/
exports.BASE_REWARD = 50 * exports.COIN;
/**
* Half base block subsidy. Required to
* calculate the reward properly (with
* only 32 bit shifts available).
* @const {Amount}
* @default
*/
exports.HALF_REWARD = Math.floor(exports.BASE_REWARD / 2);
/**
* Maximum block base size (consensus).
* @const {Number}
@ -302,7 +324,7 @@ exports.getReward = function getReward(height, interval) {
// cheat. We only start halving once the
// halvings are at least 1.
if (halvings === 0)
return 5000000000;
return exports.BASE_REWARD;
return 2500000000 >>> (halvings - 1);
return exports.HALF_REWARD >>> (halvings - 1);
};