diff options
author | Sonic <sonic@dexon.org> | 2019-05-09 14:45:50 +0800 |
---|---|---|
committer | Sonic <sonic@dexon.org> | 2019-05-09 14:45:50 +0800 |
commit | 2555cb4549e55566131f4ef3d4e06e736f4bdffb (patch) | |
tree | f90a5a29f35762f4e84af4b7bde96df0b0a8f467 | |
parent | 613d4ca4e17de31fce483378192e8e9fbf28be59 (diff) | |
download | dexon-2555cb4549e55566131f4ef3d4e06e736f4bdffb.tar dexon-2555cb4549e55566131f4ef3d4e06e736f4bdffb.tar.gz dexon-2555cb4549e55566131f4ef3d4e06e736f4bdffb.tar.bz2 dexon-2555cb4549e55566131f4ef3d4e06e736f4bdffb.tar.lz dexon-2555cb4549e55566131f4ef3d4e06e736f4bdffb.tar.xz dexon-2555cb4549e55566131f4ef3d4e06e736f4bdffb.tar.zst dexon-2555cb4549e55566131f4ef3d4e06e736f4bdffb.zip |
fixup! light: implement GetGovStateByNumber and InsertDexonHeaderChain (Stub)
-rw-r--r-- | light/lightchain.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/light/lightchain.go b/light/lightchain.go index 232178308..ac04a9728 100644 --- a/light/lightchain.go +++ b/light/lightchain.go @@ -305,6 +305,21 @@ func (self *LightChain) GetBlockByNumber(ctx context.Context, number uint64) (*t return self.GetBlock(ctx, hash, number) } +func (self *LightChain) GetGovStateByHash(hash common.Hash) (*types.GovState, error) { + header := self.GetHeaderByHash(hash) + if header == nil { + return nil, fmt.Errorf("header not found") + } + + govState := rawdb.ReadGovState(self.chainDb, header.Hash()) + if govState == nil { + log.Debug("gov state not found in db") + return nil, fmt.Errorf("gov state not found in db") + } + log.Debug("Read gov state from db success") + return govState, nil +} + func (self *LightChain) GetGovStateByNumber(number uint64) (*types.GovState, error) { header := self.GetHeaderByNumber(number) if header == nil { |