blockchain-spv icon indicating copy to clipboard operation
blockchain-spv copied to clipboard

Make params JSON-friendly?

Open paulkernfeld opened this issue 8 years ago • 5 comments

The params object is almost JSON-friendly, except that it takes in buffers for prevHash and merkleRoot. What if it accepted hex strings instead of, or in addition to buffers? That would be cool for me especially, because it would make it easy to load configuration from files. For example, see the "Setup" section here.

paulkernfeld avatar Apr 05 '16 11:04 paulkernfeld

That's a good point, I can do this if it makes things easier. But how would it work if you need to override functions? For example, see the webcoin-bitcoin-testnet params, which provide their own difficulty calculation code.

I've been writing the param code with the assumption that the params would be in their own module, including blockchain, network, and wallet params.

mappum avatar Apr 05 '16 17:04 mappum

The assumption that I'm making is that people may want to frequently add checkpoints for existing blockchains without changing the logic of the blockchain. I certainly find myself wanting to do that, although I don't know whether that will become a common use case. For me, this would be possibly convenient but not important. Also, I'm happy to implement it if you think it's a good idea.

paulkernfeld avatar Apr 05 '16 19:04 paulkernfeld

You're probably right about that, and I think the best way to do that would be to remove the checkpoints from the params and have them passed in as options to the Blockchain constructor. What do you think?

mappum avatar Apr 05 '16 19:04 mappum

For my use case, I think that would be nice. However, there is definitely a complexity cost to breaking the configuration into more pieces, so you would understand that tradeoff better.

paulkernfeld avatar Apr 05 '16 19:04 paulkernfeld

The question for this is: who should manage the checkpoints? I.e. should they be provided by the webcoin project in parameters, and overridden by developers when necessary, or should the default be to not use any checkpoints and have developers opt-in to them?

mappum avatar May 12 '16 01:05 mappum