mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth/catalyst: implement getLocalTransaction, setLocalAccounts
This commit is contained in:
parent
593e303485
commit
38dc29b3e1
3 changed files with 36 additions and 0 deletions
|
|
@ -1955,3 +1955,8 @@ func (t *lookup) RemotesBelowTip(threshold *big.Int) types.Transactions {
|
||||||
func numSlots(tx *types.Transaction) int {
|
func numSlots(tx *types.Transaction) int {
|
||||||
return int((tx.Size() + txSlotSize - 1) / txSlotSize)
|
return int((tx.Size() + txSlotSize - 1) / txSlotSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *LegacyPool) AddLocalAddr(addr common.Address) {
|
||||||
|
p.locals.add(addr)
|
||||||
|
// TODO go through all txs to mark as local now
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
"github.com/ethereum/go-ethereum/core/txpool/legacypool"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
|
@ -465,6 +466,14 @@ func (p *TxPool) Status(hash common.Hash) TxStatus {
|
||||||
return TxStatusUnknown
|
return TxStatusUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *TxPool) MarkLocal(addr common.Address) {
|
||||||
|
for _, pool := range p.subpools {
|
||||||
|
if sub, ok := pool.(*legacypool.LegacyPool); ok {
|
||||||
|
sub.AddLocalAddr(addr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Sync is a helper method for unit tests or simulator runs where the chain events
|
// Sync is a helper method for unit tests or simulator runs where the chain events
|
||||||
// are arriving in quick succession, without any time in between them to run the
|
// are arriving in quick succession, without any time in between them to run the
|
||||||
// internal background reset operations. This method will run an explicit reset
|
// internal background reset operations. This method will run an explicit reset
|
||||||
|
|
|
||||||
|
|
@ -893,3 +893,25 @@ func getBody(block *types.Block) *engine.ExecutionPayloadBodyV1 {
|
||||||
Withdrawals: withdrawals,
|
Withdrawals: withdrawals,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ConsensusAPI) SetLocalAccounts(locals []common.Address) error {
|
||||||
|
for _, addr := range locals {
|
||||||
|
c.eth.TxPool().MarkLocal(addr)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ConsensusAPI) GetLocalTransactions() ([][]byte, error) {
|
||||||
|
var res [][]byte
|
||||||
|
for _, addr := range c.eth.TxPool().Locals() {
|
||||||
|
pending, _ := c.eth.TxPool().ContentFrom(addr)
|
||||||
|
for _, tx := range pending {
|
||||||
|
m, err := tx.MarshalJSON()
|
||||||
|
if err != nil {
|
||||||
|
return [][]byte{}, nil
|
||||||
|
}
|
||||||
|
res = append(res, m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue