World Conquest Chronicles

World Conquest Chronicles

go-blockchain, v1.4.1

The library that implements models and algorithms of blockchain.

Extracted the Proof-of-Work implementation into a separate library github.com/thewizardplusplus/go-pow, enabling cancellable block generation, error handling and enhanced configuration options.

Change Log

The format is based on Keep a Changelog.

Added

  • Extended PoW interface and functionality:
    • Extended the Proofer interface to accommodate cancellable implementations with error handling.
    • The ProofOfWork implementation now supports:
      • Limiting the number of hash attempts during mining.
      • Choosing a random starting nonce from a specified range.
    • Added the ProofOfWork.HashEx() method — a cancellable version of Hash() that also returns an error.
    • Updated the ProofOfWork.Validate() method to support extended validation logic.
  • New functions and methods for block and blockchain creation — all of which:
    • Accept a context.Context for cancellation.
    • Return an error alongside the result.
    • New functions and methods list:
      • NewBlockEx()
      • NewGenesisBlockEx()
      • NewBlockchainEx()
      • Blockchain.AddBlockEx()

Changed

  • Integration with the new PoW library:
    • Functions NewBlock(), NewGenesisBlock(), NewBlockchain() and methods Blockchain.AddBlock(), ProofOfWork.Hash() now delegate to their *Ex() counterparts, which support cancellation and error handling.
  • Code improvements:
    • Refactored the parseHash() function for improved readability and robustness.
    • Introduced buildChallenge() helper function to centralize PoW challenge construction.
    • Updated mocks to support the enhanced Proofer interface and the lastest version of the mockery tool.

Deprecated

  • The legacy methods NewBlock(), NewGenesisBlock(), NewBlockchain(), Blockchain.AddBlock(), and ProofOfWork.Hash() remain available for backward compatibility but lack cancellation support and proper error handling. Use the corresponding *Ex() methods instead.

Removed

  • Nothing removed — backward compatibility is fully preserved in this release.

Fixed

  • Fixed the documentation example for the Blockchain.Merge() method.

CI / Internal

  • Migrated to go.mod for dependency management.
  • Replaced github.com/pkg/errors with the Go standard library’s errors package.
  • Switched to golangci-lint for static analysis.
  • Set up GitHub Actions for linting and testing.

Installation

$ go get github.com/thewizardplusplus/go-blockchain

Repository

Link: https://github.com/thewizardplusplus/go-blockchain/tree/v1.4.1.

Content: code.

License: MIT.