Bypass rate limiter for sendrawtransaction.
ok @davecgh
This commit is contained in:
parent
75bb52d715
commit
8a322e4792
3 changed files with 10 additions and 10 deletions
|
@ -444,7 +444,7 @@ func (b *blockManager) handleTxMsg(tmsg *txMsg) {
|
||||||
|
|
||||||
// Process the transaction to include validation, insertion in the
|
// Process the transaction to include validation, insertion in the
|
||||||
// memory pool, orphan handling, etc.
|
// memory pool, orphan handling, etc.
|
||||||
err := tmsg.peer.server.txMemPool.ProcessTransaction(tmsg.tx, true)
|
err := tmsg.peer.server.txMemPool.ProcessTransaction(tmsg.tx, true, true)
|
||||||
|
|
||||||
// Remove transaction from request maps. Either the mempool/chain
|
// Remove transaction from request maps. Either the mempool/chain
|
||||||
// already knows about it and as such we shouldn't have any more
|
// already knows about it and as such we shouldn't have any more
|
||||||
|
@ -1086,7 +1086,7 @@ func (b *blockManager) handleNotifyMsg(notification *btcchain.Notification) {
|
||||||
// Reinsert all of the transactions (except the coinbase) into
|
// Reinsert all of the transactions (except the coinbase) into
|
||||||
// the transaction pool.
|
// the transaction pool.
|
||||||
for _, tx := range block.Transactions()[1:] {
|
for _, tx := range block.Transactions()[1:] {
|
||||||
err := b.server.txMemPool.MaybeAcceptTransaction(tx, nil, false)
|
err := b.server.txMemPool.MaybeAcceptTransaction(tx, nil, false, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Remove the transaction and all transactions
|
// Remove the transaction and all transactions
|
||||||
// that depend on it if it wasn't accepted into
|
// that depend on it if it wasn't accepted into
|
||||||
|
|
14
mempool.go
14
mempool.go
|
@ -724,7 +724,7 @@ func (mp *txMemPool) FetchTransaction(txHash *btcwire.ShaHash) (*btcutil.Tx, err
|
||||||
// more details.
|
// more details.
|
||||||
//
|
//
|
||||||
// This function MUST be called with the mempool lock held (for writes).
|
// This function MUST be called with the mempool lock held (for writes).
|
||||||
func (mp *txMemPool) maybeAcceptTransaction(tx *btcutil.Tx, isOrphan *bool, isNew bool) error {
|
func (mp *txMemPool) maybeAcceptTransaction(tx *btcutil.Tx, isOrphan *bool, isNew, rateLimit bool) error {
|
||||||
if isOrphan != nil {
|
if isOrphan != nil {
|
||||||
*isOrphan = false
|
*isOrphan = false
|
||||||
}
|
}
|
||||||
|
@ -867,7 +867,7 @@ func (mp *txMemPool) maybeAcceptTransaction(tx *btcutil.Tx, isOrphan *bool, isNe
|
||||||
|
|
||||||
// Free-to-relay transactions are rate limited here to prevent
|
// Free-to-relay transactions are rate limited here to prevent
|
||||||
// penny-flooding with tiny transactions as a form of attack.
|
// penny-flooding with tiny transactions as a form of attack.
|
||||||
if minRequiredFee == 0 {
|
if rateLimit && minRequiredFee == 0 {
|
||||||
nowUnix := time.Now().Unix()
|
nowUnix := time.Now().Unix()
|
||||||
// we decay passed data with an exponentially decaying ~10
|
// we decay passed data with an exponentially decaying ~10
|
||||||
// minutes window - matches bitcoind handling.
|
// minutes window - matches bitcoind handling.
|
||||||
|
@ -919,12 +919,12 @@ func (mp *txMemPool) maybeAcceptTransaction(tx *btcutil.Tx, isOrphan *bool, isNe
|
||||||
// or not the transaction is an orphan.
|
// or not the transaction is an orphan.
|
||||||
//
|
//
|
||||||
// This function is safe for concurrent access.
|
// This function is safe for concurrent access.
|
||||||
func (mp *txMemPool) MaybeAcceptTransaction(tx *btcutil.Tx, isOrphan *bool, isNew bool) error {
|
func (mp *txMemPool) MaybeAcceptTransaction(tx *btcutil.Tx, isOrphan *bool, isNew, rateLimit bool) error {
|
||||||
// Protect concurrent access.
|
// Protect concurrent access.
|
||||||
mp.Lock()
|
mp.Lock()
|
||||||
defer mp.Unlock()
|
defer mp.Unlock()
|
||||||
|
|
||||||
return mp.maybeAcceptTransaction(tx, isOrphan, isNew)
|
return mp.maybeAcceptTransaction(tx, isOrphan, isNew, rateLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
// processOrphans determines if there are any orphans which depend on the passed
|
// processOrphans determines if there are any orphans which depend on the passed
|
||||||
|
@ -964,7 +964,7 @@ func (mp *txMemPool) processOrphans(hash *btcwire.ShaHash) error {
|
||||||
// Potentially accept the transaction into the
|
// Potentially accept the transaction into the
|
||||||
// transaction pool.
|
// transaction pool.
|
||||||
var isOrphan bool
|
var isOrphan bool
|
||||||
err := mp.maybeAcceptTransaction(tx, &isOrphan, true)
|
err := mp.maybeAcceptTransaction(tx, &isOrphan, true, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -993,7 +993,7 @@ func (mp *txMemPool) processOrphans(hash *btcwire.ShaHash) error {
|
||||||
// rules, orphan transaction handling, and insertion into the memory pool.
|
// rules, orphan transaction handling, and insertion into the memory pool.
|
||||||
//
|
//
|
||||||
// This function is safe for concurrent access.
|
// This function is safe for concurrent access.
|
||||||
func (mp *txMemPool) ProcessTransaction(tx *btcutil.Tx, allowOrphan bool) error {
|
func (mp *txMemPool) ProcessTransaction(tx *btcutil.Tx, allowOrphan, rateLimit bool) error {
|
||||||
// Protect concurrent access.
|
// Protect concurrent access.
|
||||||
mp.Lock()
|
mp.Lock()
|
||||||
defer mp.Unlock()
|
defer mp.Unlock()
|
||||||
|
@ -1002,7 +1002,7 @@ func (mp *txMemPool) ProcessTransaction(tx *btcutil.Tx, allowOrphan bool) error
|
||||||
|
|
||||||
// Potentially accept the transaction to the memory pool.
|
// Potentially accept the transaction to the memory pool.
|
||||||
var isOrphan bool
|
var isOrphan bool
|
||||||
err := mp.maybeAcceptTransaction(tx, &isOrphan, true)
|
err := mp.maybeAcceptTransaction(tx, &isOrphan, true, rateLimit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1381,7 +1381,7 @@ func handleSendRawTransaction(s *rpcServer, cmd btcjson.Cmd) (interface{}, error
|
||||||
}
|
}
|
||||||
|
|
||||||
tx := btcutil.NewTx(msgtx)
|
tx := btcutil.NewTx(msgtx)
|
||||||
err = s.server.txMemPool.ProcessTransaction(tx, false)
|
err = s.server.txMemPool.ProcessTransaction(tx, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// When the error is a rule error, it means the transaction was
|
// When the error is a rule error, it means the transaction was
|
||||||
// simply rejected as opposed to something actually going wrong,
|
// simply rejected as opposed to something actually going wrong,
|
||||||
|
|
Loading…
Add table
Reference in a new issue