Skip to content

Commit

Permalink
feat(dpos): update max tx per block
Browse files Browse the repository at this point in the history
  • Loading branch information
RainFallsSilent committed Jan 21, 2025
1 parent 1862b6e commit 186da4a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pow/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const (
maxNonce = ^uint32(0) // 2^32 - 1
updateInterval = 30 * time.Second
createAuxBlockInterval = 5 * time.Second
maxTxPerBlock = 100
)

type Config struct {
Expand Down Expand Up @@ -277,7 +276,7 @@ func (pow *Service) distributeDPOSReward(coinBaseTx interfaces.Transaction,
}

func (pow *Service) GenerateBlock(minerAddr string,
txPerBlock int) (*types.Block, error) {
txPerBlock uint32) (*types.Block, error) {
bestChain := pow.chain.BestChain
nextBlockHeight := bestChain.Height + 1
coinBaseTx, err := pow.CreateCoinbaseTx(minerAddr, nextBlockHeight)
Expand All @@ -300,7 +299,7 @@ func (pow *Service) GenerateBlock(minerAddr string,
}

msgBlock.Transactions = append(msgBlock.Transactions, coinBaseTx)
txCount := 1
txCount := uint32(1)
totalTxsSize := coinBaseTx.GetSize()
totalTxFee := common.Fixed64(0)

Expand Down Expand Up @@ -403,7 +402,7 @@ func (pow *Service) CreateAuxBlock(payToAddr string) (*types.Block, error) {
}

// Create new block with nonce = 0
auxBlock, err := pow.GenerateBlock(payToAddr, maxTxPerBlock)
auxBlock, err := pow.GenerateBlock(payToAddr, pact.MaxTxPerBlock)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -472,7 +471,7 @@ func (pow *Service) DiscreteMining(n uint32) ([]*common.Uint256, error) {

log.Info("<================Discrete Mining==============>\n")
for {
msgBlock, err := pow.GenerateBlock(pow.PayToAddr, maxTxPerBlock)
msgBlock, err := pow.GenerateBlock(pow.PayToAddr, pact.MaxTxPerBlock)
if err != nil {
log.Warn("Generate block failed, ", err.Error())
continue
Expand Down Expand Up @@ -581,7 +580,7 @@ out:
log.Debug("<================Packing Block==============>")
//time.Sleep(15 * time.Second)

msgBlock, err := pow.GenerateBlock(pow.PayToAddr, maxTxPerBlock)
msgBlock, err := pow.GenerateBlock(pow.PayToAddr, pact.MaxTxPerBlock)
if err != nil {
log.Debug("generage block err", err)
continue
Expand Down

0 comments on commit 186da4a

Please sign in to comment.