npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

hicon-consensus

v0.0.1

Published

Node.js bindings for HiCon hybrid consensus algorithm

Readme

HiCon: Algoritmo de Consenso Híbrido CCR-CCC

Rust Version NPM Version License

Un algoritmo de consenso distribuido de alto rendimiento que combina Consenso por Redundancia de Capas Cruzadas (CCR) y Consenso por Comunicación de Capas Cruzadas (CCC) para lograr mejor escalabilidad, tolerancia a fallos y rendimiento.

Características

  • Híbrido CCR-CCC: Combina dos enfoques complementarios de consenso para mayor resistencia
  • Alto rendimiento: Optimizado para alto throughput y baja latencia
  • Tolerancia a fallos: Diseñado para ser resistente a fallos de nodos
  • Escalabilidad: Funciona eficientemente en clusters grandes
  • Criptografía post-cuántica: Implementación preparada para amenazas cuánticas
  • Bindings para Node.js: API fácil de usar para aplicaciones JavaScript

Uso en Rust

Para usar HiCon en proyectos Rust, añade esto a tu Cargo.toml:

[dependencies]
hybridconsensus = "0.1.0"

Ejemplo básico:

use hybridconsensus::node::Node;
use hybridconsensus::network::NetworkManager;
use hybridconsensus::crypto::CryptoManager;
use hybridconsensus::metrics::MetricsCollector;
use hybridconsensus::sharding::ShardManager;
use std::sync::Arc;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Crear componentes necesarios
    let network_manager = Arc::new(NetworkManager::default());
    let crypto_manager = Arc::new(CryptoManager::new());
    let metrics_collector = Arc::new(MetricsCollector::new());
    let shard_manager = Arc::new(ShardManager::new(10));

    // Crear y configurar nodo
    let node = Node::new(
        "node-1".to_string(),
        network_manager,
        shard_manager,
        crypto_manager,
        metrics_collector,
    );

    // Iniciar el nodo
    tokio::spawn(async move {
        if let Err(e) = node.run().await {
            eprintln!("Error running node: {:?}", e);
        }
    });

    // Mantener el programa ejecutándose
    tokio::signal::ctrl_c().await?;
    println!("Shutting down...");

    Ok(())
}

Uso en Node.js

Para usar HiCon en proyectos Node.js, instala el paquete:

npm install hicon-consensus

Ejemplo básico:

const { createNode } = require('hicon-consensus');

async function main() {
    // Crear y configurar nodo
    const node = createNode({
        id: 'node-1',
        logPath: './data/node1',
        redundancyFactor: 3,
        enableEncryption: true
    });
    
    // Escuchar eventos
    node.on('stateChange', (oldState, newState) => {
        console.log(`Estado cambiado: ${oldState} -> ${newState}`);
    });
    
    // Iniciar nodo y conectar a peers
    await node.start(['node-2', 'node-3', 'node-4']);
    
    // Proponer un valor
    try {
        const result = await node.propose(JSON.stringify({ key: 'test-key', value: 'test-value' }));
        console.log(`Consenso alcanzado: ${result.success}, término: ${result.term}, índice: ${result.index}`);
    } catch (error) {
        console.error('Error al proponer valor:', error);
    }
    
    // Al finalizar
    process.on('SIGINT', async () => {
        await node.stop();
        process.exit(0);
    });
}

main().catch(console.error);

Para ejemplos más detallados, consulta la documentación y ejemplos.

Requisitos de sistema

  • Rust 1.70 o superior
  • Node.js 14.0 o superior (para bindings de JavaScript)
  • Sistema operativo: Linux, macOS, Windows (todos x64/arm64)

Compilar desde código fuente

# Clonar el repositorio
git clone https://github.com/osvalois/hicon.git
cd hicon

# Compilar la biblioteca Rust
cargo build --release

# Compilar los bindings de Node.js
npm install
npm run build

Documentación

Contribuir

Las contribuciones son bienvenidas. Por favor, lee CONTRIBUTING.md para obtener detalles sobre nuestro proceso de envío de pull requests.

Licencia

Este proyecto está licenciado bajo la Licencia MIT - ver el archivo LICENSE para más detalles.