aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-03-27 18:54:10 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:58 +0800
commita29eba604b1a58ea414a6570223dedb0482cefaf (patch)
treef7413ae341125e79f81557b769707ad8ac62c659
parent797e5058c6dbfa3c668d6568144431aea03f6256 (diff)
downloaddexon-a29eba604b1a58ea414a6570223dedb0482cefaf.tar
dexon-a29eba604b1a58ea414a6570223dedb0482cefaf.tar.gz
dexon-a29eba604b1a58ea414a6570223dedb0482cefaf.tar.bz2
dexon-a29eba604b1a58ea414a6570223dedb0482cefaf.tar.lz
dexon-a29eba604b1a58ea414a6570223dedb0482cefaf.tar.xz
dexon-a29eba604b1a58ea414a6570223dedb0482cefaf.tar.zst
dexon-a29eba604b1a58ea414a6570223dedb0482cefaf.zip
dex: do not propose skip block if not in notary set (#303)
-rw-r--r--dex/recovery.go10
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