diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-10-20 20:21:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-20 20:21:54 +0800 |
commit | 479aa61f11724560c63a7b56084259552892819d (patch) | |
tree | f21465975f55507e85f8a3cebc7440371b266c30 /event | |
parent | eaa4f8a5f925592bd777d5b0daf635bec85f6242 (diff) | |
parent | 0af1ab0c86975201349d92e0943485c3534d8c8c (diff) | |
download | dexon-479aa61f11724560c63a7b56084259552892819d.tar dexon-479aa61f11724560c63a7b56084259552892819d.tar.gz dexon-479aa61f11724560c63a7b56084259552892819d.tar.bz2 dexon-479aa61f11724560c63a7b56084259552892819d.tar.lz dexon-479aa61f11724560c63a7b56084259552892819d.tar.xz dexon-479aa61f11724560c63a7b56084259552892819d.tar.zst dexon-479aa61f11724560c63a7b56084259552892819d.zip |
Merge pull request #15343 from karalabe/txpool-replacement-propagation
core: fire tx event on replace, expand tests
Diffstat (limited to 'event')
-rw-r--r-- | event/feed.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/event/feed.go b/event/feed.go index b1b597f17..78fa3d98d 100644 --- a/event/feed.go +++ b/event/feed.go @@ -127,6 +127,8 @@ func (f *Feed) remove(sub *feedSub) { // Send delivers to all subscribed channels simultaneously. // It returns the number of subscribers that the value was sent to. func (f *Feed) Send(value interface{}) (nsent int) { + rvalue := reflect.ValueOf(value) + f.once.Do(f.init) <-f.sendLock @@ -134,14 +136,14 @@ func (f *Feed) Send(value interface{}) (nsent int) { f.mu.Lock() f.sendCases = append(f.sendCases, f.inbox...) f.inbox = nil - f.mu.Unlock() - // Set the sent value on all channels. - rvalue := reflect.ValueOf(value) if !f.typecheck(rvalue.Type()) { f.sendLock <- struct{}{} panic(feedTypeError{op: "Send", got: rvalue.Type(), want: f.etype}) } + f.mu.Unlock() + + // Set the sent value on all channels. for i := firstSubSendCase; i < len(f.sendCases); i++ { f.sendCases[i].Send = rvalue } |