Skip to content

Commit

Permalink
#314: Implement transaction nonces in the applicator
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandeberg committed Nov 18, 2024
1 parent 6fc4cff commit 71aa138
Show file tree
Hide file tree
Showing 7 changed files with 394 additions and 72 deletions.
6 changes: 4 additions & 2 deletions internal/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,16 @@ func (n *KoinosP2PNode) handleBlockBroadcast(topic string, data []byte) {
}

func (n *KoinosP2PNode) handleTransactionBroadcast(topic string, data []byte) {
log.Debug("Received koinos.mempool.accept broadcast")
trxBroadcast := &broadcast.MempoolAccepted{}
log.Debug("Received koinos.chain.transaction_accepted")
trxBroadcast := &broadcast.TransactionAccepted{}
err := proto.Unmarshal(data, trxBroadcast)
if err != nil {
log.Warnf("Unable to parse koinos.transaction.accept broadcast: %v", err.Error())
return
}

n.Applicator.HandleTransactionBroadcast(trxBroadcast)

// If gossip is enabled publish the transaction
err = n.Gossip.PublishTransaction(context.Background(), trxBroadcast.Transaction)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions internal/options/applicator_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,39 @@ func min(x, y int) int {
const (
maxPendingBlocksDefault = 2500
maxHeightDeltaDefault = 60
maxPendingTransactionsDefault = 100000
delayThresholdDefault = time.Second * 4
delayTimeoutDefault = time.Second * 60
applicationJobsDefault = 8
forceChildRequestThresholdDefault = time.Minute
forceApplicationRetryDelayDefault = 50 * time.Millisecond
transactionExpirationDefault = time.Second * 10
)

// ApplicatorOptions are options for Applicator
type ApplicatorOptions struct {
MaxPendingBlocks uint64
MaxHeightDelta uint64
MaxPendingTransactions uint64
DelayThreshold time.Duration
DelayTimeout time.Duration
ApplicationJobs int
ForceChildRequestThreshold time.Duration
ForceApplicationRetryDelay time.Duration
TransactionExpiration time.Duration
}

// NewApplicatorOptions returns default initialized ApplicatorOptions
func NewApplicatorOptions() *ApplicatorOptions {
return &ApplicatorOptions{
MaxPendingBlocks: maxPendingBlocksDefault,
MaxHeightDelta: maxHeightDeltaDefault,
MaxPendingTransactions: maxPendingTransactionsDefault,
DelayThreshold: delayThresholdDefault,
DelayTimeout: delayTimeoutDefault,
ApplicationJobs: min(applicationJobsDefault, runtime.NumCPU()),
ForceChildRequestThreshold: forceChildRequestThresholdDefault,
ForceApplicationRetryDelay: forceApplicationRetryDelayDefault,
TransactionExpiration: transactionExpirationDefault,
}
}
Loading

0 comments on commit 71aa138

Please sign in to comment.