Angine is a completely self-contained blockchain consensus engine. At the core, we use Tendermint BFT, which is an implementation of a Byzantine Fault Tolerant PoS consensus algorithm. So thank you Tendermint team. We just wrapped those many things that Tendermint already offered together under a new concept, "Angine".
├── blockchain
│ ├── pool.go
│ ├── pool_test.go
│ ├── reactor.go
│ └── store.go
├── config
│ ├── config.go
│ └── templates.go
├── consensus
│ ├── byzantine_test.go
│ ├── common.go
│ ├── common_test.go
│ ├── height_vote_set.go
│ ├── height_vote_set_test.go
│ ├── mempool_test.go
│ ├── reactor.go
│ ├── reactor_test.go
│ ├── README.md
│ ├── replay.go
│ ├── replay_test.go
│ ├── state.go
│ ├── state_test.go
│ ├── test_data
│ │ ├── build.sh
│ │ ├── empty_block.cswal
│ │ ├── README.md
│ │ ├── small_block1.cswal
│ │ └── small_block2.cswal
│ ├── ticker.go
│ ├── version.go
│ └── wal.go
├── angine.go
├── log.go
├── mempool
│ ├── mempool.go
│ ├── mempool_test.go
│ └── reactor.go
├── plugin
│ ├── init.go
│ └── specialop.go
├── README.org
├── refuse_list
│ ├── refuse_list.go
│ └── refuse_list_test.go
├── specialop.go
├── state
│ ├── errors.go
│ ├── execution.go
│ ├── execution_test.go
│ ├── plugin.go
│ ├── state.go
│ └── state_test.go
└── types
├── application.go
├── block.go
├── block_meta.go
├── canonical_json.go
├── common.go
├── events.go
├── genesis.go
├── hooks.go
├── keys.go
├── mempool.go
├── part_set.go
├── part_set_test.go
├── priv_validator.go
├── proposal.go
├── proposal_test.go
├── resultcode.go
├── result.go
├── rpc.go
├── signable.go
├── specialOP.go
├── tx.go
├── validator.go
├── validator_set.go
├── validator_set_test.go
├── vote.go
├── vote_set.go
├── vote_set_test.go
└── vote_test.go
From the directory structure of Angine above, you can see that we have packed every module under its own directory. This gives you a clear view of the parts that make up an Angine.
-
state/ is the running state of the Angine, which is driven by blockchain/, mempool/ and consensus/
-
blockchain/ takes charge of syncing blocks, loading blocks, persisting blocks and anything that is physically related to "block"
-
mempool/ takes charge of buffering effective transactions and reaching an agreement about the order of transactions
-
consensus/ takes charge of gossipping between peers, and consensus algorithms on data stream
-
CA based on asymmetric cyrpto
-
Dynamically changing ValidatorSet of ConsensusState
-
Two kinds of transactions, namely normal and special, are totally isolated. Special tx will only be processed by plugins by default
-
Angine plugins
-
Newly joined nodes will automatically download genesisfiles from the first seed listed in config file
This is how you initialize an angine.
angine.Initialize(&angine.Tunes{Conf: conf})
The "angine.Initialize" will handle the generation of default configs, genesis file and private key. You should never perform this more than once for a particular chain, otherwise your chain id will be different for sure.
type Tunes struct {
Runtime string
Conf *cfg.MapConfig
}
This struct contains 2 fields and you only have to fill one:
-
Runtime is a path that contains all the auto-generated files. So providing this will just generate everything under this path with a random chainID and a private/pub key pair.
-
Conf contains any configs that you wish to override the defaults. For instance, if you want to use some cli args to override the default configs, this is where you should look into.
And then, you will probably need to edit those files mannually to get exactly what you want. Everything in the files are pretty straightforward.
As the first step, you will need to import angine into your project. :-)
// this line should be changed to github path accordingly
import "github.com/annchain/angine"
...
mainAngine := angine.NewAngine(&angine.Tunes{Conf: conf})
...
mainAngine.Start()
That is all. Have fun!