mirror of
https://github.com/luxfi/proto.git
synced 2026-10-30 15:21:09 +00:00
Adds .hanzo/workflows/cicd.yml calling the canonical pipeline and drops the GitHub-hosted workflows it replaces. Lands here because this is where the repo is written — git.hanzo.ai is upstream and github.com is its push mirror, so the same change made on github.com never reaches the runner fleet.
77 lines
1.5 KiB
Go
77 lines
1.5 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package executor
|
|
|
|
import (
|
|
"github.com/luxfi/log"
|
|
"github.com/luxfi/proto/p/block"
|
|
vmcore "github.com/luxfi/vm"
|
|
)
|
|
|
|
var _ block.Visitor = (*rejector)(nil)
|
|
|
|
// rejector handles the logic for rejecting a block.
|
|
// All errors returned by this struct are fatal and should result in the chain
|
|
// being shutdown.
|
|
type rejector struct {
|
|
*backend
|
|
toEngine chan<- vmcore.Message
|
|
addTxsToMempool bool
|
|
}
|
|
|
|
func (r *rejector) AbortBlock(b *block.AbortBlock) error {
|
|
return r.rejectBlock(b, "abort")
|
|
}
|
|
|
|
func (r *rejector) CommitBlock(b *block.CommitBlock) error {
|
|
return r.rejectBlock(b, "commit")
|
|
}
|
|
|
|
func (r *rejector) ProposalBlock(b *block.ProposalBlock) error {
|
|
return r.rejectBlock(b, "proposal")
|
|
}
|
|
|
|
func (r *rejector) StandardBlock(b *block.StandardBlock) error {
|
|
return r.rejectBlock(b, "standard")
|
|
}
|
|
|
|
func (r *rejector) rejectBlock(b block.Block, blockType string) error {
|
|
blkID := b.ID()
|
|
defer r.free(blkID)
|
|
|
|
log.Debug(
|
|
"rejecting block",
|
|
"blockType", blockType,
|
|
"blkID", blkID,
|
|
"height", b.Height(),
|
|
"parentID", b.Parent(),
|
|
)
|
|
|
|
if !r.addTxsToMempool {
|
|
return nil
|
|
}
|
|
|
|
for _, tx := range b.Txs() {
|
|
if err := r.Mempool.Add(tx); err != nil {
|
|
log.Debug(
|
|
"failed to reissue tx",
|
|
"txID", tx.ID(),
|
|
"blkID", blkID,
|
|
"error", err,
|
|
)
|
|
}
|
|
}
|
|
|
|
if r.Mempool.Len() == 0 {
|
|
return nil
|
|
}
|
|
|
|
select {
|
|
case r.toEngine <- vmcore.Message{Type: vmcore.PendingTxs}:
|
|
default:
|
|
}
|
|
|
|
return nil
|
|
}
|