EthereumJ se conecta a un nodo privado

Necesito conectarme a un nodo ethereum privado usando ethereumj sin el archivo ethereum.conf. Necesito configurar la conexión desde el código usando Spring Framework.

Respuestas (2)

Está funcionando para mí. Puede ser que ayude a algunas personas.

public class EthereumAppConfig implements BeanPostProcessor {

    private static final List<String> ipList = new ArrayList<>();

    private static ConfigValue value(Object value) {
        return ConfigValueFactory.fromAnyRef(value);
    }





    @Override
    public Object postProcessBeforeInitialization(Object o, String s) throws BeansException {
        if (o instanceof SystemProperties)
            ((SystemProperties) o).overrideParams(getConfig());

        return o;
    }

    @Override
    public Object postProcessAfterInitialization(Object o, String s) throws BeansException {
        return o;
    }








    private static Config getConfig() {
        ipList.add("0.0.0.0:00000");
        List<Map<String, String>> peerActives = new ArrayList<>();


        Map<String, String> urls = new HashMap<>();

        urls.put("url", "enode://0");
        urls.put("url", "enode://1");
        urls.put("url", "enode://2");
        urls.put("url", "enode://4");

        peerActives.add(
                urls
        );
        return ConfigFactory.empty()
                .withValue("peer.discovery.enabled", value(true))
                .withValue("peer.discovery.external.ip", value("0.0.0.0"))
                .withValue("peer.discovery.bind.ip", value("0.0.0.0"))
                .withValue("peer.discovery.persist", value("false"))
                .withValue("peer.listen.port", value(00000))
                .withValue("peer.privateKey", value(Hex.toHexString(ECKey.fromPrivate(("0").getBytes()).getPrivKeyBytes())))
                .withValue("peer.networkId", value(76543))
                .withValue("sync.enabled", value(true))
                .withValue("genesis", value("genesis.json"))
                .withValue("database.dir", value("database"))
                .withValue("peer.discovery.ip.list", value(ipList))
                .withValue("peer.active", value(peerActives))
                .withValue("mine.start", value(true));
    }

}

Consulte el código que cargué en Github que hace exactamente esto :) Contiene toda la configuración relevante en el .confarchivo.