aboutsummaryrefslogtreecommitdiffstats
path: root/dex/governance.go
diff options
context:
space:
mode:
authorSonic <sonic@dexon.org>2018-11-20 14:13:53 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:53 +0800
commitafc01df41cafd3a8b56db9f32e23da3bf0e6b7ef (patch)
tree28013bb14a19611adecda49d1dfbeb0a34dad66a /dex/governance.go
parent2113837c006aad6af75c09d37514591fd6863dbc (diff)
downloaddexon-afc01df41cafd3a8b56db9f32e23da3bf0e6b7ef.tar
dexon-afc01df41cafd3a8b56db9f32e23da3bf0e6b7ef.tar.gz
dexon-afc01df41cafd3a8b56db9f32e23da3bf0e6b7ef.tar.bz2
dexon-afc01df41cafd3a8b56db9f32e23da3bf0e6b7ef.tar.lz
dexon-afc01df41cafd3a8b56db9f32e23da3bf0e6b7ef.tar.xz
dexon-afc01df41cafd3a8b56db9f32e23da3bf0e6b7ef.tar.zst
dexon-afc01df41cafd3a8b56db9f32e23da3bf0e6b7ef.zip
dex: implement downloader for dex
We need governance state to verify block's signature (randomness), but in ethereum fast sync mode, eth downloader only downloads the whole state of pivot block, so we don't have governance state to verify the downloaded block that is before pivot block if we don't processing transaction. To avoid running transactions, dex downloader also downloads the governance state (merkle proof and storage) at snapshot height of each round, so that we can verify blocks in fast sync mode.
Diffstat (limited to 'dex/governance.go')
-rw-r--r--dex/governance.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/dex/governance.go b/dex/governance.go
index db33f7820..01f39b68c 100644
--- a/dex/governance.go
+++ b/dex/governance.go
@@ -46,7 +46,7 @@ func NewDexconGovernance(backend *DexAPIBackend, chainConfig *params.ChainConfig
return g
}
-func (d *DexconGovernance) getRoundHeight(ctx context.Context, round uint64) (uint64, error) {
+func (d *DexconGovernance) GetRoundHeight(ctx context.Context, round uint64) (uint64, error) {
state, _, err := d.b.StateAndHeaderByNumber(ctx, rpc.LatestBlockNumber)
if state == nil || err != nil {
return 0, err
@@ -72,7 +72,7 @@ func (d *DexconGovernance) getGovStateAtRound(round uint64) *vm.GovernanceStateH
round -= dexCore.ConfigRoundShift
}
ctx := context.Background()
- blockHeight, err := d.getRoundHeight(ctx, round)
+ blockHeight, err := d.GetRoundHeight(ctx, round)
if err != nil {
return nil
}