diff options
author | Wei-Ning Huang <w@dexon.org> | 2019-03-27 18:54:10 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:58 +0800 |
commit | a29eba604b1a58ea414a6570223dedb0482cefaf (patch) | |
tree | f7413ae341125e79f81557b769707ad8ac62c659 /dex | |
parent | 797e5058c6dbfa3c668d6568144431aea03f6256 (diff) | |
download | dexon-a29eba604b1a58ea414a6570223dedb0482cefaf.tar.gz dexon-a29eba604b1a58ea414a6570223dedb0482cefaf.tar.zst dexon-a29eba604b1a58ea414a6570223dedb0482cefaf.zip |
dex: do not propose skip block if not in notary set (#303)
Diffstat (limited to 'dex')
-rw-r--r-- | dex/recovery.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/dex/recovery.go b/dex/recovery.go index 4c3da7d5a..adeb1f612 100644 --- a/dex/recovery.go +++ b/dex/recovery.go @@ -314,6 +314,7 @@ type Recovery struct { gov *DexconGovernance contract common.Address confirmation int + publicKey string privateKey *ecdsa.PrivateKey nodeAddress common.Address client *ethrpc.EthRPC @@ -326,6 +327,7 @@ func NewRecovery(config *params.RecoveryConfig, networkRPC string, gov: gov, contract: config.Contract, confirmation: config.Confirmation, + publicKey: hex.EncodeToString(crypto.FromECDSAPub(&privKey.PublicKey)), privateKey: privKey, nodeAddress: crypto.PubkeyToAddress(privKey.PublicKey), client: client, @@ -429,6 +431,14 @@ func (r *Recovery) genVoteForSkipBlockTx(height uint64) (*types.Transaction, err } func (r *Recovery) ProposeSkipBlock(height uint64) error { + notarySet, err := r.gov.NotarySet(r.gov.Round()) + if err != nil { + return err + } + if _, ok := notarySet[r.publicKey]; !ok { + return errors.New("not in notary set") + } + tx, err := r.genVoteForSkipBlockTx(height) if err == errAlreadyVoted { return nil |