Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cmd] Set server command seal flag default to false #196

Merged
merged 2 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion command/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func setFlags(cmd *cobra.Command) {
cmd.Flags().BoolVar(
&params.rawConfig.ShouldSeal,
sealFlag,
true,
false,
"the flag indicating that the client should seal blocks",
)

Expand Down
29 changes: 20 additions & 9 deletions txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ import (
"math/big"
"time"

"github.com/go-kit/kit/metrics"
"github.com/golang/protobuf/ptypes/any"
"github.com/hashicorp/go-hclog"
"google.golang.org/grpc"

"github.com/dogechain-lab/dogechain/blockchain"
"github.com/dogechain-lab/dogechain/chain"
"github.com/dogechain-lab/dogechain/network"
"github.com/dogechain-lab/dogechain/state"
"github.com/dogechain-lab/dogechain/txpool/proto"
"github.com/dogechain-lab/dogechain/types"
"github.com/go-kit/kit/metrics"
"github.com/golang/protobuf/ptypes/any"
"github.com/hashicorp/go-hclog"
"google.golang.org/grpc"
)

const (
Expand Down Expand Up @@ -225,11 +224,12 @@ func NewTxPool(
index: lookupMap{all: make(map[types.Hash]*types.Transaction)},
gauge: slotGauge{height: 0, max: maxSlot},
priceLimit: config.PriceLimit,
sealing: config.Sealing,
pruneTick: time.Second * time.Duration(pruneTickSeconds),
promoteOutdateDuration: time.Second * time.Duration(promoteOutdateSeconds),
}

pool.SetSealing(config.Sealing) // sealing flag

// Attach the event manager
pool.eventManager = newEventManager(pool.logger)

Expand All @@ -240,6 +240,7 @@ func NewTxPool(
return nil, err
}

// subscribe txpool topic to make a full-message peerings
if subscribeErr := topic.Subscribe(pool.addGossipTx); subscribeErr != nil {
return nil, fmt.Errorf("unable to subscribe to gossip topic, %w", subscribeErr)
}
Expand All @@ -265,6 +266,16 @@ func NewTxPool(
return pool, nil
}

// SetSealing sets the sealing flag
func (p *TxPool) SetSealing(sealing bool) {
p.sealing = sealing
}

// sealing returns the current set sealing flag
func (p *TxPool) getSealing() bool {
return p.sealing
}

// Start runs the pool's main loop in the background.
// On each request received, the appropriate handler
// is invoked in a separate goroutine.
Expand Down Expand Up @@ -817,10 +828,10 @@ func (p *TxPool) pruneEnqueuedTxs(pruned []*types.Transaction) {
p.decreaseQueueGauge(pruned, p.metrics.EnqueueTxs, proto.EventType_PRUNED_ENQUEUED)
}

// addGossipTx handles receiving transactions
// gossiped by the network.
// addGossipTx handles receiving transactions gossiped by the network.
func (p *TxPool) addGossipTx(obj interface{}) {
if !p.sealing {
if !p.getSealing() {
// we're not validator, not interested in it
return
}

Expand Down