Skip to content

Commit 2460733

Browse files
authored
don't delete gws in grace period (#112)
Signed-off-by: Ashraf Fouda <ashraf.m.fouda@gmail.com>
1 parent 94372e9 commit 2460733

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pkg/gateway/gateway.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const (
4646
var (
4747
ErrTwinIDMismatch = fmt.Errorf("twin id mismatch")
4848
ErrContractNotReserved = fmt.Errorf("a name contract with the given name must be reserved first")
49-
ErrInvalidContractState = fmt.Errorf("the name contract must be in Created state")
49+
ErrInvalidContractState = fmt.Errorf("the name contract must be in Created or GracePeriod state")
5050

5151
_ pkg.Gateway = (*gatewayModule)(nil)
5252
)
@@ -545,7 +545,7 @@ func (g *gatewayModule) validateNameContract(name string, twinID uint32) error {
545545
} else if subErr.IsError() {
546546
return subErr.Err
547547
}
548-
if !contract.State.IsCreated {
548+
if !contract.State.IsCreated && !contract.State.IsGracePeriod {
549549
return ErrInvalidContractState
550550
}
551551
if uint32(contract.TwinID) != twinID {

pkg/gateway_light/gateway.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const (
4848
var (
4949
ErrTwinIDMismatch = fmt.Errorf("twin id mismatch")
5050
ErrContractNotReserved = fmt.Errorf("a name contract with the given name must be reserved first")
51-
ErrInvalidContractState = fmt.Errorf("the name contract must be in Created state")
51+
ErrInvalidContractState = fmt.Errorf("the name contract must be in Created or GracePeriod state")
5252

5353
_ pkg.Gateway = (*gatewayModule)(nil)
5454
)
@@ -556,7 +556,7 @@ func (g *gatewayModule) validateNameContract(name string, twinID uint32) error {
556556
} else if subErr.IsError() {
557557
return subErr.Err
558558
}
559-
if !contract.State.IsCreated {
559+
if !contract.State.IsCreated && !contract.State.IsGracePeriod {
560560
return ErrInvalidContractState
561561
}
562562
if uint32(contract.TwinID) != twinID {

0 commit comments

Comments
 (0)