Skip to content

Add chain validation and consensus mechanism #2

@devduart

Description

@devduart

Summary

Implement functionality to verify blockchain integrity and allow choosing the longest valid chain in multi-node environments.

Tasks

  • Create IsValid(chain Blockchain) bool to verify:
    • All blocks are correctly linked (PrevHash == previous.Hash)
    • All hashes are valid given the difficulty
  • Implement a method to compare two chains and pick the longest valid one
  • Optionally log validation errors for debugging

Notes

This will be used during peer-to-peer sync to determine which chain is canonical.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions