bcoin-org / bcfg Goto Github PK
View Code? Open in Web Editor NEWConfig parser for bcoin
License: Other
Config parser for bcoin
License: Other
This is just a documentation of user error, perhaps nothing to fix. But I want a reference posted in case someone else does this.
Consider you're working with Bitcoin Core and you accidentally try to start bcoin with:
$ bcoin -blocksonly
What happens is the following:
Strictly because of the single dash, blocksonly
gets interpreted as a series of single-letter keys (b
, l
, o
, c
...) , and sets all the corresponding values to "true"
(the STRING, not a boolean). In the case of the letter n
an "alias" already exists, so the value of network
is set to "true"
:
Lines 908 to 923 in 1216c77
So:
{
b: 'true',
l: 'true',
o: 'true',
c: 'true',
k: 'true',
s: 'true',
network: 'true',
y: 'true'
}
As bcoin continues to process the configuration parameters, it will alert the user the network is invalid:
$ bcoin -blocksonly
/Users/matthewzipkin/Desktop/work/bcoin/node_modules/bsert/lib/assert.js:84
throw new AssertionError({
^
AssertionError [ERR_ASSERTION]: Unknown network.
at Function.create (/Users/matthewzipkin/Desktop/work/bcoin/lib/protocol/network.js:135:5)
at Function.get (/Users/matthewzipkin/Desktop/work/bcoin/lib/protocol/network.js:181:22)
at new Node (/Users/matthewzipkin/Desktop/work/bcoin/lib/node/node.js:49:28)
at new FullNode (/Users/matthewzipkin/Desktop/work/bcoin/lib/node/fullnode.js:40:5)
at Object.<anonymous> (/Users/matthewzipkin/Desktop/work/bcoin/bin/node:41:14)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10) {
type: 'AssertionError',
name: 'AssertionError [ERR_ASSERTION]',
code: 'ERR_ASSERTION',
generatedMessage: false,
actual: undefined,
expected: true,
operator: '=='
}
There are several issues that have accumulated, so I will try to sum up
desired behaviour for the bcfg.
camelCase
to represent namespaces internally. Currently it onlyconfig
, that just overridesgetFile
. This will remove inconsistency with ConfigcamelCase
forcamelCase
to pass the-
(dash) to have multi word names.log-network
)dash-case
) prefix, insteadFormat of the file does not change. The thing that changes is how we
process the results.
Example:
option-example: 123
optionexample: 111
Current behaviour wont differentiate between these two. It will be
optionexample
internally. These will be two different options with new
behaviour: optionExample
and optionexample
.
Similar problem:
MODULE_OPTION_EXAMPLE=123
MODULE_OPTIONEXAMPLE=111
will be: optionexample
internally. New behaviour optionExample
and
optionexample
.
Similar.
--option-example=123 --optionexample=123
This will be: optionexample
internally. New behaviour: optionExample
and
optionexample
.
Injected options have the similar behaviour.
config.inject({
optionExample: 123,
optionexample: 111
});
New behaviour will leave them as is, separate. (options
being the namespace
)
query: https://..something/something?exampleOption=123&exampleoption=111
hash: https://..something/something#exampleOption=123&exampleoption=111
These will also generate two separate internal options.
Getting configurations will still be the same, but will query keys with new
behaviour.
config.str('example-option');
config.str('exampleoption');
Now these will query two different options: optionExample
and optionexample
.
Filtering will now use case information as namespace.
// Configuration with `optionExample` and `optionexample`.
const nconfig = config.filter('option');
// will only have `example` from the `optionExample`.
When you configure aliases, if the configuration you are using is multi word, it does not accept -
in the middle.
For example, 'p': 'http-port'
would not work for http-port
alias instead you will need to use 'p': 'httpport'
.
I believe it should accept proper form for the aliases.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.