Skip to content
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

refactor: eliminate unnecessary nil check in BigEndianToUint64 function #778

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 1 addition & 6 deletions x/crosschain/keeper/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,5 @@ func (k Keeper) SetLastEventBlockHeightByOracle(ctx sdk.Context, oracleAddr sdk.
// GetLastEventBlockHeightByOracle get the latest event blockHeight for a give oracle
func (k Keeper) GetLastEventBlockHeightByOracle(ctx sdk.Context, oracleAddr sdk.AccAddress) uint64 {
store := ctx.KVStore(k.storeKey)
key := types.GetLastEventBlockHeightByOracleKey(oracleAddr)
if !store.Has(key) {
return 0
}
data := store.Get(key)
return sdk.BigEndianToUint64(data)
return sdk.BigEndianToUint64(store.Get(types.GetLastEventBlockHeightByOracleKey(oracleAddr)))
}
6 changes: 1 addition & 5 deletions x/crosschain/keeper/batch_confirm.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ func (k Keeper) SetLastSlashedBatchBlock(ctx sdk.Context, blockHeight uint64) {
// GetLastSlashedBatchBlock returns the latest slashed Batch block
func (k Keeper) GetLastSlashedBatchBlock(ctx sdk.Context) uint64 {
store := ctx.KVStore(k.storeKey)
bytes := store.Get(types.LastSlashedBatchBlock)
if len(bytes) == 0 {
return 0
}
return sdk.BigEndianToUint64(bytes)
return sdk.BigEndianToUint64(store.Get(types.LastSlashedBatchBlock))
}

// GetUnSlashedBatches returns all the unSlashed batches in state
Expand Down
6 changes: 1 addition & 5 deletions x/crosschain/keeper/observed.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import (
// GetLastObservedEventNonce returns the latest observed event nonce
func (k Keeper) GetLastObservedEventNonce(ctx sdk.Context) uint64 {
store := ctx.KVStore(k.storeKey)
bytes := store.Get(types.LastObservedEventNonceKey)
if len(bytes) == 0 {
return 0
}
return sdk.BigEndianToUint64(bytes)
return sdk.BigEndianToUint64(store.Get(types.LastObservedEventNonceKey))
}

// SetLastObservedEventNonce sets the latest observed event nonce
Expand Down
6 changes: 1 addition & 5 deletions x/crosschain/keeper/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,5 @@ func (k Keeper) SetLastOracleSlashBlockHeight(ctx sdk.Context, blockHeight uint6
// GetLastOracleSlashBlockHeight returns the last proposal block height
func (k Keeper) GetLastOracleSlashBlockHeight(ctx sdk.Context) uint64 {
store := ctx.KVStore(k.storeKey)
data := store.Get(types.LastOracleSlashBlockHeight)
if len(data) == 0 {
return 0
}
return sdk.BigEndianToUint64(data)
return sdk.BigEndianToUint64(store.Get(types.LastOracleSlashBlockHeight))
}
6 changes: 1 addition & 5 deletions x/crosschain/keeper/oracle_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,7 @@ func (k Keeper) SetLatestOracleSetNonce(ctx sdk.Context, nonce uint64) {
// GetLatestOracleSetNonce returns the latest oracleSet nonce
func (k Keeper) GetLatestOracleSetNonce(ctx sdk.Context) uint64 {
store := ctx.KVStore(k.storeKey)
data := store.Get(types.LatestOracleSetNonce)
if len(data) == 0 {
return 0
}
return sdk.BigEndianToUint64(data)
return sdk.BigEndianToUint64(store.Get(types.LatestOracleSetNonce))
}

// GetUnSlashedOracleSets returns all the unSlashed oracle sets in state
Expand Down
6 changes: 1 addition & 5 deletions x/crosschain/keeper/oracle_set_confirm.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,5 @@ func (k Keeper) SetLastSlashedOracleSetNonce(ctx sdk.Context, nonce uint64) {
// GetLastSlashedOracleSetNonce returns the latest slashed oracleSet nonce
func (k Keeper) GetLastSlashedOracleSetNonce(ctx sdk.Context) uint64 {
store := ctx.KVStore(k.storeKey)
data := store.Get(types.LastSlashedOracleSetNonce)
if len(data) == 0 {
return 0
}
return sdk.BigEndianToUint64(data)
return sdk.BigEndianToUint64(store.Get(types.LastSlashedOracleSetNonce))
}