Skip to content

Initialize Blockchain Object #1308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: experimental
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,25 @@ jobs:
paths:
- ./dist
- run:
name: ADD HOSTS
command: |
ssh-keyscan $ln4 >> ~/.ssh/known_hosts
name: ADD HOSTS
command: |
for host in $x1 $x2 $x3; do ssh-keyscan $host >> ~/.ssh/known_hosts; done
# for host in $ln1 $ln2 $ln3; do ssh-keyscan $host >> ~/.ssh/known_hosts; done
- run:
name: DOWN SERVICES
command: |
ssh root@$ln4 'sudo systemctl stop zoobc.service'
name: DOWN SERVICES
command: |
for host in $x1 $x2 $x3; do ssh root@$host 'sudo systemctl stop zoobc.service'; done
# for host in $ln1 $ln2 $ln3; do ssh root@$host 'sudo systemctl stop zoobc.service'; done
- run: *reset_dbs
- run:
name: DEPLOY
command: |
rsync -vae ssh ./dist/ root@$ln4:/root/zoobc --exclude='*.db' --exclude='generated'
name: DEPLOY
command: |
for host in $x1 $x2 $x3; do rsync -vae ssh ./dist/ root@$host:/root/zoobc --exclude='*.db' --exclude='generated'; done
# for host in $ln1 $ln2 $ln3; do rsync -vae ssh ./dist/ root@$host:/root/zoobc --exclude='*.db' --exclude='generated'; done
- run:
name: UP SERVICES
command: |
ssh root@$ln4 'sudo systemctl start zoobc.service'
name: UP SERVICES
command: |
for host in $x1 $x2 $x3; do ssh root@$host 'sudo systemctl start zoobc.service'; done
# for host in $ln1 $ln2 $ln3; do ssh root@$host 'sudo systemctl start zoobc.service'; done
deploy-staging:
<<: *defaults
Expand Down
28 changes: 12 additions & 16 deletions api/client/PostTransaction/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package main

import (
"context"
"flag"
"fmt"
"os"
"strings"

log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
Expand All @@ -17,23 +16,20 @@ import (
func main() {

var (
apiRPCPort int
configPath = "./resource"
ip string
conn *grpc.ClientConn
err error
)
dir, _ := os.Getwd()
if strings.Contains(dir, "api") {
configPath = "../../../resource"
}
if err := util.LoadConfig(configPath, "config", "toml", ""); err != nil {
log.Fatal(err)
} else {
apiRPCPort = viper.GetInt("apiRPCPort")
if apiRPCPort == 0 {
apiRPCPort = 8080
flag.StringVar(&ip, "ip", "", "Usage")
flag.Parse()
if len(ip) < 1 {
if err := util.LoadConfig("../../../", "config", "toml", ""); err != nil {
log.Fatal(err)
} else {
ip = fmt.Sprintf(":%d", viper.GetInt("apiRPCPort"))
}
}

conn, err := grpc.Dial(fmt.Sprintf(":%d", apiRPCPort), grpc.WithInsecure())
conn, err = grpc.Dial(ip, grpc.WithInsecure())
if err != nil {
log.Fatalf("did not connect: %s", err)
}
Expand Down
16 changes: 13 additions & 3 deletions cmd/block/blockGenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package block

import (
"fmt"
"strings"
"time"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand All @@ -23,6 +21,8 @@ import (
"github.com/zoobc/zoobc-core/core/smith/strategy"
coreUtil "github.com/zoobc/zoobc-core/core/util"
"github.com/zoobc/zoobc-core/observer"
"strings"
"time"
)

type (
Expand All @@ -37,6 +37,7 @@ var (
blockProcessor smith.BlockchainProcessorInterface
blockService service.BlockServiceInterface
nodeRegistrationService service.NodeRegistrationServiceInterface
blockSmithStrategy strategy.BlocksmithStrategyInterface
blocksmithStrategy strategy.BlocksmithStrategyInterface
queryExecutor query.ExecutorInterface
migration database.Migration
Expand Down Expand Up @@ -192,7 +193,15 @@ func initialize(
)

blocksmithStrategy = strategy.NewBlocksmithStrategyMain(
queryExecutor, query.NewNodeRegistrationQuery(), query.NewSkippedBlocksmithQuery(), activeNodeRegistryCacheStorage, log.New(),
log.New(),
nil,
activeNodeRegistryCacheStorage,
query.NewSkippedBlocksmithQuery(),
query.NewBlockQuery(&chaintype.MainChain{}),
nil,
queryExecutor,
crypto.NewRandomNumberGenerator(),
nil,
)
publishedReceiptUtil := coreUtil.NewPublishedReceiptUtil(
query.NewPublishedReceiptQuery(),
Expand Down Expand Up @@ -254,6 +263,7 @@ func generateBlocks(numberOfBlocks int, blocksmithSecretPhrase, outputPath strin
log.New(),
&mockBlockchainStatusService{},
nodeRegistrationService,
blockSmithStrategy,
)
startTime := time.Now().UnixNano() / 1e6
fmt.Printf("generating %d blocks\n", numberOfBlocks)
Expand Down
9 changes: 6 additions & 3 deletions cmd/snapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@ package snapshot
import (
"crypto/sha256"
"database/sql"
"github.com/zoobc/zoobc-core/common/crypto"
"math/rand"
"os"

"github.com/zoobc/zoobc-core/common/util"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/ugorji/go/codec"
"github.com/zoobc/zoobc-core/common/auth"
"github.com/zoobc/zoobc-core/common/chaintype"
"github.com/zoobc/zoobc-core/common/constant"
"github.com/zoobc/zoobc-core/common/crypto"
"github.com/zoobc/zoobc-core/common/database"
"github.com/zoobc/zoobc-core/common/model"
"github.com/zoobc/zoobc-core/common/query"
"github.com/zoobc/zoobc-core/common/storage"
"github.com/zoobc/zoobc-core/common/transaction"
"github.com/zoobc/zoobc-core/common/util"
"github.com/zoobc/zoobc-core/core/service"
"golang.org/x/crypto/sha3"
)
Expand Down Expand Up @@ -104,6 +103,8 @@ func newSnapshotProcess() func(ccmd *cobra.Command, args []string) {
query.NewLiquidPaymentTransactionQuery(),
query.NewNodeAdmissionTimestampQuery(),
query.NewBlockQuery(mainChain),
query.NewBlockchainObjectQuery(),
query.NewBlockchainObjectPropertyQuery(),
query.GetSnapshotQuery(mainChain),
query.GetBlocksmithSafeQuery(mainChain),
query.GetDerivedQuery(mainChain),
Expand Down Expand Up @@ -339,6 +340,8 @@ func storingPayloadProcess() func(ccmd *cobra.Command, args []string) {
query.NewLiquidPaymentTransactionQuery(),
query.NewNodeAdmissionTimestampQuery(),
query.NewBlockQuery(mainChain),
query.NewBlockchainObjectQuery(),
query.NewBlockchainObjectPropertyQuery(),
query.GetSnapshotQuery(mainChain),
query.GetBlocksmithSafeQuery(mainChain),
query.GetDerivedQuery(mainChain),
Expand Down
Loading