:: Re: [Libbitcoin] Master libbitcoin-…
Góra strony
Delete this message
Reply to this message
Autor: Eric Voskuil
Data:  
Dla: Police Terror, libbitcoin
Temat: Re: [Libbitcoin] Master libbitcoin-server on testnet
The zero bound is easily resolved by using the distribution bound
parameters. The thread safety is a little harder to do optimally, but
this should do it:

https://github.com/libbitcoin/libbitcoin/pull/559

Please let me know how it looks for you. Note that there are multiple
PRs currently working their way through.

e

On 10/21/2016 01:27 PM, Eric Voskuil wrote:
> On 10/21/2016 07:36 AM, Police Terror wrote:
>> Looking at libbitcoin/src/utility/random.cpp, I see that
>> nonzero_pseudo_random() is throwing. Why isn't that an assert instead?
>
> (1) In a !NDEBUG build the assert would not execute. The result would
> have to be either a zero value return, other (fixed) value or an
> infinite loop - any of which is catostrophic. A failure return could be
> allowed, but it would push the hard failure out to each caller, creating
> failure-handling complexity without any means to resolve the failure
> (except calling again, which is where we are with the loop).
>
> (2) In a DEBUG build the result is the same as the throw, it terminates
> the process.
>
> Asserts are useful for checking developer assumptions, but are not
> useful in validating inputs from public interfaces or resolving
> unrecoverable failures.
>
>> terminate called after throwing an instance of 'std::runtime_error'
>> what(): random_device::random_device(const std::string&)
>
> It does look like the error is being handled exactly as intended. If the
> RNG returns a value of zero 100 times in a row, the only thing one can
> do is try longer. The question is why this is happening. My best guess
> is lack of thread safety. Otherwise you might want to inspect your
> platform for "enhancements" :).
>
> e