Cluster raft config changes

This commit is contained in:
Shrenuj Bansal 2022-09-13 19:09:03 -04:00
parent 4be8861f41
commit 81c729e09c
3 changed files with 19 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package node
import (
"os"
gorpc "github.com/libp2p/go-libp2p-gorpc"
"go.uber.org/fx"
"golang.org/x/xerrors"
@ -28,6 +29,7 @@ import (
"github.com/filecoin-project/lotus/chain/wallet"
ledgerwallet "github.com/filecoin-project/lotus/chain/wallet/ledger"
"github.com/filecoin-project/lotus/chain/wallet/remotewallet"
consensus2 "github.com/filecoin-project/lotus/lib/consensus/raft"
"github.com/filecoin-project/lotus/lib/peermgr"
"github.com/filecoin-project/lotus/markets/storageadapter"
"github.com/filecoin-project/lotus/node/config"
@ -237,6 +239,15 @@ func ConfigFullNode(c interface{}) Option {
Unset(new(*wallet.LocalWallet)),
Override(new(wallet.Default), wallet.NilDefault),
),
// Chain node cluster enabled
If(cfg.Raft.ClusterModeEnabled,
Override(new(*gorpc.Client), modules.NewRPCClient),
Override(new(*consensus.Consensus), consensus2.NewConsensusWithRPCClient(false)),
Override(new(*messagesigner.MessageSignerConsensus), messagesigner.NewMessageSignerConsensus),
Override(new(messagesigner.MsgSigner), func(ms *messagesigner.MessageSignerConsensus) *messagesigner.MessageSignerConsensus { return ms }),
Override(new(*modules.RPCHandler), modules.NewRPCHandler),
Override(RPCServer, modules.NewRPCServer),
),
)
}

View File

@ -118,6 +118,12 @@ of automatically performing on-chain operations.`,
},
},
"ClusterRaftConfig": []DocField{
{
Num: "ClusterModeEnabled",
Type: "bool",
Comment: `config to enabled node cluster with raft consensus`,
},
{
Num: "HostShutdown",
Type: "bool",

View File

@ -598,6 +598,8 @@ type FeeConfig struct {
// ClusterRaftConfig allows to configure the Raft Consensus component for the node cluster.
type ClusterRaftConfig struct {
// config to enabled node cluster with raft consensus
ClusterModeEnabled bool
// will shutdown libp2p host on shutdown. Useful for testing
HostShutdown bool
// A folder to store Raft's data.