mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
fix after reviewing
This commit is contained in:
parent
9fc966c7db
commit
7ebdbeed64
6 changed files with 19 additions and 14 deletions
|
|
@ -457,6 +457,8 @@ func (pool *TxPool) SubscribeTxPreEvent(ch chan<- TxPreEvent) event.Subscription
|
|||
return pool.scope.Track(pool.txFeed.Subscribe(ch))
|
||||
}
|
||||
|
||||
// SubscribeSpecialTxPreEvent registers a subscription of TxPreEvent and
|
||||
// starts sending event to the given channel.
|
||||
func (pool *TxPool) SubscribeSpecialTxPreEvent(ch chan<- TxPreEvent) event.Subscription {
|
||||
return pool.scope.Track(pool.specialTxFeed.Subscribe(ch))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,11 +268,10 @@ func (tx *Transaction) RawSignatureValues() (*big.Int, *big.Int, *big.Int) {
|
|||
}
|
||||
|
||||
func (tx *Transaction) IsSpecialTransaction() bool {
|
||||
to := ""
|
||||
if tx.To() != nil {
|
||||
to = tx.To().String()
|
||||
if tx.To() == nil {
|
||||
return false
|
||||
}
|
||||
return to == common.RandomizeSMC || to == common.BlockSigners
|
||||
return tx.To().String() == common.RandomizeSMC || tx.To().String() == common.BlockSigners
|
||||
}
|
||||
|
||||
func (tx *Transaction) String() string {
|
||||
|
|
@ -403,6 +402,8 @@ type TransactionsByPriceAndNonce struct {
|
|||
//
|
||||
// Note, the input map is reowned so the caller should not interact any more with
|
||||
// if after providing it to the constructor.
|
||||
|
||||
// It also classifies special txs and normal txs
|
||||
func NewTransactionsByPriceAndNonce(signer Signer, txs map[common.Address]Transactions) (*TransactionsByPriceAndNonce, Transactions) {
|
||||
// Initialize a price based heap with the head transactions
|
||||
heads := TxByPrice{}
|
||||
|
|
@ -500,4 +501,4 @@ func (m Message) Value() *big.Int { return m.amount }
|
|||
func (m Message) Gas() uint64 { return m.gasLimit }
|
||||
func (m Message) Nonce() uint64 { return m.nonce }
|
||||
func (m Message) Data() []byte { return m.data }
|
||||
func (m Message) CheckNonce() bool { return m.checkNonce }
|
||||
func (m Message) CheckNonce() bool { return m.checkNonce
|
||||
|
|
@ -210,6 +210,7 @@ func (pm *ProtocolManager) Start(maxPeers int) {
|
|||
pm.txSub = pm.txpool.SubscribeTxPreEvent(pm.txCh)
|
||||
go pm.txBroadcastLoop()
|
||||
|
||||
// broadcast special transactions
|
||||
pm.specialTxCh = make(chan core.TxPreEvent, txChanSize)
|
||||
pm.specialTxSub = pm.txpool.SubscribeSpecialTxPreEvent(pm.specialTxCh)
|
||||
go pm.specialTxBroadcastLoop()
|
||||
|
|
|
|||
14
eth/peer.go
14
eth/peer.go
|
|
@ -55,7 +55,8 @@ type peer struct {
|
|||
id string
|
||||
|
||||
*p2p.Peer
|
||||
rw p2p.MsgReadWriter
|
||||
rw p2p.MsgReadWriter
|
||||
pairRw p2p.MsgReadWriter
|
||||
|
||||
version int // Protocol version negotiated
|
||||
forkDrop *time.Timer // Timed connection dropper if forks aren't validated in time
|
||||
|
|
@ -66,7 +67,6 @@ type peer struct {
|
|||
|
||||
knownTxs *set.Set // Set of transaction hashes known to be known by this peer
|
||||
knownBlocks *set.Set // Set of block hashes known to be known by this peer
|
||||
pairRw p2p.MsgReadWriter
|
||||
}
|
||||
|
||||
func newPeer(version int, p *p2p.Peer, rw p2p.MsgReadWriter) *peer {
|
||||
|
|
@ -338,13 +338,13 @@ func (ps *peerSet) Register(p *peer) error {
|
|||
if ps.closed {
|
||||
return errClosed
|
||||
}
|
||||
if exitPeer, ok := ps.peers[p.id]; ok {
|
||||
if exitPeer.pairRw != nil {
|
||||
if existPeer, ok := ps.peers[p.id]; ok {
|
||||
if existPeer.pairRw != nil {
|
||||
return errAlreadyRegistered
|
||||
}
|
||||
exitPeer.PairPeer = p.Peer
|
||||
exitPeer.pairRw = p.rw
|
||||
p.PairPeer = exitPeer.Peer
|
||||
existPeer.PairPeer = p.Peer
|
||||
existPeer.pairRw = p.rw
|
||||
p.PairPeer = existPeer.Peer
|
||||
return p2p.ErrAddPairPeer
|
||||
}
|
||||
ps.peers[p.id] = p
|
||||
|
|
|
|||
|
|
@ -627,6 +627,7 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB
|
|||
|
||||
var coalescedLogs []*types.Log
|
||||
|
||||
// first priority for special Txs
|
||||
for _, tx := range specialTxs {
|
||||
if gp.Gas() < params.TxGas && tx.Gas() > 0 {
|
||||
log.Trace("Not enough gas for further transactions", "gp", gp)
|
||||
|
|
|
|||
|
|
@ -266,8 +266,8 @@ func (s *dialstate) checkDial(n *discover.Node, peers map[discover.NodeID]*Peer)
|
|||
case dialing:
|
||||
return errAlreadyDialing
|
||||
case peers[n.ID] != nil:
|
||||
exitPeer := peers[n.ID]
|
||||
if exitPeer.PairPeer != nil {
|
||||
exitsPeer := peers[n.ID]
|
||||
if exitsPeer.PairPeer != nil {
|
||||
return errAlreadyConnected
|
||||
}
|
||||
case s.ntab != nil && n.ID == s.ntab.Self().ID:
|
||||
|
|
|
|||
Loading…
Reference in a new issue