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 13:50:05 +0800 |
commit | d550ab1a88353d326ecd743170f0a4117568d66b (patch) | |
tree | 64174d3a13148408a6e6900f81c3fe9884c05a47 | |
parent | f8965e35ce4ee76187cb8c479bec99638f93efc2 (diff) | |
download | dexon-d550ab1a88353d326ecd743170f0a4117568d66b.tar.gz dexon-d550ab1a88353d326ecd743170f0a4117568d66b.tar.zst dexon-d550ab1a88353d326ecd743170f0a4117568d66b.zip |
dex: do not propose skip block if not in notary set (#303)
-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 |