diff options
author | Sonic <sonic@dexon.org> | 2019-05-13 08:42:12 +0800 |
---|---|---|
committer | Sonic <sonic@dexon.org> | 2019-05-13 08:42:12 +0800 |
commit | ad2e2dbf2115319c35b806abe823b8cf27e4e96e (patch) | |
tree | 8781caffb5070f74ae1612d66bc4a5041aa08cae /light/lightchain.go | |
parent | 31f99d2c7da15226627ea71acd8bd55093c6e7f8 (diff) | |
download | dexon-s-lds.tar dexon-s-lds.tar.gz dexon-s-lds.tar.bz2 dexon-s-lds.tar.lz dexon-s-lds.tar.xz dexon-s-lds.tar.zst dexon-s-lds.zip |
tmps-lds
Diffstat (limited to 'light/lightchain.go')
-rw-r--r-- | light/lightchain.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/light/lightchain.go b/light/lightchain.go index ac04a9728..7028ed976 100644 --- a/light/lightchain.go +++ b/light/lightchain.go @@ -305,6 +305,20 @@ func (self *LightChain) GetBlockByNumber(ctx context.Context, number uint64) (*t return self.GetBlock(ctx, hash, number) } +func (self *LightChain) CurrentGovState() *types.GovState { + hash := rawdb.ReadHeadGovStateHash(self.chainDb) + if hash == (common.Hash{}) { + log.Warn("Head gov state hash not found") + return nil + } + govState, err := self.GetGovStateByHash(hash) + if err != nil { + log.Warn("Get gov state by hash fail, err=%v", err) + return nil + } + return govState +} + func (self *LightChain) GetGovStateByHash(hash common.Hash) (*types.GovState, error) { header := self.GetHeaderByHash(hash) if header == nil { |