69 Commits
Author SHA1 Message Date
Hanzo Dev ced5a60274 Update import path 2025-07-31 17:10:10 -05:00
cocoyealandGitHub f03f192235 event: fix typo (#29749)
typo: of -> or
2024-05-10 19:44:07 +02:00
InphiandGitHub 0f38933615 event: fix Resubscribe deadlock when unsubscribing after inner sub ends (#28359)
A goroutine is used to manage the lifetime of subscriptions managed by
resubscriptions. When the subscription ends with no error, the resub
goroutine ends as well. However, the resub goroutine needs to live
long enough to read from the unsub channel. Otheriwse, an Unsubscribe
call deadlocks when writing to the unsub channel.

This is fixed by adding a buffer to the unsub channel.
2023-10-22 17:37:56 +02:00
Péter SzilágyiandGitHub 3ad8ea86f8 all: move main transaction pool into a subpool (#27463)
* all: move main transaction pool into a subpool

* go.mod: remove superfluous updates

* core/txpool: review fixes, handle txs rejected by all subpools

* core/txpool: typos
2023-06-16 15:29:40 +03:00
e6c8ec3acd event: move type fixation logic into Feed.init (#27249)
This is a minor optimization/refactoring of Feed.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2023-05-30 16:34:32 +02:00
DelwengandGitHub 94a6967947 ethclient,event: replace noarg fmt.Errorf with errors.New (#27334)
Signed-off-by: jsvisa <delweng@gmail.com>
2023-05-24 12:39:49 +02:00
ucwongandGitHub 0e09a3142d event: initialize maps with known size (#27233)
event: initialize maps with known size
2023-05-09 15:29:32 -04:00
Péter SzilágyiandGitHub 59c42340d9 README, go.mod, event, internal/version: bump min Go to 1.19 (#26803) 2023-03-03 12:24:09 +02:00
Martin Holst SwendeandGitHub 0b9467e2af all: remove deprecated uses of math.rand (#26710)
This PR is a (superior) alternative to https://github.com/ethereum/go-ethereum/pull/26708, it handles deprecation, primarily two specific cases. 

`rand.Seed` is typically used in two ways
- `rand.Seed(time.Now().UnixNano())` -- we seed it, just to be sure to get some random, and not always get the same thing on every run. This is not needed, with global seeding, so those are just removed. 
- `rand.Seed(1)` this is typically done to ensure we have a stable test. If we rely on this, we need to fix up the tests to use a deterministic prng-source. A few occurrences like this has been replaced with a proper custom source. 

`rand.Read` has been replaced by `crypto/rand`.`Read` in this PR.
2023-02-16 14:36:58 -05:00
Felix LangeandGitHub 7c0fdc1986 event: add FeedOf[T] (#26310)
This PR adds a new type event.FeedOf[T], which is like event.Feed but parameterized
over the channel element type. Performance is unchanged, and it still uses reflect. But
unlike Feed, the generic version doesn't need to type-check interface{} arguments.
All panic cases are gone from the API.
2022-12-09 16:20:46 +01:00
244e6ccc1a event: add ResubscribeErr (#22191)
This adds a way to get the error of the failing subscription
for logging/debugging purposes.

Co-authored-by: Felix Lange <fjl@twurst.com>
2021-01-21 13:47:38 +01:00
Alex PrutandGitHub 8d2224fefa all: remove redundant conversions and import names (#21903) 2020-11-25 21:00:23 +01:00
ucwongandGitHub 74c72aa78b event, whisper/whisperv6: use defer where possible (#20940) 2020-04-28 10:53:08 +02:00
4a121d9544 event: fix inconsistency in Lock and Unlock (#20933)
Co-authored-by: Felix Lange <fjl@twurst.com>
2020-04-17 14:51:38 +02:00
8f29e57314 all: fix a bunch of inconsequential goroutine leaks (#20667)
The leaks were mostly in unit tests, and could all be resolved by
adding suitably-sized channel buffers or by restructuring the test
to not send on a channel after an error has occurred.

There is an unavoidable goroutine leak in Console.Interactive: when
we receive a signal, the line reader cannot be unblocked and will get
stuck. This leak is now documented and I've tried to make it slightly 
less bad by adding a one-element buffer to the output channels of
the line-reading loop. Should the reader eventually awake from its
blocked state (i.e. when stdin is closed), at least it won't get stuck
trying to send to the interpreter loop which has quit long ago.

Co-authored-by: Felix Lange <fjl@twurst.com>
2020-04-03 20:07:22 +02:00
ucwongandGitHub c60a4baea2 event: add missing timer.Stop call in TestFeed (#20868) 2020-04-02 15:56:25 +02:00
898785977d event, p2p/simulations/adapters: fix rare goroutine leaks (#20657)
Co-authored-by: Felix Lange <fjl@twurst.com>
2020-02-12 15:19:47 +01:00
Boqin QinandGitHub 6baf2b4b42 event: add missing unlock before panic (#20653) 2020-02-12 10:33:31 +01:00
Felix LangeandPéter Szilágyi 44e4b315ba event: remove unused field 'closed' (#20324) 2019-11-19 16:00:32 +02:00
Felix LangeandPéter Szilágyi 4d27153d22 event/filter: delete unused package (#18063) 2018-11-08 14:26:29 +02:00
Corey LinandFelix Lange 2b28c5fc0e event, event/filter: minor code cleanup (#18061) 2018-11-08 12:17:01 +01:00
Felix LangeandPéter Szilágyi 4416325eec event: document select case slice use and add edge case test (#16680)
Feed keeps active subscription channels in a slice called 'f.sendCases'.
The Send method tracks the active cases in a local variable 'cases'
whose value is f.sendCases initially. 'cases' shrinks to a shorter
prefix of f.sendCases every time a send succeeds, moving the successful
case out of range of the active case list.

This can be confusing because the two slices share a backing array. Add
more comments to document what is going on. Also add a test for removing
a case that is in 'f.sentCases' but not 'cases'.
2018-05-10 13:26:36 +03:00
gary rongandPéter Szilágyi 362cc0a819 eth/filter: check nil pointer when unsubscribe (#16682)
* eth/filter: check nil pointer when unsubscribe

* eth/filters, accounts, rpc: abort system if subscribe failed

* eth/filter: add crit log before exit

* eth/filter, event: minor fixes
2018-05-09 11:29:25 +03:00
kiel barryandPéter Szilágyi eeadb3d418 event: golint updates for this or self warning (#16631)
* event/*: golint updates for this or self warning

* event/*: golint updates for this or self warning, pr updated per feedback
2018-05-03 14:54:36 +03:00
Péter Szilágyi d94601f1a0 event: fix datarace between Subscribe and Send 2017-10-20 14:42:19 +03:00
Jia ChenhuiandFelix Lange 1a02069f96 event: fix typo (#15270) 2017-10-10 14:11:15 +02:00
Felix Lange 91a9ae5334 all: update license information 2017-04-14 10:29:00 +02:00
Felix Lange 7ed3a04665 all: import "context" instead of "golang.org/x/net/context"
There is no need to depend on the old context package now that the
minimum Go version is 1.7. The move to "context" eliminates our weird
vendoring setup. Some vendored code still uses golang.org/x/net/context
and it is now vendored in the normal way.

This change triggered new vet checks around context.WithTimeout which
didn't fire with golang.org/x/net/context.
2017-03-22 20:49:15 +01:00
Péter Szilágyi e976d8ca50 event: use sync.Once for init for faster/cleaner locking 2017-02-03 14:04:57 +02:00
Felix LangeandPéter Szilágyi 6f44880d68 event: address review issues (multiple commits)
event: address Feed review issues

event: clarify role of NewSubscription function

event: more Feed review fixes

* take sendLock after dropping f.mu
* add constant for number of special cases

event: fix subscribing/unsubscribing while Send is blocked
2017-02-03 13:37:49 +02:00
Felix Lange 757494850d event: add new Subscription type and related utilities
This commit introduces a new Subscription type, which is synonymous with
ethereum.Subscription. It also adds a couple of utilities that make
working with Subscriptions easier. The mot complex utility is Feed, a
synchronisation device that implements broadcast subscriptions. Feed is
slightly faster than TypeMux and will replace uses of TypeMux across the
go-ethereum codebase in the future.
2017-01-25 18:44:20 +01:00
Felix Lange 6816230e34 event: deprecate TypeMux and related types
The Subscription type is gone, all uses are replaced by
*TypeMuxSubscription. This change is prep-work for the
introduction of the new Subscription type in a later commit.

   gorename -from '"github.com/ethereum/go-ethereum/event"::Event' -to TypeMuxEvent
   gorename -from '"github.com/ethereum/go-ethereum/event"::muxsub' -to TypeMuxSubscription
   gofmt -w -r 'Subscription -> *TypeMuxSubscription' ./event/*.go
   find . -name '*.go' -and -not -regex '\./vendor/.*' \| xargs gofmt -w -r 'event.Subscription -> *event.TypeMuxSubscription'
2017-01-25 16:25:57 +01:00
Felix Lange 87209c66b5 all: gofmt -w -s 2017-01-06 15:52:03 +01:00
Jeffrey Wilcke a6177c607a event: fixed subscribtions to stopped event mux
This fixes an issue where the following would lead to a panic due to a
channel being closed twice:

* Start mux
* Stop mux
* Sub to mux
* Unsub

This is fixed by setting the subscriptions status to closed resulting in
the Unsubscribe to ignore the request when called.
2016-05-12 20:38:09 +02:00
Péter Szilágyi 4b43f533f1 event/filter: fix data race in the test 2015-11-05 16:55:53 +02:00
Péter Szilágyi 0c288e4cf8 core, eth, event, miner, xeth: fix event post / subscription race 2015-10-12 16:22:03 +03:00
Jeffrey Wilcke b26b470db8 core, event/filter, xeth: refactored filter system
Moved the filtering system from `event` to `eth/filters` package and
removed the `core.Filter` object. The `filters.Filter` object now
requires a `common.Database` rather than a `eth.Backend` and invokes the
`core.GetBlockByX` directly rather than thru a "manager".
2015-10-02 22:47:43 +02:00
Felix Lange 6fd6b38189 all: fix license headers one more time
I forgot to update one instance of "go-ethereum" in commit df44ca7fe.
2015-07-23 18:35:11 +02:00
Felix Lange df44ca7fe9 all: update license headers to distiguish GPL/LGPL
All code outside of cmd/ is licensed as LGPL. The headers
now reflect this by calling the whole work "the go-ethereum library".
2015-07-22 18:51:45 +02:00
Felix Lange 8d57b0b7df all: add some godoc synopsis comments 2015-07-07 14:12:45 +02:00
Felix Lange 0695440cbf all: update license information 2015-07-07 14:12:44 +02:00
Péter Szilágyi 505dc3b353 event/filter: hack around data race in the test 2015-06-09 21:33:39 +03:00
obscuren 9ed7f3a17d xeth, core, event/filter, rpc: new block and transaction filters 2015-05-07 14:44:32 +02:00
obscuren 7f46393e83 Improved tx pool to ignore invalid transactions
Transaction pool will attempt to ignore invalid transactions it had
previously encountered.
2015-04-08 00:31:23 +02:00
obscuren 44a9249b24 moved state and vm to core 2015-03-23 16:59:09 +01:00
Taylor Gerring 639617f0ee Merge branch 'rpcxeth' into rpcfrontier
Conflicts:
	rpc/api.go
2015-03-20 15:25:43 +01:00
obscuren 92d9153f2c Listen to tx pre event and trigger 'pending' 2015-03-20 12:07:06 +01:00
Taylor Gerring 72f640d06b Reorg filter logic to XEth 2015-03-19 22:58:07 -04:00
obscuren 588d0dbe21 fixed chain event. Closes #529 2015-03-19 16:19:54 +01:00
obscuren 651be33b07 skipping test 2015-02-23 20:27:00 +01:00