Implement customizing dispute vote window time in dione config

This commit is contained in:
ChronosX88 2021-04-21 00:38:54 +03:00
parent fb22d3c4e3
commit b1cfc81cf7
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A
3 changed files with 8 additions and 5 deletions

View File

@ -30,6 +30,7 @@ type EthereumConfig struct {
DioneOracleContractAddress string `mapstructure:"oracle_contract_address"`
DioneStakingContractAddress string `mapstructure:"staking_contract_address"`
DisputeContractAddress string `mapstructure:"dispute_contract_address"`
DisputeVoteWindow int `mapstructure:"dispute_vote_window"` // in secs
}
type FilecoinConfig struct {

View File

@ -21,9 +21,10 @@ type DisputeManager struct {
pcm *PBFTConsensusManager
submissionMap map[string]*dioneOracle.DioneOracleSubmittedOracleRequest
disputeMap map[string]*dioneDispute.DioneDisputeNewDispute
voteWindow time.Duration
}
func NewDisputeManager(ctx context.Context, ethClient *ethclient.EthereumClient, pcm *PBFTConsensusManager) (*DisputeManager, error) {
func NewDisputeManager(ctx context.Context, ethClient *ethclient.EthereumClient, pcm *PBFTConsensusManager, voteWindow int) (*DisputeManager, error) {
newSubmittionsChan, submSubscription, err := ethClient.SubscribeOnNewSubmittions(ctx)
if err != nil {
return nil, err
@ -40,6 +41,7 @@ func NewDisputeManager(ctx context.Context, ethClient *ethclient.EthereumClient,
ctx: ctx,
submissionMap: map[string]*dioneOracle.DioneOracleSubmittedOracleRequest{},
disputeMap: map[string]*dioneDispute.DioneDisputeNewDispute{},
voteWindow: time.Duration(voteWindow) * time.Second,
}
go func() {
@ -92,7 +94,7 @@ func (dm *DisputeManager) onNewSubmission(submittion *dioneOracle.DioneOracleSub
logrus.Errorf(err.Error())
return
}
disputeFinishTimer := time.NewTimer(time.Minute * 5)
disputeFinishTimer := time.NewTimer(dm.voteWindow)
go func() {
for {
select {

View File

@ -139,7 +139,7 @@ func NewNode(config *config.Config, prvKey crypto.PrivKey, pexDiscoveryUpdateTim
logrus.Info("Consensus subsystem has initialized!")
// initialize dispute subsystem
disputeManager, err := provideDisputeManager(context.TODO(), ethClient, cManager)
disputeManager, err := provideDisputeManager(context.TODO(), ethClient, cManager, config)
if err != nil {
logrus.Fatal(err)
}
@ -268,8 +268,8 @@ func provideEventCache(config *config.Config) cache.EventCache {
return backend
}
func provideDisputeManager(ctx context.Context, ethClient *ethclient.EthereumClient, pcm *consensus.PBFTConsensusManager) (*consensus.DisputeManager, error) {
return consensus.NewDisputeManager(ctx, ethClient, pcm)
func provideDisputeManager(ctx context.Context, ethClient *ethclient.EthereumClient, pcm *consensus.PBFTConsensusManager, cfg *config.Config) (*consensus.DisputeManager, error) {
return consensus.NewDisputeManager(ctx, ethClient, pcm, cfg.Ethereum.DisputeVoteWindow)
}
func provideMiner(peerID peer.ID, ethAddress common.Address, beacon beacon.BeaconNetworks, ethClient *ethclient.EthereumClient, privateKey []byte) *consensus.Miner {