diff --git a/common/config/producer.go b/common/config/producer.go index b279f7b0d..b0d57b903 100644 --- a/common/config/producer.go +++ b/common/config/producer.go @@ -13,8 +13,6 @@ type Producer struct { Coinbase string `json:"Coinbase"` EntropyStorePath string `json:"EntropyStorePath"` - ExternalMiner bool `json:"externalMiner"` - coinbase types.Address index uint32 } diff --git a/conf/evm/node_config.json b/conf/evm/node_config.json index c6660a6a1..21be9b917 100644 --- a/conf/evm/node_config.json +++ b/conf/evm/node_config.json @@ -18,11 +18,9 @@ "util", "debug", "sbpstats", - "miner", "wallet" ], "Miner": true, - "ExternalMiner": true, "CoinBase": "0:vite_3167c9421c8a4cb642d613082dfcef932e26063867f277ec0f", "EntropyStorePath": "/root/conf/evm/vite_3167c9421c8a4cb642d613082dfcef932e26063867f277ec0f", "EntropyStorePassword": "123456", diff --git a/ledger/consensus/config.go b/ledger/consensus/config.go index d75730921..09acdd6c2 100644 --- a/ledger/consensus/config.go +++ b/ledger/consensus/config.go @@ -1,15 +1,12 @@ package consensus type ConsensusCfg struct { - EnablePuppet bool } func DefaultCfg() *ConsensusCfg { - return &ConsensusCfg{ - EnablePuppet: false, - } + return &ConsensusCfg{} } -func Cfg(enablePuppet bool) *ConsensusCfg { - return &ConsensusCfg{EnablePuppet: enablePuppet} +func Cfg() *ConsensusCfg { + return &ConsensusCfg{} } diff --git a/ledger/consensus/consensus_impl.go b/ledger/consensus/consensus_impl.go index 52822ec2f..25e72b9e4 100644 --- a/ledger/consensus/consensus_impl.go +++ b/ledger/consensus/consensus_impl.go @@ -12,9 +12,6 @@ import ( ) func (cs *consensus) VerifySnapshotProducer(header *ledger.SnapshotBlock) (bool, error) { - if cs.EnablePuppet { - return true, nil - } cs.snapshot.verifyProducerAndSeed(header) return cs.snapshot.VerifyProducer(header.Producer(), *header.Timestamp) } @@ -116,12 +113,6 @@ func (cs *consensus) Init(cfg *ConsensusCfg) error { cs.rw.init(snapshot) cs.tg = newTrigger(cs.rollback) - if cfg.EnablePuppet { - sub := newSubscriberPuppet(cs.Subscriber, cs.snapshot) - cs.Subscriber = sub - cs.subscribeTrigger = sub - } - cs.contracts = newContractCs(cs.rw, cs.mLog) err := cs.contracts.LoadGid(types.DELEGATE_GID) diff --git a/ledger/consensus/subscriber_puppet.go b/ledger/consensus/subscriber_puppet.go deleted file mode 100644 index c14963baa..000000000 --- a/ledger/consensus/subscriber_puppet.go +++ /dev/null @@ -1,58 +0,0 @@ -package consensus - -import ( - "time" - - "github.com/vitelabs/go-vite/v2/common" - "github.com/vitelabs/go-vite/v2/common/types" -) - -type subscriber_puppet struct { - *consensusSubscriber - - snapshot DposReader -} - -func newSubscriberPuppet(sub interface{}, snapshot DposReader) *subscriber_puppet { - switch v := sub.(type) { - case *consensusSubscriber: - return &subscriber_puppet{ - consensusSubscriber: v, - snapshot: snapshot, - } - } - panic("err sub type") -} - -func (cs subscriber_puppet) triggerEvent(gid types.Gid, fn func(*subscribeEvent)) { - if gid == types.SNAPSHOT_GID { - return - } - cs.consensusSubscriber.triggerEvent(gid, fn) -} - -func (cs subscriber_puppet) TriggerMineEvent(addr types.Address) error { - sTime := time.Unix(time.Now().Unix(), 0) - eTime := sTime.Add(time.Duration(cs.snapshot.GetInfo().Interval)) - index := cs.snapshot.Time2Index(sTime) - periodStartTime, periodEndTime := cs.snapshot.Index2Time(index) - voteTime := cs.snapshot.GenProofTime(index) - - cs.consensusSubscriber.triggerEvent(types.SNAPSHOT_GID, func(e *subscribeEvent) { - common.Go(func() { - event := Event{ - Gid: types.SNAPSHOT_GID, - Address: addr, - Stime: sTime, - Etime: eTime, - Timestamp: sTime, - VoteTime: voteTime, - PeriodStime: periodStartTime, - PeriodEtime: periodEndTime, - } - e.fn(event) - }) - - }) - return nil -} diff --git a/node/config/config.go b/node/config/config.go index eb49a483a..3913a38dc 100644 --- a/node/config/config.go +++ b/node/config/config.go @@ -63,7 +63,6 @@ type Config struct { EntropyStorePassword string `json:"EntropyStorePassword"` CoinBase string `json:"CoinBase"` MinerEnabled bool `json:"Miner"` - ExternalMiner bool `json:"ExternalMiner"` //rpc RPCEnabled bool `json:"RPCEnabled"` @@ -193,7 +192,6 @@ func (c *Config) MakeMinerConfig() *config.Producer { Producer: c.MinerEnabled, Coinbase: c.CoinBase, EntropyStorePath: c.EntropyStorePath, - ExternalMiner: c.ExternalMiner, } err := cfg.Parse() if err != nil { diff --git a/rpcapi/api/virtual.go b/rpcapi/api/virtual.go index 29469c1db..c41ed910c 100644 --- a/rpcapi/api/virtual.go +++ b/rpcapi/api/virtual.go @@ -2,7 +2,6 @@ package api import ( "errors" - "fmt" "github.com/vitelabs/go-vite/v2" "github.com/vitelabs/go-vite/v2/common/upgrade" @@ -29,12 +28,6 @@ func (api VirtualApi) String() string { } func (api *VirtualApi) Mine() error { - if !api.vite.Config().IsMine() { - return fmt.Errorf("should enable mine") - } - if !api.vite.Config().ExternalMiner { - return fmt.Errorf("should enable external miner") - } return api.vite.Producer().SnapshotOnce() } diff --git a/vite.go b/vite.go index 4bd52b602..c90591362 100644 --- a/vite.go +++ b/vite.go @@ -124,7 +124,7 @@ func (v *Vite) Start() (err error) { v.chain.Start() - err = v.consensus.Init(consensus.Cfg(v.Config().Producer.ExternalMiner)) + err = v.consensus.Init(consensus.Cfg()) if err != nil { return err }