Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #71 from irisnet/develop
Browse files Browse the repository at this point in the history
R4R: merge master from develop branch
  • Loading branch information
kaifei Hu authored Feb 22, 2021
2 parents 0d9c0a0 + cd19867 commit 3dc7740
Show file tree
Hide file tree
Showing 36 changed files with 1,385 additions and 1,974 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.13.1-alpine3.10 as builder
FROM golang:1.15.5-alpine3.12 as builder

# Set up dependencies
ENV PACKAGES go make git libc-dev bash
Expand All @@ -16,7 +16,7 @@ WORKDIR $REPO_PATH
RUN apk add --no-cache $PACKAGES && \
cd $REPO_PATH && make all

FROM alpine:3.10
FROM alpine:3.12

ENV BINARY_NAME rainbow-sync-iris
COPY --from=builder /go/src/$BINARY_NAME /usr/local/bin/$BINARY_NAME
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ A daemon that synchronizes IRIS hub data for the Rainbow wallet backend
- `model`: mongodb script to create database
- `task`: main logic of sync-server, sync data from blockChain and write to database
- `db`: database model
- `helper`: helper functions
- `msgs`: tx msgs model
- `lib`: cdc and client pool functions
- `utils`: common functions
- `main.go`: bootstrap project

Expand All @@ -35,8 +36,7 @@ docker build -t rainbow-sync .
docker run --name rainbow-sync \&
-v /mnt/data/rainbow-sync/logs:/root/go/src/github.com/irisnet/rainbow-sync/logs \&
-e "DB_ADDR=127.0.0.1:27217" -e "DB_USER=user" \&
-e "DB_PASSWD=password" -e "DB_DATABASE=db_name" \&
-e "IRIS_NETWORK=testnet" \&
-e "DB_PASSWD=password" -e "DB_DATABASE=db_name" \&
-e "SER_BC_FULL_NODES=tcp://localhost:26657,..." rainbow-sync
```

Expand All @@ -49,14 +49,14 @@ docker run --name rainbow-sync \&
| DB_USER | string | "" | db user | user |
| DB_PASSWD | string | "" |db passwd | password |
| DB_DATABASE | string | "" |database name | db_name |
| IRIS_NETWORK | string | "testnet" |irishub name | testnet or mainnet |
| SER_BC_FULL_NODES | string | tcp://localhost:26657 | iris full node rpc url | tcp://localhost:26657, tcp://127.0.0.2:26657 |
| WORKER_NUM_EXECUTE_TASK | string | 30 | number of threads executing synchronization TX task | 30 |
| WORKER_MAX_SLEEP_TIME | string | 120 | the maximum time (in seconds) that synchronization TX threads are allowed to be out of work | 120 |
| BLOCK_NUM_PER_WORKER_HANDLE | string | 50 | number of blocks per sync TX task | 50 |
| BEHIND_BLOCK_NUM | string | 0 | wait block num to handle tx | 0 |

- Remarks
- synchronizes irishub data from specify block height(such as:17908 current time:1576208532)
- synchronizes block chain data from specify block height(such as:17908 current time:1576208532)

At first,stop the rainbow-sync and create the task. Run:
```bash
Expand Down
44 changes: 44 additions & 0 deletions block/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package block

import (
"github.com/irisnet/rainbow-sync/conf"
"github.com/kaifei-bianjie/msg-parser/codec"
)

var (

// Bech32ChainPrefix defines the prefix of this chain
Bech32ChainPrefix = "i"

// PrefixAcc is the prefix for account
PrefixAcc = "a"

// PrefixValidator is the prefix for validator keys
PrefixValidator = "v"

// PrefixConsensus is the prefix for consensus keys
PrefixConsensus = "c"

// PrefixPublic is the prefix for public
PrefixPublic = "p"

// PrefixAddress is the prefix for address
PrefixAddress = "a"

// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
Bech32PrefixAccAddr = conf.SvrConf.Bech32ChainPrefix + PrefixAcc + PrefixAddress
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
Bech32PrefixAccPub = conf.SvrConf.Bech32ChainPrefix + PrefixAcc + PrefixPublic
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
Bech32PrefixValAddr = conf.SvrConf.Bech32ChainPrefix + PrefixValidator + PrefixAddress
// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
Bech32PrefixValPub = conf.SvrConf.Bech32ChainPrefix + PrefixValidator + PrefixPublic
// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
Bech32PrefixConsAddr = conf.SvrConf.Bech32ChainPrefix + PrefixConsensus + PrefixAddress
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
Bech32PrefixConsPub = conf.SvrConf.Bech32ChainPrefix + PrefixConsensus + PrefixPublic
)

func init() {
codec.SetBech32Prefix(Bech32PrefixAccAddr, Bech32PrefixAccPub, Bech32PrefixValAddr, Bech32PrefixValPub, Bech32PrefixConsAddr, Bech32PrefixConsPub)
}
67 changes: 67 additions & 0 deletions block/handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package block

import (
"github.com/irisnet/rainbow-sync/lib/msgparser"
. "github.com/kaifei-bianjie/msg-parser/modules"
"github.com/kaifei-bianjie/msg-parser/types"
)

func HandleTxMsg(v types.SdkMsg) MsgDocInfo {
if BankDocInfo, ok := msgparser.MsgClient.Bank.HandleTxMsg(v); ok {
return BankDocInfo
}
if IServiceDocInfo, ok := msgparser.MsgClient.Service.HandleTxMsg(v); ok {
return IServiceDocInfo
}
if NftDocInfo, ok := msgparser.MsgClient.Nft.HandleTxMsg(v); ok {
return NftDocInfo
}
if RecordDocInfo, ok := msgparser.MsgClient.Record.HandleTxMsg(v); ok {
return RecordDocInfo
}
if TokenDocInfo, ok := msgparser.MsgClient.Token.HandleTxMsg(v); ok {
return TokenDocInfo
}
if CoinswapDocInfo, ok := msgparser.MsgClient.Coinswap.HandleTxMsg(v); ok {
return CoinswapDocInfo
}
if CrisisDocInfo, ok := msgparser.MsgClient.Crisis.HandleTxMsg(v); ok {
return CrisisDocInfo
}
if DistrubutionDocInfo, ok := msgparser.MsgClient.Distribution.HandleTxMsg(v); ok {
return DistrubutionDocInfo
}
if SlashingDocInfo, ok := msgparser.MsgClient.Slashing.HandleTxMsg(v); ok {
return SlashingDocInfo
}
if EvidenceDocInfo, ok := msgparser.MsgClient.Evidence.HandleTxMsg(v); ok {
return EvidenceDocInfo
}
if HtlcDocInfo, ok := msgparser.MsgClient.Htlc.HandleTxMsg(v); ok {
return HtlcDocInfo
}
if StakingDocInfo, ok := msgparser.MsgClient.Staking.HandleTxMsg(v); ok {
return StakingDocInfo
}
if GovDocInfo, ok := msgparser.MsgClient.Gov.HandleTxMsg(v); ok {
return GovDocInfo
}
if IbcDocInfo, ok := msgparser.MsgClient.Ibc.HandleTxMsg(v); ok {
return IbcDocInfo
}
return MsgDocInfo{}
}

func removeDuplicatesFromSlice(data []string) (result []string) {
tempSet := make(map[string]string, len(data))
for _, val := range data {
if _, ok := tempSet[val]; ok || val == "" {
continue
}
tempSet[val] = val
}
for one := range tempSet {
result = append(result, one)
}
return
}
222 changes: 0 additions & 222 deletions block/parse_asset_detail.go

This file was deleted.

Loading

0 comments on commit 3dc7740

Please sign in to comment.