"github.com/blockchain/p2p"
"github.com/blockchain/types"
"github.com/blockchain/protocol/bc/legacy"
+ "github.com/blockchain/protocol"
cmn "github.com/tendermint/tmlibs/common"
)
// state *sm.State
// proxyAppConn proxy.AppConnConsensus // same as consensus.proxyAppConn
// store *MemStore
+ chain *protocol.Chain
store *BlockStore
pool *BlockPool
fastSync bool
evsw types.EventSwitch
}
-func NewBlockchainReactor(store *BlockStore, fastSync bool) *BlockchainReactor {
+func NewBlockchainReactor(store *BlockStore, chain *protocol.Chain,fastSync bool) *BlockchainReactor {
requestsCh := make(chan BlockRequest, defaultChannelCapacity)
timeoutsCh := make(chan string, defaultChannelCapacity)
pool := NewBlockPool(
timeoutsCh,
)
bcR := &BlockchainReactor {
+ chain: chain,
fastSync: fastSync,
pool: pool,
store: store,
//rpc "github.com/blockchain/rpc/lib"
rpcserver "github.com/blockchain/rpc/lib/server"
"github.com/blockchain/blockchain/account"
+ "github.com/blockchain/protocol"
_ "net/http/pprof"
)
sw.SetLogger(p2pLogger)
fastSync := config.FastSync
- bcReactor := bc.NewBlockchainReactor(blockStore, fastSync)
+ genesisblock, err := protocol.NewInitialBlock()
+ if err != nil {
+ cmn.Exit(cmn.Fmt("initialize genesisblock failed: %v", err))
+ }
+
+ txdb := dbm.NewDB("txdb", config.DBBackend, config.DBDir())
+ store := txdb.NewStore(txdb)
+ chain, err := protocol.NewChain(ctx, genesisblock.Hash(), store, nil)
+ if err != nil {
+ cmn.Exit(cmn.Fmt("protocol new chain failed: %v", err)
+ }
+ err = chain.CommitAppliedBlock(ctx, block, state.Empty())
+ if err != nil {
+ cmn.Exit(cmn.Fmt("commit block failed: %v", err))
+ }
+ chain.MaxIssuanceWindow = bc.MillisDuration(c.MaxIssuanceWindowMs)
+
+ bcReactor := bc.NewBlockchainReactor(blockStore, chain, fastSync)
bcReactor.SetLogger(logger.With("module", "blockchain"))
sw.AddReactor("BLOCKCHAIN", bcReactor)