Skip to content

Commit

Permalink
Merge pull request #408 from klim0v/v1.2
Browse files Browse the repository at this point in the history
CHANGELOG.md + refactor
  • Loading branch information
danil-lashin authored Sep 27, 2020
2 parents bd1ac79 + 2d3184c commit 260ce96
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 23 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
- [core] Added RecreateCoin tx
- [core] Added ChangeCoinOwner tx
- [core] Limit validators slots to 64
- [core] Add EditMultisigOwnersData tx
- [core] Add EditMultisigData tx
- [core] Add PriceVoteData tx
- [core] Stake value calculation changes
- [console] Added PruneBlocks command
- [api] Marked as deprecated version of API v1
- [api] Added Swagger UI for API v2

## 1.1.8

Expand Down
6 changes: 3 additions & 3 deletions api/v2/service/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ func (s *Service) Address(ctx context.Context, req *pb.AddressRequest) (*pb.Addr
return new(pb.AddressResponse), status.Error(codes.NotFound, err.Error())
}

cState.RLock()
defer cState.RUnlock()

if req.Height != 0 && req.Delegated {
cState.Lock()
cState.Candidates().LoadCandidates()
cState.Candidates().LoadStakes()
cState.Unlock()
}

cState.RLock()
defer cState.RUnlock()

balances := cState.Accounts().GetBalances(address)
var res pb.AddressResponse

Expand Down
6 changes: 3 additions & 3 deletions api/v2/service/addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ func (s *Service) Addresses(ctx context.Context, req *pb.AddressesRequest) (*pb.
return new(pb.AddressesResponse), status.Error(codes.NotFound, err.Error())
}

cState.RLock()
defer cState.RUnlock()

if req.Height != 0 && req.Delegated {
cState.Lock()
cState.Candidates().LoadCandidates()
cState.Candidates().LoadStakes()
cState.Unlock()
}

cState.RLock()
defer cState.RUnlock()

response := &pb.AddressesResponse{
Addresses: make(map[string]*pb.AddressesResponse_Result, len(req.Addresses)),
}
Expand Down
1 change: 1 addition & 0 deletions api/v2/service/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func (s *Service) Status(context.Context, *empty.Empty) (*pb.StatusResponse, err

return &pb.StatusResponse{
Version: s.version,
Network: result.NodeInfo.Network,
LatestBlockHash: fmt.Sprintf("%X", result.SyncInfo.LatestBlockHash),
LatestAppHash: fmt.Sprintf("%X", result.SyncInfo.LatestAppHash),
LatestBlockHeight: uint64(result.SyncInfo.LatestBlockHeight),
Expand Down
6 changes: 6 additions & 0 deletions api/v2/service/waitlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ func (s *Service) WaitList(ctx context.Context, req *pb.WaitListRequest) (*pb.Wa
return new(pb.WaitListResponse), status.Error(codes.NotFound, err.Error())
}

if req.Height != 0 {
cState.Lock()
cState.Candidates().LoadCandidates()
cState.Unlock()
}

cState.RLock()
defer cState.RUnlock()

Expand Down
8 changes: 4 additions & 4 deletions core/minter/minter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func initTestNode(t *testing.T) (*Blockchain, *rpc.Local, *privval.FilePV) {
utils.MinterHome = t.TempDir()

if err := tmos.EnsureDir(utils.GetMinterHome()+"/tmdata/blockstore.db", 0777); err != nil {
panic(err.Error())
t.Fatal(err)
}

minterCfg := config.GetConfig()
Expand All @@ -175,7 +175,7 @@ func initTestNode(t *testing.T) (*Blockchain, *rpc.Local, *privval.FilePV) {
app := NewMinterBlockchain(minterCfg)
nodeKey, err := p2p.LoadOrGenNodeKey(cfg.NodeKeyFile())
if err != nil {
panic(err)
t.Fatal(err)
}

node, err := tmNode.NewNode(
Expand All @@ -190,11 +190,11 @@ func initTestNode(t *testing.T) (*Blockchain, *rpc.Local, *privval.FilePV) {
)

if err != nil {
panic(fmt.Sprintf("Failed to create a node: %v", err))
t.Fatal(fmt.Sprintf("Failed to create a node: %v", err))
}

if err = node.Start(); err != nil {
panic(fmt.Sprintf("Failed to start node: %v", err))
t.Fatal(fmt.Sprintf("Failed to start node: %v", err))
}

logger.Info("Started node", "nodeInfo", node.Switch().NodeInfo())
Expand Down
14 changes: 5 additions & 9 deletions core/state/waitlist/waitlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (wl *WaitList) Get(address types.Address, pubkey types.Pubkey, coin types.C

candidate := wl.bus.Candidates().GetCandidate(pubkey)
if candidate == nil {
log.Panicf("Candidate not found: %s", pubkey.String())
return nil
}

for _, item := range waitlist.List {
Expand All @@ -123,20 +123,16 @@ func (wl *WaitList) GetByAddressAndPubKey(address types.Address, pubkey types.Pu

candidate := wl.bus.Candidates().GetCandidate(pubkey)
if candidate == nil {
log.Panicf("Candidate not found: %s", pubkey.String())
return nil
}

items := make([]Item, len(waitlist.List))
for i, item := range waitlist.List {
var items []Item
for _, item := range waitlist.List {
if item.CandidateId == candidate.ID {
items[i] = item
items = append(items, item)
}
}

if len(items) == 0 {
return nil
}

return items
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/MinterTeam/minter-go-node
go 1.15

require (
github.com/MinterTeam/node-grpc-gateway v1.1.3-0.20200925002945-15b5cde8e354
github.com/MinterTeam/node-grpc-gateway v1.1.3-0.20200927171657-f776ba10feca
github.com/btcsuite/btcd v0.20.1-beta
github.com/c-bata/go-prompt v0.2.3
github.com/go-kit/kit v0.10.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg=
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/MinterTeam/node-grpc-gateway v1.1.3-0.20200925002945-15b5cde8e354 h1:HpjApkir3UtOL4WzGzkgQcdT9SyqwiZ/wbGrahzIlLQ=
github.com/MinterTeam/node-grpc-gateway v1.1.3-0.20200925002945-15b5cde8e354/go.mod h1:LZ+Y8IYfSBx0IQZY+a9pHLjztMwmlaCQX2ncTejoE2o=
github.com/MinterTeam/node-grpc-gateway v1.1.3-0.20200927171657-f776ba10feca h1:dnzof1I43yr3aI+TX+cNxnveDKmtoqt1RHNGR3JfsOM=
github.com/MinterTeam/node-grpc-gateway v1.1.3-0.20200927171657-f776ba10feca/go.mod h1:LZ+Y8IYfSBx0IQZY+a9pHLjztMwmlaCQX2ncTejoE2o=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
Expand Down

0 comments on commit 260ce96

Please sign in to comment.