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
|
||||
// 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
|
||||
// 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
|
||||
// the transaction pool.
|
||||
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 {
|
||||
// Remove the transaction and all transactions
|
||||
// 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.
|
||||
//
|
||||
// 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 {
|
||||
*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
|
||||
// penny-flooding with tiny transactions as a form of attack.
|
||||
if minRequiredFee == 0 {
|
||||
if rateLimit && minRequiredFee == 0 {
|
||||
nowUnix := time.Now().Unix()
|
||||
// we decay passed data with an exponentially decaying ~10
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
mp.Lock()
|
||||
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
|
||||
|
@ -964,7 +964,7 @@ func (mp *txMemPool) processOrphans(hash *btcwire.ShaHash) error {
|
|||
// Potentially accept the transaction into the
|
||||
// transaction pool.
|
||||
var isOrphan bool
|
||||
err := mp.maybeAcceptTransaction(tx, &isOrphan, true)
|
||||
err := mp.maybeAcceptTransaction(tx, &isOrphan, true, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -993,7 +993,7 @@ func (mp *txMemPool) processOrphans(hash *btcwire.ShaHash) error {
|
|||
// rules, orphan transaction handling, and insertion into the memory pool.
|
||||
//
|
||||
// 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.
|
||||
mp.Lock()
|
||||
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.
|
||||
var isOrphan bool
|
||||
err := mp.maybeAcceptTransaction(tx, &isOrphan, true)
|
||||
err := mp.maybeAcceptTransaction(tx, &isOrphan, true, rateLimit)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1381,7 +1381,7 @@ func handleSendRawTransaction(s *rpcServer, cmd btcjson.Cmd) (interface{}, error
|
|||
}
|
||||
|
||||
tx := btcutil.NewTx(msgtx)
|
||||
err = s.server.txMemPool.ProcessTransaction(tx, false)
|
||||
err = s.server.txMemPool.ProcessTransaction(tx, false, false)
|
||||
if err != nil {
|
||||
// When the error is a rule error, it means the transaction was
|
||||
// simply rejected as opposed to something actually going wrong,
|
||||
|
|
Loading…
Reference in a new issue