Skip to content

Commit

Permalink
Merge pull request #39 from bnb-chain/develop
Browse files Browse the repository at this point in the history
release: Prepare for release v0.0.7
  • Loading branch information
alexgao001 authored Apr 7, 2023
2 parents 8e7adbb + 4fd89d0 commit 0a138b9
Show file tree
Hide file tree
Showing 30 changed files with 1,104 additions and 570 deletions.
661 changes: 661 additions & 0 deletions COPYING

Large diffs are not rendered by default.

165 changes: 0 additions & 165 deletions COPYING.LESSER

This file was deleted.

20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Go version above 1.19
"key_type": "local_private_key",
"aws_region": "",
"aws_secret_name": "",
"aws_bls_secret_name": "",
"rpc_addrs": [
"http://127.0.0.1:26750",
"http://127.0.0.1:26751",
Expand All @@ -50,10 +51,12 @@ Go version above 1.19
],
"private_key": "your_private_key",
"bls_private_key": "your_private_key",
"chain_id": 1, // greenfield oracle module defines this
"chain_id": 18, // greenfield oracle module defines this
"start_height": 1,
"number_of_blocks_for_finality": 0,
"monitor_channel_list": [1,2,3],
"gas_limit": 210000,
"gas_limit": 30000,
"fee_amount": 150000000000000,
"chain_id_string": "greenfield_9000-121"
},
"bsc_config": {
Expand Down Expand Up @@ -103,7 +106,14 @@ Go version above 1.19
```
"db_config": {
"dialect": "mysql",
"db_path": "root:pass@tcp(127.0.0.1:3306)/greenfield-relayer?charset=utf8&parseTime=True&loc=Local"
"key_type": "local_private_key",
"aws_region": "",
"aws_secret_name": "",
"password": "pass",
"username": "root",
"url": "/local-greenfield-relayer1?charset=utf8&parseTime=True&loc=Local",
"max_idle_conns": 10,
"max_open_conns": 100
}
```

Expand Down Expand Up @@ -196,5 +206,5 @@ Please make sure your contributions adhere to our coding guidelines:

## License
The repo is licensed under the
[GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html),
also included in our repository in the `COPYING.LESSER` file.
[GNU Affero General Public License v3.0](https://www.gnu.org/licenses/agpl-3.0.en.html), also
included in our repository in the `COPYING` file.
32 changes: 27 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ package app
import (
"encoding/json"
"fmt"
"log"
"os"
"time"

"github.com/spf13/viper"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"

"github.com/bnb-chain/greenfield-relayer/assembler"
"github.com/bnb-chain/greenfield-relayer/config"
Expand Down Expand Up @@ -35,20 +39,38 @@ func NewApp(cfg *config.Config) *App {
url := cfg.DBConfig.Url
dbPath := fmt.Sprintf("%s:%s@%s", username, password, url)

db, err := gorm.Open(mysql.Open(dbPath), &gorm.Config{})
newLogger := logger.New(
log.New(os.Stdout, "\r\n", log.LstdFlags), // io writer
logger.Config{
SlowThreshold: time.Second, // Slow SQL threshold
LogLevel: logger.Silent, // Log level
IgnoreRecordNotFoundError: true, // Ignore ErrRecordNotFound error for logger
Colorful: true, // Disable color
},
)

db, err := gorm.Open(mysql.Open(dbPath), &gorm.Config{
Logger: newLogger,
})
if err != nil {
panic(fmt.Sprintf("open db error, err=%s", err.Error()))
}
dbConfig, err := db.DB()
if err != nil {
panic(err)
}

dbConfig.SetMaxIdleConns(cfg.DBConfig.MaxIdleConns)
dbConfig.SetMaxOpenConns(cfg.DBConfig.MaxOpenConns)

model.InitBSCTables(db)
model.InitGreenfieldTables(db)
model.InitVoteTables(db)
model.InitSequenceTable(db)

greenfieldDao := dao.NewGreenfieldDao(db)
bscDao := dao.NewBSCDao(db)
voteDao := dao.NewVoteDao(db)
seqDao := dao.NewSequenceDao(db)
daoManager := dao.NewDaoManager(greenfieldDao, bscDao, voteDao, seqDao)
daoManager := dao.NewDaoManager(greenfieldDao, bscDao, voteDao)

greenfieldExecutor := executor.NewGreenfieldExecutor(cfg)
bscExecutor := executor.NewBSCExecutor(cfg)
Expand All @@ -66,7 +88,7 @@ func NewApp(cfg *config.Config) *App {
bscVoteProcessor := vote.NewBSCVoteProcessor(cfg, daoManager, signer, bscExecutor)

// listeners
greenfieldListener := listener.NewGreenfieldListener(cfg, greenfieldExecutor, bscExecutor, greenfieldVoteProcessor, daoManager, metricService)
greenfieldListener := listener.NewGreenfieldListener(cfg, greenfieldExecutor, bscExecutor, daoManager, metricService)
bscListener := listener.NewBSCListener(cfg, bscExecutor, greenfieldExecutor, daoManager, metricService)

// assemblers
Expand Down
Loading

0 comments on commit 0a138b9

Please sign in to comment.