Skip to content

Commit

Permalink
Parallelize chain synchronization in startup
Browse files Browse the repository at this point in the history
  • Loading branch information
leventeliu committed May 13, 2019
1 parent 6af1b83 commit 2cf42e0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sqlchain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ func (c *Chain) processBlocks(ctx context.Context) {
}

// Start starts the main process of the sql-chain.
func (c *Chain) Start() (err error) {
func (c *Chain) Start() {
c.rt.goFunc(c.processBlocks)
c.sync()
c.rt.goFunc(c.mainCycle)
Expand Down
5 changes: 1 addition & 4 deletions sqlchain/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,7 @@ func TestMultiChain(t *testing.T) {

// Start all chain instances
for _, v := range chains {
if err = v.chain.Start(); err != nil {
t.Fatalf("error occurred: %v", err)
}

v.chain.Start()
defer func(c *Chain) {
// Stop chain main process before exit
_ = c.Stop()
Expand Down
3 changes: 1 addition & 2 deletions worker/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,8 @@ func NewDatabase(cfg *DBConfig, peers *proto.Peers,
}
if db.chain, err = sqlchain.NewChain(chainCfg); err != nil {
return
} else if err = db.chain.Start(); err != nil {
return
}
go db.chain.Start()

// init kayak config
kayakWalPath := filepath.Join(cfg.DataDir, KayakWalFileName)
Expand Down

0 comments on commit 2cf42e0

Please sign in to comment.