blockchain-spv
blockchain-spv copied to clipboard
Make params JSON-friendly?
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.
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.
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.
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?
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.
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?