Add Mpool ref to raft state and rearrange some APIs

This commit is contained in:
Shrenuj Bansal
2022-09-29 10:56:57 +00:00
parent 570f61438a
commit f89a682d98
26 changed files with 705 additions and 297 deletions
+3 -2
View File
@@ -9,7 +9,8 @@ import (
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
consensus2 "github.com/filecoin-project/lotus/lib/consensus/raft"
//consensus2 "github.com/filecoin-project/lotus/lib/consensus/raft"
"github.com/filecoin-project/lotus/node/impl/client"
"github.com/filecoin-project/lotus/node/impl/common"
"github.com/filecoin-project/lotus/node/impl/full"
@@ -119,7 +120,7 @@ func (n *FullNodeAPI) NodeStatus(ctx context.Context, inclChainStatus bool) (sta
return status, nil
}
func (n *FullNodeAPI) RaftState(ctx context.Context) (*consensus2.RaftState, error) {
func (n *FullNodeAPI) RaftState(ctx context.Context) (*api.RaftStateData, error) {
return n.RaftAPI.GetRaftState(ctx)
}
+8 -3
View File
@@ -2,12 +2,13 @@ package full
import (
"context"
"github.com/libp2p/go-libp2p/core/peer"
"go.uber.org/fx"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/messagesigner"
consensus "github.com/filecoin-project/lotus/lib/consensus/raft"
)
type RaftAPI struct {
@@ -16,11 +17,15 @@ type RaftAPI struct {
MessageSigner *messagesigner.MessageSignerConsensus `optional:"true"`
}
func (r *RaftAPI) GetRaftState(ctx context.Context) (*consensus.RaftState, error) {
func (r *RaftAPI) GetRaftState(ctx context.Context) (*api.RaftStateData, error) {
if r.MessageSigner == nil {
return nil, xerrors.Errorf("Raft consensus not enabled. Please check your configuration")
}
return r.MessageSigner.GetRaftState(ctx)
raftState, err := r.MessageSigner.GetRaftState(ctx)
if err != nil {
return nil, err
}
return &api.RaftStateData{NonceMap: raftState.NonceMap, MsgUuids: raftState.MsgUuids}, nil
}
func (r *RaftAPI) Leader(ctx context.Context) (peer.ID, error) {