架构

分为五个部分:

  • 区块链(核心部分,其中又以区块、交易为重点)

  • API/客户端/服务端(通过RPC交互)

  • 网络传输(一般就是P2P)

  • 数据存储(运用数据库,保存、管理数据)

  • 数学/密码学

模块间调用

模块之间,可通过创建其关联对象进行互相调用。

API/客户端 - 调用 chain::Chain、p2p::Peers、pool::TransactionPool、pool::BlockChain、store::Store

区块链 - 调用 store::ChainStore(store::Store)、ChainAdapter、PMMRBackend(PMMR)

网络传输 - 调用 grin_store::Store,自调用 ChainAdapter、NetAdapter

交易池 - 调用 BlockChain、PoolAdapter

其它模块之间事件处理 - NetToChainAdapter(p2p::ChainAdapter)、ChainToPoolAndNetAdapter(chain::ChainAdapter)、PoolToNetAdapter(pool::PoolAdapter)、PoolToChainAdapter(pool::BlockChain)

目录结构

After checking out grin, building and using, these are the folders you'll have:

  • api

    Code for ApiEndpoints accessible over REST.

  • chain

    The blockchain implementation. Accepts a block (see pipe.rs) and adds it to the chain, or reject it.

  • config

    Code for handling configuration.

  • core

    All core types: Hash, Block, Input, Output, and how to serialize them. Core mining algorithm, and more.

  • doc

    All documentation.

  • servers

    Many parts (adapters, lib, miner, seed, server, sync, types) that the grin server needs, including mining server.

  • keychain

    Code for working safely with keys and doing blinding.

  • p2p

    All peer to peer connection and protocol-related logic (handshake, block propagation, etc.).

  • pool

    Code for the transaction pool implementation.

  • server

    A folder you're supposed to create , before starting your server: cd to project root; mkdir server; cd server; grin server start (or run) and it will create a subfolder .grin

    • .grin
      • chain
        • a database with the blockchain blocks and related information
      • peers
        • a database with the list of Grin peers you're connected to
      • txhashset
        • contains folders kernel, rangeproof and output that each have a pmmr_dat.bin
  • src

    Code for the grin binary.

  • store

    Data store - Grin uses near-zero-cost Rust wrapper around LMDB, key-value embedded data store.

  • target

    Where the grin binary ends up, after the compile and build process finishes. In case of trouble, see troubleshooting

  • util

    Low-level rust utilities.

  • wallet

    Simple command line wallet implementation. Will generate:

    • wallet_data
      • a database storing your "outputs", that once confirmed and matured, can be spent with thegrin wallet sendcommand. (locally created, _not _in git)
    • wallet.seed
      • your secret wallet seed. (locally created, _not _in git)

results matching ""

    No results matching ""