Skip to content

Coding Style

JinGyeong Jeong edited this page Nov 21, 2019 · 11 revisions

Imports order

Group imports into 3 groups:

  • System
  • Other Package
  • Self Package
use std::collections::HashSet;

use codechain_types::{Address, H256};
use crypto::BLAKE_NULL_RLP;
use rlp::{UntrustedRlp, RlpStream, Encodable, Decodable, DecoderError};
use triehash::ordered_trie_root;

use super::Bytes;
use super::codechain_machine::CodeChainMachine;
use super::engine::ConsensusEngine;
use super::error::Error;
use super::header::{Header, Seal};
use super::machine::{LiveBlock, Transactions};
use super::transaction::{UnverifiedTransaction, SignedTransaction, TransactionError};

Rename codechain packages

Reduce codechain_ prefix in package name to c.

extern crate codechain_crypto as ccrypto;
extern crate codechain_io as cio;
extern crate codechain_types as ctypes;

Add unique prefix to common names when exporting symbols

For example, kademlia module exports Config and Extension as KademliaConfig and KademliaExtension respectively to avoid confusion.

pub use self::config::Config as KademliaConfig;
pub use self::extension::Extension as KademliaExtension;