From 4095f8c34043a2418dece4d5affbceffe0ca55da Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Wed, 16 Jan 2019 13:07:20 +0800 Subject: vendor: sync to latest core (#154) * vendor: sync to latest core with BA3.0 * params: Update dmoment --- .../dexon-consensus/core/db/level-db.go | 43 +++++----------------- 1 file changed, 9 insertions(+), 34 deletions(-) (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/db') diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/db/level-db.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/db/level-db.go index 75c30372f..1fe29fa10 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/db/level-db.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/db/level-db.go @@ -72,11 +72,7 @@ func (lvl *LevelDBBackedDB) HasBlock(hash common.Hash) bool { } func (lvl *LevelDBBackedDB) internalHasBlock(key []byte) (bool, error) { - exists, err := lvl.db.Has(key, nil) - if err != nil { - return false, err - } - return exists, nil + return lvl.db.Has(key, nil) } // GetBlock implements the Reader.GetBlock method. @@ -90,9 +86,6 @@ func (lvl *LevelDBBackedDB) GetBlock( return } err = rlp.DecodeBytes(queried, &block) - if err != nil { - return - } return } @@ -113,9 +106,7 @@ func (lvl *LevelDBBackedDB) UpdateBlock(block types.Block) (err error) { err = ErrBlockDoesNotExist return } - if err = lvl.db.Put(blockKey, marshaled, nil); err != nil { - return - } + err = lvl.db.Put(blockKey, marshaled, nil) return } @@ -134,9 +125,7 @@ func (lvl *LevelDBBackedDB) PutBlock(block types.Block) (err error) { err = ErrBlockExists return } - if err = lvl.db.Put(blockKey, marshaled, nil); err != nil { - return - } + err = lvl.db.Put(blockKey, marshaled, nil) return } @@ -166,10 +155,7 @@ func (lvl *LevelDBBackedDB) PutCompactionChainTipInfo( if info.Height+1 != height { return ErrInvalidCompactionChainTipHeight } - if err = lvl.db.Put(compactionChainTipInfoKey, marshaled, nil); err != nil { - return err - } - return nil + return lvl.db.Put(compactionChainTipInfoKey, marshaled, nil) } func (lvl *LevelDBBackedDB) internalGetCompactionChainTipInfo() ( @@ -181,9 +167,7 @@ func (lvl *LevelDBBackedDB) internalGetCompactionChainTipInfo() ( } return } - if err = rlp.DecodeBytes(queried, &info); err != nil { - return - } + err = rlp.DecodeBytes(queried, &info) return } @@ -201,11 +185,7 @@ func (lvl *LevelDBBackedDB) GetCompactionChainTipInfo() ( // HasDKGPrivateKey check existence of DKG private key of one round. func (lvl *LevelDBBackedDB) HasDKGPrivateKey(round uint64) (bool, error) { - exists, err := lvl.db.Has(lvl.getDKGPrivateKeyKey(round), nil) - if err != nil { - return false, err - } - return exists, nil + return lvl.db.Has(lvl.getDKGPrivateKeyKey(round), nil) } // GetDKGPrivateKey get DKG private key of one round. @@ -218,9 +198,7 @@ func (lvl *LevelDBBackedDB) GetDKGPrivateKey(round uint64) ( } return } - if err = rlp.DecodeBytes(queried, &prv); err != nil { - return - } + err = rlp.DecodeBytes(queried, &prv) return } @@ -239,11 +217,8 @@ func (lvl *LevelDBBackedDB) PutDKGPrivateKey( if err != nil { return err } - if err := lvl.db.Put( - lvl.getDKGPrivateKeyKey(round), marshaled, nil); err != nil { - return err - } - return nil + return lvl.db.Put( + lvl.getDKGPrivateKeyKey(round), marshaled, nil) } func (lvl *LevelDBBackedDB) getBlockKey(hash common.Hash) (ret []byte) { -- cgit v1.2.3