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
1ff3d7c2
Commit
1ff3d7c2
authored
Nov 29, 2019
by
Guillaume Ballet
Committed by
Felix Lange
Nov 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/faucet, cmd/geth: fix staticcheck warnings (#20374)
parent
08611cfd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
faucet.go
cmd/faucet/faucet.go
+12
-1
retesteth.go
cmd/geth/retesteth.go
+1
-9
No files found.
cmd/faucet/faucet.go
View file @
1ff3d7c2
...
@@ -351,6 +351,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -351,6 +351,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
if
head
==
nil
||
balance
==
nil
{
if
head
==
nil
||
balance
==
nil
{
// Report the faucet offline until initial stats are ready
// Report the faucet offline until initial stats are ready
//lint:ignore ST1005 This error is to be displayed in the browser
if
err
=
sendError
(
conn
,
errors
.
New
(
"Faucet offline"
));
err
!=
nil
{
if
err
=
sendError
(
conn
,
errors
.
New
(
"Faucet offline"
));
err
!=
nil
{
log
.
Warn
(
"Failed to send faucet error to client"
,
"err"
,
err
)
log
.
Warn
(
"Failed to send faucet error to client"
,
"err"
,
err
)
return
return
...
@@ -392,6 +393,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -392,6 +393,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
continue
continue
}
}
if
msg
.
Tier
>=
uint
(
*
tiersFlag
)
{
if
msg
.
Tier
>=
uint
(
*
tiersFlag
)
{
//lint:ignore ST1005 This error is to be displayed in the browser
if
err
=
sendError
(
conn
,
errors
.
New
(
"Invalid funding tier requested"
));
err
!=
nil
{
if
err
=
sendError
(
conn
,
errors
.
New
(
"Invalid funding tier requested"
));
err
!=
nil
{
log
.
Warn
(
"Failed to send tier error to client"
,
"err"
,
err
)
log
.
Warn
(
"Failed to send tier error to client"
,
"err"
,
err
)
return
return
...
@@ -429,6 +431,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -429,6 +431,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
}
}
if
!
result
.
Success
{
if
!
result
.
Success
{
log
.
Warn
(
"Captcha verification failed"
,
"err"
,
string
(
result
.
Errors
))
log
.
Warn
(
"Captcha verification failed"
,
"err"
,
string
(
result
.
Errors
))
//lint:ignore ST1005 it's funny and the robot won't mind
if
err
=
sendError
(
conn
,
errors
.
New
(
"Beep-bop, you're a robot!"
));
err
!=
nil
{
if
err
=
sendError
(
conn
,
errors
.
New
(
"Beep-bop, you're a robot!"
));
err
!=
nil
{
log
.
Warn
(
"Failed to send captcha failure to client"
,
"err"
,
err
)
log
.
Warn
(
"Failed to send captcha failure to client"
,
"err"
,
err
)
return
return
...
@@ -450,6 +453,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -450,6 +453,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
}
}
continue
continue
case
strings
.
HasPrefix
(
msg
.
URL
,
"https://plus.google.com/"
)
:
case
strings
.
HasPrefix
(
msg
.
URL
,
"https://plus.google.com/"
)
:
//lint:ignore ST1005 Google is a company name and should be capitalized.
if
err
=
sendError
(
conn
,
errors
.
New
(
"Google+ authentication discontinued as the service was sunset"
));
err
!=
nil
{
if
err
=
sendError
(
conn
,
errors
.
New
(
"Google+ authentication discontinued as the service was sunset"
));
err
!=
nil
{
log
.
Warn
(
"Failed to send Google+ deprecation to client"
,
"err"
,
err
)
log
.
Warn
(
"Failed to send Google+ deprecation to client"
,
"err"
,
err
)
return
return
...
@@ -462,6 +466,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -462,6 +466,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
case
*
noauthFlag
:
case
*
noauthFlag
:
username
,
avatar
,
address
,
err
=
authNoAuth
(
msg
.
URL
)
username
,
avatar
,
address
,
err
=
authNoAuth
(
msg
.
URL
)
default
:
default
:
//lint:ignore ST1005 This error is to be displayed in the browser
err
=
errors
.
New
(
"Something funky happened, please open an issue at https://github.com/ethereum/go-ethereum/issues"
)
err
=
errors
.
New
(
"Something funky happened, please open an issue at https://github.com/ethereum/go-ethereum/issues"
)
}
}
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -520,7 +525,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -520,7 +525,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
// Send an error if too frequent funding, othewise a success
// Send an error if too frequent funding, othewise a success
if
!
fund
{
if
!
fund
{
if
err
=
sendError
(
conn
,
fmt
.
Errorf
(
"%s left until next allowance"
,
common
.
PrettyDuration
(
time
out
.
Sub
(
time
.
Now
()
))));
err
!=
nil
{
// nolint: gosimple
if
err
=
sendError
(
conn
,
fmt
.
Errorf
(
"%s left until next allowance"
,
common
.
PrettyDuration
(
time
.
Until
(
timeout
))));
err
!=
nil
{
// nolint: gosimple
log
.
Warn
(
"Failed to send funding error to client"
,
"err"
,
err
)
log
.
Warn
(
"Failed to send funding error to client"
,
"err"
,
err
)
return
return
}
}
...
@@ -682,6 +687,7 @@ func authTwitter(url string) (string, string, common.Address, error) {
...
@@ -682,6 +687,7 @@ func authTwitter(url string) (string, string, common.Address, error) {
// Ensure the user specified a meaningful URL, no fancy nonsense
// Ensure the user specified a meaningful URL, no fancy nonsense
parts
:=
strings
.
Split
(
url
,
"/"
)
parts
:=
strings
.
Split
(
url
,
"/"
)
if
len
(
parts
)
<
4
||
parts
[
len
(
parts
)
-
2
]
!=
"status"
{
if
len
(
parts
)
<
4
||
parts
[
len
(
parts
)
-
2
]
!=
"status"
{
//lint:ignore ST1005 This error is to be displayed in the browser
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"Invalid Twitter status URL"
)
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"Invalid Twitter status URL"
)
}
}
// Twitter's API isn't really friendly with direct links. Still, we don't
// Twitter's API isn't really friendly with direct links. Still, we don't
...
@@ -696,6 +702,7 @@ func authTwitter(url string) (string, string, common.Address, error) {
...
@@ -696,6 +702,7 @@ func authTwitter(url string) (string, string, common.Address, error) {
// Resolve the username from the final redirect, no intermediate junk
// Resolve the username from the final redirect, no intermediate junk
parts
=
strings
.
Split
(
res
.
Request
.
URL
.
String
(),
"/"
)
parts
=
strings
.
Split
(
res
.
Request
.
URL
.
String
(),
"/"
)
if
len
(
parts
)
<
4
||
parts
[
len
(
parts
)
-
2
]
!=
"status"
{
if
len
(
parts
)
<
4
||
parts
[
len
(
parts
)
-
2
]
!=
"status"
{
//lint:ignore ST1005 This error is to be displayed in the browser
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"Invalid Twitter status URL"
)
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"Invalid Twitter status URL"
)
}
}
username
:=
parts
[
len
(
parts
)
-
3
]
username
:=
parts
[
len
(
parts
)
-
3
]
...
@@ -706,6 +713,7 @@ func authTwitter(url string) (string, string, common.Address, error) {
...
@@ -706,6 +713,7 @@ func authTwitter(url string) (string, string, common.Address, error) {
}
}
address
:=
common
.
HexToAddress
(
string
(
regexp
.
MustCompile
(
"0x[0-9a-fA-F]{40}"
)
.
Find
(
body
)))
address
:=
common
.
HexToAddress
(
string
(
regexp
.
MustCompile
(
"0x[0-9a-fA-F]{40}"
)
.
Find
(
body
)))
if
address
==
(
common
.
Address
{})
{
if
address
==
(
common
.
Address
{})
{
//lint:ignore ST1005 This error is to be displayed in the browser
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"No Ethereum address found to fund"
)
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"No Ethereum address found to fund"
)
}
}
var
avatar
string
var
avatar
string
...
@@ -721,6 +729,7 @@ func authFacebook(url string) (string, string, common.Address, error) {
...
@@ -721,6 +729,7 @@ func authFacebook(url string) (string, string, common.Address, error) {
// Ensure the user specified a meaningful URL, no fancy nonsense
// Ensure the user specified a meaningful URL, no fancy nonsense
parts
:=
strings
.
Split
(
url
,
"/"
)
parts
:=
strings
.
Split
(
url
,
"/"
)
if
len
(
parts
)
<
4
||
parts
[
len
(
parts
)
-
2
]
!=
"posts"
{
if
len
(
parts
)
<
4
||
parts
[
len
(
parts
)
-
2
]
!=
"posts"
{
//lint:ignore ST1005 This error is to be displayed in the browser
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"Invalid Facebook post URL"
)
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"Invalid Facebook post URL"
)
}
}
username
:=
parts
[
len
(
parts
)
-
3
]
username
:=
parts
[
len
(
parts
)
-
3
]
...
@@ -740,6 +749,7 @@ func authFacebook(url string) (string, string, common.Address, error) {
...
@@ -740,6 +749,7 @@ func authFacebook(url string) (string, string, common.Address, error) {
}
}
address
:=
common
.
HexToAddress
(
string
(
regexp
.
MustCompile
(
"0x[0-9a-fA-F]{40}"
)
.
Find
(
body
)))
address
:=
common
.
HexToAddress
(
string
(
regexp
.
MustCompile
(
"0x[0-9a-fA-F]{40}"
)
.
Find
(
body
)))
if
address
==
(
common
.
Address
{})
{
if
address
==
(
common
.
Address
{})
{
//lint:ignore ST1005 This error is to be displayed in the browser
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"No Ethereum address found to fund"
)
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"No Ethereum address found to fund"
)
}
}
var
avatar
string
var
avatar
string
...
@@ -755,6 +765,7 @@ func authFacebook(url string) (string, string, common.Address, error) {
...
@@ -755,6 +765,7 @@ func authFacebook(url string) (string, string, common.Address, error) {
func
authNoAuth
(
url
string
)
(
string
,
string
,
common
.
Address
,
error
)
{
func
authNoAuth
(
url
string
)
(
string
,
string
,
common
.
Address
,
error
)
{
address
:=
common
.
HexToAddress
(
regexp
.
MustCompile
(
"0x[0-9a-fA-F]{40}"
)
.
FindString
(
url
))
address
:=
common
.
HexToAddress
(
regexp
.
MustCompile
(
"0x[0-9a-fA-F]{40}"
)
.
FindString
(
url
))
if
address
==
(
common
.
Address
{})
{
if
address
==
(
common
.
Address
{})
{
//lint:ignore ST1005 This error is to be displayed in the browser
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"No Ethereum address found to fund"
)
return
""
,
""
,
common
.
Address
{},
errors
.
New
(
"No Ethereum address found to fund"
)
}
}
return
address
.
Hex
()
+
"@noauth"
,
""
,
address
,
nil
return
address
.
Hex
()
+
"@noauth"
,
""
,
address
,
nil
...
...
cmd/geth/retesteth.go
View file @
1ff3d7c2
...
@@ -495,7 +495,6 @@ func (api *RetestethAPI) mineBlock() error {
...
@@ -495,7 +495,6 @@ func (api *RetestethAPI) mineBlock() error {
txCount
:=
0
txCount
:=
0
var
txs
[]
*
types
.
Transaction
var
txs
[]
*
types
.
Transaction
var
receipts
[]
*
types
.
Receipt
var
receipts
[]
*
types
.
Receipt
var
coalescedLogs
[]
*
types
.
Log
var
blockFull
=
gasPool
.
Gas
()
<
params
.
TxGas
var
blockFull
=
gasPool
.
Gas
()
<
params
.
TxGas
for
address
:=
range
api
.
txSenders
{
for
address
:=
range
api
.
txSenders
{
if
blockFull
{
if
blockFull
{
...
@@ -522,7 +521,6 @@ func (api *RetestethAPI) mineBlock() error {
...
@@ -522,7 +521,6 @@ func (api *RetestethAPI) mineBlock() error {
}
}
txs
=
append
(
txs
,
tx
)
txs
=
append
(
txs
,
tx
)
receipts
=
append
(
receipts
,
receipt
)
receipts
=
append
(
receipts
,
receipt
)
coalescedLogs
=
append
(
coalescedLogs
,
receipt
.
Logs
...
)
delete
(
m
,
nonce
)
delete
(
m
,
nonce
)
if
len
(
m
)
==
0
{
if
len
(
m
)
==
0
{
// Last tx for the sender
// Last tx for the sender
...
@@ -682,9 +680,6 @@ func (api *RetestethAPI) AccountRange(ctx context.Context,
...
@@ -682,9 +680,6 @@ func (api *RetestethAPI) AccountRange(ctx context.Context,
for
i
:=
0
;
i
<
int
(
maxResults
)
&&
it
.
Next
();
i
++
{
for
i
:=
0
;
i
<
int
(
maxResults
)
&&
it
.
Next
();
i
++
{
if
preimage
:=
accountTrie
.
GetKey
(
it
.
Key
);
preimage
!=
nil
{
if
preimage
:=
accountTrie
.
GetKey
(
it
.
Key
);
preimage
!=
nil
{
result
.
AddressMap
[
common
.
BytesToHash
(
it
.
Key
)]
=
common
.
BytesToAddress
(
preimage
)
result
.
AddressMap
[
common
.
BytesToHash
(
it
.
Key
)]
=
common
.
BytesToAddress
(
preimage
)
//fmt.Printf("%x: %x\n", it.Key, preimage)
}
else
{
//fmt.Printf("could not find preimage for %x\n", it.Key)
}
}
}
}
//fmt.Printf("Number of entries returned: %d\n", len(result.AddressMap))
//fmt.Printf("Number of entries returned: %d\n", len(result.AddressMap))
...
@@ -808,9 +803,6 @@ func (api *RetestethAPI) StorageRangeAt(ctx context.Context,
...
@@ -808,9 +803,6 @@ func (api *RetestethAPI) StorageRangeAt(ctx context.Context,
Key
:
string
(
ks
),
Key
:
string
(
ks
),
Value
:
string
(
vs
),
Value
:
string
(
vs
),
}
}
//fmt.Printf("Key: %s, Value: %s\n", ks, vs)
}
else
{
//fmt.Printf("Did not find preimage for %x\n", it.Key)
}
}
}
}
if
it
.
Next
()
{
if
it
.
Next
()
{
...
@@ -889,7 +881,7 @@ func retesteth(ctx *cli.Context) error {
...
@@ -889,7 +881,7 @@ func retesteth(ctx *cli.Context) error {
log
.
Info
(
"HTTP endpoint closed"
,
"url"
,
httpEndpoint
)
log
.
Info
(
"HTTP endpoint closed"
,
"url"
,
httpEndpoint
)
}()
}()
abortChan
:=
make
(
chan
os
.
Signal
)
abortChan
:=
make
(
chan
os
.
Signal
,
11
)
signal
.
Notify
(
abortChan
,
os
.
Interrupt
)
signal
.
Notify
(
abortChan
,
os
.
Interrupt
)
sig
:=
<-
abortChan
sig
:=
<-
abortChan
...
...
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