sigp/discv5

"PROTOCOL_ID has already been initialized" error when creating more than one `Discv5` instance

ogenev opened this issue · 3 comments

I'm getting "PROTOCOL_ID has already been initialized" error when trying to create more than one Discv5 instance.

discv5 version: 0.2.0

Here is an example code to replicate the issue:

use discv5::{Discv5, Discv5ConfigBuilder};
use discv5::enr::{CombinedKey, EnrBuilder};

fn main() {
    let config_1 = Discv5ConfigBuilder::new().protocol_id("fooooo").build();
    let enr_key_1 = CombinedKey::generate_secp256k1();
    let enr_1 = EnrBuilder::new("v4").build(&enr_key_1).unwrap();
    let _ = Discv5::new(enr_1, enr_key_1, config_1).unwrap();

    let config_2 = Discv5ConfigBuilder::new().build();
    let enr_key_2 = CombinedKey::generate_secp256k1();
    let enr_2 = EnrBuilder::new("v4").build(&enr_key_2).unwrap();
    let _ = Discv5::new(enr_2, enr_key_2, config_2).unwrap();
}

The last line panics with:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "PROTOCOL_ID has already been initialized"'

Just commenting here to acknowledge we've received the bug report and we know what's going on, expect a solution in a couple of days. This version will probably be yanked as well

@ogenev you can use master in the meantime, we'll publish a release and release notes soon. Let me know if you need any help

closed by #163