Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
e34e540e
Unverified
Commit
e34e540e
authored
Nov 14, 2022
by
Martin Holst Swende
Committed by
GitHub
Nov 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts/keystore: replace inotify with fsnotify (#26176)
parent
8334b5f5
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
39 deletions
+29
-39
watch.go
accounts/keystore/watch.go
+25
-8
go.mod
go.mod
+1
-1
go.sum
go.sum
+3
-30
No files found.
accounts/keystore/watch.go
View file @
e34e540e
...
...
@@ -23,7 +23,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/log"
"github.com/
rjeczalik/
notify"
"github.com/
fsnotify/fs
notify"
)
type
watcher
struct
{
...
...
@@ -31,14 +31,12 @@ type watcher struct {
running
bool
// set to true when runloop begins
runEnded
bool
// set to true when runloop ends
starting
bool
// set to true prior to runloop starting
ev
chan
notify
.
EventInfo
quit
chan
struct
{}
}
func
newWatcher
(
ac
*
accountCache
)
*
watcher
{
return
&
watcher
{
ac
:
ac
,
ev
:
make
(
chan
notify
.
EventInfo
,
10
),
quit
:
make
(
chan
struct
{}),
}
}
...
...
@@ -71,12 +69,19 @@ func (w *watcher) loop() {
}()
logger
:=
log
.
New
(
"path"
,
w
.
ac
.
keydir
)
if
err
:=
notify
.
Watch
(
w
.
ac
.
keydir
,
w
.
ev
,
notify
.
All
);
err
!=
nil
{
logger
.
Trace
(
"Failed to watch keystore folder"
,
"err"
,
err
)
// Create new watcher.
watcher
,
err
:=
fsnotify
.
NewWatcher
()
if
err
!=
nil
{
log
.
Error
(
"Failed to start filesystem watcher"
,
"err"
,
err
)
return
}
defer
notify
.
Stop
(
w
.
ev
)
logger
.
Trace
(
"Started watching keystore folder"
)
defer
watcher
.
Close
()
if
err
:=
watcher
.
Add
(
w
.
ac
.
keydir
);
err
!=
nil
{
logger
.
Warn
(
"Failed to watch keystore folder"
,
"err"
,
err
)
return
}
logger
.
Trace
(
"Started watching keystore folder"
,
"folder"
,
w
.
ac
.
keydir
)
defer
logger
.
Trace
(
"Stopped watching keystore folder"
)
w
.
ac
.
mu
.
Lock
()
...
...
@@ -100,12 +105,24 @@ func (w *watcher) loop() {
select
{
case
<-
w
.
quit
:
return
case
<-
w
.
ev
:
case
_
,
ok
:=
<-
watcher
.
Events
:
if
!
ok
{
return
}
// Trigger the scan (with delay), if not already triggered
if
!
rescanTriggered
{
debounce
.
Reset
(
debounceDuration
)
rescanTriggered
=
true
}
// The fsnotify library does provide more granular event-info, it
// would be possible to refresh individual affected files instead
// of scheduling a full rescan. For most cases though, the
// full rescan is quick and obviously simplest.
case
err
,
ok
:=
<-
watcher
.
Errors
:
if
!
ok
{
return
}
log
.
Info
(
"Filsystem watcher error"
,
"err"
,
err
)
case
<-
debounce
.
C
:
w
.
ac
.
scanAccounts
()
rescanTriggered
=
false
...
...
go.mod
View file @
e34e540e
...
...
@@ -21,6 +21,7 @@ require (
github.com/fatih/color v1.7.0
github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5
github.com/fsnotify/fsnotify v1.6.0
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff
github.com/gballet/go-verkle v0.0.0-20220902153445-097bd83b7732
github.com/go-stack/stack v1.8.1
...
...
@@ -49,7 +50,6 @@ require (
github.com/olekukonko/tablewriter v0.0.5
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7
github.com/prometheus/tsdb v0.7.1
github.com/rjeczalik/notify v0.9.1
github.com/rs/cors v1.7.0
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible
github.com/status-im/keycard-go v0.2.0
...
...
go.sum
View file @
e34e540e
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment