@ -124,8 +124,8 @@ const (
PendingLogsSubscription
PendingLogsSubscription
// MinedAndPendingLogsSubscription queries for logs in mined and pending blocks.
// MinedAndPendingLogsSubscription queries for logs in mined and pending blocks.
MinedAndPendingLogsSubscription
MinedAndPendingLogsSubscription
// PendingTransactionsSubscription queries tx hashes for pending
// PendingTransactionsSubscription queries for pending transactions enter ing
// transactions entering t he pending state
// the pending state
PendingTransactionsSubscription
PendingTransactionsSubscription
// BlocksSubscription queries hashes for blocks that are imported
// BlocksSubscription queries hashes for blocks that are imported
BlocksSubscription
BlocksSubscription
@ -151,7 +151,7 @@ type subscription struct {
created time . Time
created time . Time
logsCrit ethereum . FilterQuery
logsCrit ethereum . FilterQuery
logs chan [ ] * types . Log
logs chan [ ] * types . Log
hashes chan [ ] common . Hash
txs chan [ ] * types . Transaction
headers chan * types . Header
headers chan * types . Header
installed chan struct { } // closed when the filter is installed
installed chan struct { } // closed when the filter is installed
err chan error // closed when the filter is uninstalled
err chan error // closed when the filter is uninstalled
@ -244,7 +244,7 @@ func (sub *Subscription) Unsubscribe() {
case sub . es . uninstall <- sub . f :
case sub . es . uninstall <- sub . f :
break uninstallLoop
break uninstallLoop
case <- sub . f . logs :
case <- sub . f . logs :
case <- sub . f . hashe s:
case <- sub . f . tx s:
case <- sub . f . headers :
case <- sub . f . headers :
}
}
}
}
@ -311,7 +311,7 @@ func (es *EventSystem) subscribeMinedPendingLogs(crit ethereum.FilterQuery, logs
logsCrit : crit ,
logsCrit : crit ,
created : time . Now ( ) ,
created : time . Now ( ) ,
logs : logs ,
logs : logs ,
hashes : make ( chan [ ] common . Hash ) ,
txs : make ( chan [ ] * types . Transaction ) ,
headers : make ( chan * types . Header ) ,
headers : make ( chan * types . Header ) ,
installed : make ( chan struct { } ) ,
installed : make ( chan struct { } ) ,
err : make ( chan error ) ,
err : make ( chan error ) ,
@ -328,7 +328,7 @@ func (es *EventSystem) subscribeLogs(crit ethereum.FilterQuery, logs chan []*typ
logsCrit : crit ,
logsCrit : crit ,
created : time . Now ( ) ,
created : time . Now ( ) ,
logs : logs ,
logs : logs ,
hashes : make ( chan [ ] common . Hash ) ,
txs : make ( chan [ ] * types . Transaction ) ,
headers : make ( chan * types . Header ) ,
headers : make ( chan * types . Header ) ,
installed : make ( chan struct { } ) ,
installed : make ( chan struct { } ) ,
err : make ( chan error ) ,
err : make ( chan error ) ,
@ -345,7 +345,7 @@ func (es *EventSystem) subscribePendingLogs(crit ethereum.FilterQuery, logs chan
logsCrit : crit ,
logsCrit : crit ,
created : time . Now ( ) ,
created : time . Now ( ) ,
logs : logs ,
logs : logs ,
hashes : make ( chan [ ] common . Hash ) ,
txs : make ( chan [ ] * types . Transaction ) ,
headers : make ( chan * types . Header ) ,
headers : make ( chan * types . Header ) ,
installed : make ( chan struct { } ) ,
installed : make ( chan struct { } ) ,
err : make ( chan error ) ,
err : make ( chan error ) ,
@ -361,7 +361,7 @@ func (es *EventSystem) SubscribeNewHeads(headers chan *types.Header) *Subscripti
typ : BlocksSubscription ,
typ : BlocksSubscription ,
created : time . Now ( ) ,
created : time . Now ( ) ,
logs : make ( chan [ ] * types . Log ) ,
logs : make ( chan [ ] * types . Log ) ,
hashes : make ( chan [ ] common . Hash ) ,
txs : make ( chan [ ] * types . Transaction ) ,
headers : headers ,
headers : headers ,
installed : make ( chan struct { } ) ,
installed : make ( chan struct { } ) ,
err : make ( chan error ) ,
err : make ( chan error ) ,
@ -369,15 +369,15 @@ func (es *EventSystem) SubscribeNewHeads(headers chan *types.Header) *Subscripti
return es . subscribe ( sub )
return es . subscribe ( sub )
}
}
// SubscribePendingTxs creates a subscription that writes transaction hashe s for
// SubscribePendingTxs creates a subscription that writes transactions for
// transactions that enter the transaction pool.
// transactions that enter the transaction pool.
func ( es * EventSystem ) SubscribePendingTxs ( hashes chan [ ] common . Hash ) * Subscription {
func ( es * EventSystem ) SubscribePendingTxs ( txs chan [ ] * types . Transaction ) * Subscription {
sub := & subscription {
sub := & subscription {
id : rpc . NewID ( ) ,
id : rpc . NewID ( ) ,
typ : PendingTransactionsSubscription ,
typ : PendingTransactionsSubscription ,
created : time . Now ( ) ,
created : time . Now ( ) ,
logs : make ( chan [ ] * types . Log ) ,
logs : make ( chan [ ] * types . Log ) ,
hashes : hashe s,
txs : tx s,
headers : make ( chan * types . Header ) ,
headers : make ( chan * types . Header ) ,
installed : make ( chan struct { } ) ,
installed : make ( chan struct { } ) ,
err : make ( chan error ) ,
err : make ( chan error ) ,
@ -421,12 +421,8 @@ func (es *EventSystem) handleRemovedLogs(filters filterIndex, ev core.RemovedLog
}
}
func ( es * EventSystem ) handleTxsEvent ( filters filterIndex , ev core . NewTxsEvent ) {
func ( es * EventSystem ) handleTxsEvent ( filters filterIndex , ev core . NewTxsEvent ) {
hashes := make ( [ ] common . Hash , 0 , len ( ev . Txs ) )
for _ , tx := range ev . Txs {
hashes = append ( hashes , tx . Hash ( ) )
}
for _ , f := range filters [ PendingTransactionsSubscription ] {
for _ , f := range filters [ PendingTransactionsSubscription ] {
f . hashes <- hashe s
f . txs <- ev . Txs
}
}
}
}