fix some bugs and address some comments

This commit is contained in:
Shrenuj Bansal
2022-10-16 22:52:22 -04:00
parent 17a77220c2
commit 139f8773de
8 changed files with 33 additions and 59 deletions
+12 -4
View File
@@ -3,10 +3,10 @@
package consensus
import (
"bytes"
"context"
"errors"
"fmt"
"github.com/filecoin-project/lotus/lib/addrutil"
"sort"
"time"
@@ -18,6 +18,7 @@ import (
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/messagepool"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/addrutil"
"github.com/filecoin-project/lotus/node/repo"
//ds "github.com/ipfs/go-datastore"
@@ -73,10 +74,17 @@ func (c ConsensusOp) ApplyTo(state consensus.State) (consensus.State, error) {
s := state.(*RaftState)
s.NonceMap[c.Addr] = c.Nonce
if c.SignedMsg != nil {
tmp := *c.SignedMsg
s.MsgUuids[c.Uuid] = &tmp
_, err := s.Mpool.Push(context.TODO(), c.SignedMsg, false)
// Deep copy to tmp
var buffer bytes.Buffer
c.SignedMsg.MarshalCBOR(&buffer)
tmp, err := types.DecodeSignedMessage(buffer.Bytes())
if err != nil {
return nil, err
}
s.MsgUuids[c.Uuid] = tmp
_, err = s.Mpool.Push(context.TODO(), tmp, false)
// Since this is only meant to keep messages in sync, ignore any error which
// shows the message already exists in the mpool
if err != nil && !api.ErrorIsIn(err, []error{messagepool.ErrExistingNonce}) {
+1 -1
View File
@@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"github.com/filecoin-project/lotus/lib/addrutil"
"io"
"os"
"path/filepath"
@@ -18,6 +17,7 @@ import (
peer "github.com/libp2p/go-libp2p/core/peer"
"go.uber.org/zap"
"github.com/filecoin-project/lotus/lib/addrutil"
"github.com/filecoin-project/lotus/node/repo"
)