Skip to content

Commit

Permalink
remove nullable goproto option for DeploymentGroups (#149)
Browse files Browse the repository at this point in the history
* remove nullable

* remove assign by index
  • Loading branch information
aastein authored Mar 26, 2018
1 parent e787585 commit eecf4c1
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 90 deletions.
8 changes: 3 additions & 5 deletions app/deployment/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func (a *app) doDeliverCreateTx(ctx apptypes.Context, tx *types.TxCreateDeployme
for _, group := range groups {
group.Deployment = deployment.Address
group.Seq = seq.Advance()
a.State().DeploymentGroup().Save(&group)
a.State().DeploymentGroup().Save(group)
}

if err := a.State().Deployment().Save(deployment); err != nil {
Expand Down Expand Up @@ -440,11 +440,10 @@ func (a *app) doDeliverCloseTx(ctx apptypes.Context, tx *types.TxCloseDeployment

deployment.State = types.Deployment_CLOSING

for i, group := range groups {
for _, group := range groups {
// begin for each group
if group.State != types.DeploymentGroup_CLOSING {
group.State = types.DeploymentGroup_CLOSING
groups[i] = group
}

orders, err := a.State().Order().ForGroup(group)
Expand Down Expand Up @@ -575,11 +574,10 @@ func (a *app) doDeliverClosedTx(ctx apptypes.Context, tx *types.TxDeploymentClos
}
}

for i, group := range groups {
for _, group := range groups {
// begin for each group
if group.State != types.DeploymentGroup_CLOSED {
group.State = types.DeploymentGroup_CLOSED
groups[i] = group
}

orders, err := a.State().Order().ForGroup(group)
Expand Down
2 changes: 1 addition & 1 deletion app/market/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestEngine_Orders(t *testing.T) {
require.NoError(t, state_.Deployment().Save(deployment))

for idx := range groups.GetItems() {
require.NoError(t, state_.DeploymentGroup().Save(&groups.GetItems()[idx]))
require.NoError(t, state_.DeploymentGroup().Save(groups.GetItems()[idx]))
}

txs, err := market.NewEngine(testutil.Logger()).Run(state_)
Expand Down
2 changes: 1 addition & 1 deletion app/order/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestTx(t *testing.T) {
orderSeq := uint64(0)
testutil.CreateOrder(t, app, account, &key, deployment.Address, groups.GetItems()[0].Seq, orderSeq)

orders, err := state_.Order().ForGroup(&groups.GetItems()[0])
orders, err := state_.Order().ForGroup(groups.GetItems()[0])
require.NoError(t, err)
require.Len(t, orders, 1)

Expand Down
2 changes: 1 addition & 1 deletion testutil/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func DeploymentGroups(deployment base.Bytes, nonce uint64) *types.DeploymentGrou
OrderTTL: orderTTL,
}

groups := []types.DeploymentGroup{*group}
groups := []*types.DeploymentGroup{group}

return &types.DeploymentGroups{Items: groups}
}
158 changes: 77 additions & 81 deletions types/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ message DeploymentGroup {
}

message DeploymentGroups {
repeated DeploymentGroup items = 1 [(gogoproto.nullable) = false];
repeated DeploymentGroup items = 1;
}

message Deployment {
Expand Down

0 comments on commit eecf4c1

Please sign in to comment.