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
d42ce0f2
Commit
d42ce0f2
authored
Jul 30, 2018
by
Oleg Kovalov
Committed by
Péter Szilágyi
Jul 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all: simplify switches (#17267)
* all: simplify switches * silly mistake
parent
273c7a9d
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
20 additions
and
34 deletions
+20
-34
blockchain_test.go
core/blockchain_test.go
+1
-2
filter_system.go
eth/filters/filter_system.go
+1
-2
handler.go
eth/handler.go
+1
-2
tracer.go
eth/tracers/tracer.go
+1
-6
handler.go
les/handler.go
+1
-2
exp.go
metrics/exp/exp.go
+8
-8
natpmp.go
p2p/nat/natpmp.go
+1
-2
natupnp.go
p2p/nat/natupnp.go
+2
-5
inproc.go
p2p/simulations/adapters/inproc.go
+1
-2
abihelper.go
signer/core/abihelper.go
+3
-3
No files found.
core/blockchain_test.go
View file @
d42ce0f2
...
...
@@ -1146,8 +1146,7 @@ func TestEIP155Transition(t *testing.T) {
return
types
.
SignTx
(
types
.
NewTransaction
(
block
.
TxNonce
(
address
),
common
.
Address
{},
new
(
big
.
Int
),
21000
,
new
(
big
.
Int
),
nil
),
signer
,
key
)
}
)
switch
i
{
case
0
:
if
i
==
0
{
tx
,
err
=
basicTx
(
types
.
NewEIP155Signer
(
big
.
NewInt
(
2
)))
if
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
eth/filters/filter_system.go
View file @
d42ce0f2
...
...
@@ -338,8 +338,7 @@ func (es *EventSystem) broadcast(filters filterIndex, ev interface{}) {
}
}
case
*
event
.
TypeMuxEvent
:
switch
muxe
:=
e
.
Data
.
(
type
)
{
case
core
.
PendingLogsEvent
:
if
muxe
,
ok
:=
e
.
Data
.
(
core
.
PendingLogsEvent
);
ok
{
for
_
,
f
:=
range
filters
[
PendingLogsSubscription
]
{
if
e
.
Time
.
After
(
f
.
created
)
{
if
matchedLogs
:=
filterLogs
(
muxe
.
Logs
,
nil
,
f
.
logsCrit
.
ToBlock
,
f
.
logsCrit
.
Addresses
,
f
.
logsCrit
.
Topics
);
len
(
matchedLogs
)
>
0
{
...
...
eth/handler.go
View file @
d42ce0f2
...
...
@@ -744,8 +744,7 @@ func (pm *ProtocolManager) BroadcastTxs(txs types.Transactions) {
func
(
pm
*
ProtocolManager
)
minedBroadcastLoop
()
{
// automatically stops if unsubscribe
for
obj
:=
range
pm
.
minedBlockSub
.
Chan
()
{
switch
ev
:=
obj
.
Data
.
(
type
)
{
case
core
.
NewMinedBlockEvent
:
if
ev
,
ok
:=
obj
.
Data
.
(
core
.
NewMinedBlockEvent
);
ok
{
pm
.
BroadcastBlock
(
ev
.
Block
,
true
)
// First propagate block to peers
pm
.
BroadcastBlock
(
ev
.
Block
,
false
)
// Only then announce to the rest
}
...
...
eth/tracers/tracer.go
View file @
d42ce0f2
...
...
@@ -486,12 +486,7 @@ func (jst *Tracer) call(method string, args ...string) (json.RawMessage, error)
}
func
wrapError
(
context
string
,
err
error
)
error
{
var
message
string
switch
err
:=
err
.
(
type
)
{
default
:
message
=
err
.
Error
()
}
return
fmt
.
Errorf
(
"%v in server-side tracer function '%v'"
,
message
,
context
)
return
fmt
.
Errorf
(
"%v in server-side tracer function '%v'"
,
err
,
context
)
}
// CaptureStart implements the Tracer interface to initialize the tracing operation.
...
...
les/handler.go
View file @
d42ce0f2
...
...
@@ -1158,8 +1158,7 @@ func (pm *ProtocolManager) getHelperTrie(id uint, idx uint64) (common.Hash, stri
// getHelperTrieAuxData returns requested auxiliary data for the given HelperTrie request
func
(
pm
*
ProtocolManager
)
getHelperTrieAuxData
(
req
HelperTrieReq
)
[]
byte
{
switch
{
case
req
.
Type
==
htCanonical
&&
req
.
AuxReq
==
auxHeader
&&
len
(
req
.
Key
)
==
8
:
if
req
.
Type
==
htCanonical
&&
req
.
AuxReq
==
auxHeader
&&
len
(
req
.
Key
)
==
8
{
blockNum
:=
binary
.
BigEndian
.
Uint64
(
req
.
Key
)
hash
:=
rawdb
.
ReadCanonicalHash
(
pm
.
chainDb
,
blockNum
)
return
rawdb
.
ReadHeaderRLP
(
pm
.
chainDb
,
hash
,
blockNum
)
...
...
metrics/exp/exp.go
View file @
d42ce0f2
...
...
@@ -147,21 +147,21 @@ func (exp *exp) publishResettingTimer(name string, metric metrics.ResettingTimer
func
(
exp
*
exp
)
syncToExpvar
()
{
exp
.
registry
.
Each
(
func
(
name
string
,
i
interface
{})
{
switch
i
.
(
type
)
{
switch
i
:=
i
.
(
type
)
{
case
metrics
.
Counter
:
exp
.
publishCounter
(
name
,
i
.
(
metrics
.
Counter
)
)
exp
.
publishCounter
(
name
,
i
)
case
metrics
.
Gauge
:
exp
.
publishGauge
(
name
,
i
.
(
metrics
.
Gauge
)
)
exp
.
publishGauge
(
name
,
i
)
case
metrics
.
GaugeFloat64
:
exp
.
publishGaugeFloat64
(
name
,
i
.
(
metrics
.
GaugeFloat64
)
)
exp
.
publishGaugeFloat64
(
name
,
i
)
case
metrics
.
Histogram
:
exp
.
publishHistogram
(
name
,
i
.
(
metrics
.
Histogram
)
)
exp
.
publishHistogram
(
name
,
i
)
case
metrics
.
Meter
:
exp
.
publishMeter
(
name
,
i
.
(
metrics
.
Meter
)
)
exp
.
publishMeter
(
name
,
i
)
case
metrics
.
Timer
:
exp
.
publishTimer
(
name
,
i
.
(
metrics
.
Timer
)
)
exp
.
publishTimer
(
name
,
i
)
case
metrics
.
ResettingTimer
:
exp
.
publishResettingTimer
(
name
,
i
.
(
metrics
.
ResettingTimer
)
)
exp
.
publishResettingTimer
(
name
,
i
)
default
:
panic
(
fmt
.
Sprintf
(
"unsupported type for '%s': %T"
,
name
,
i
))
}
...
...
p2p/nat/natpmp.go
View file @
d42ce0f2
...
...
@@ -115,8 +115,7 @@ func potentialGateways() (gws []net.IP) {
return
gws
}
for
_
,
addr
:=
range
ifaddrs
{
switch
x
:=
addr
.
(
type
)
{
case
*
net
.
IPNet
:
if
x
,
ok
:=
addr
.
(
*
net
.
IPNet
);
ok
{
if
lan10
.
Contains
(
x
.
IP
)
||
lan176
.
Contains
(
x
.
IP
)
||
lan192
.
Contains
(
x
.
IP
)
{
ip
:=
x
.
IP
.
Mask
(
x
.
Mask
)
.
To4
()
if
ip
!=
nil
{
...
...
p2p/nat/natupnp.go
View file @
d42ce0f2
...
...
@@ -81,14 +81,11 @@ func (n *upnp) internalAddress() (net.IP, error) {
return
nil
,
err
}
for
_
,
addr
:=
range
addrs
{
switch
x
:=
addr
.
(
type
)
{
case
*
net
.
IPNet
:
if
x
.
Contains
(
devaddr
.
IP
)
{
if
x
,
ok
:=
addr
.
(
*
net
.
IPNet
);
ok
&&
x
.
Contains
(
devaddr
.
IP
)
{
return
x
.
IP
,
nil
}
}
}
}
return
nil
,
fmt
.
Errorf
(
"could not find local address in same net as %v"
,
devaddr
)
}
...
...
p2p/simulations/adapters/inproc.go
View file @
d42ce0f2
...
...
@@ -353,8 +353,7 @@ func (sn *SimNode) NodeInfo() *p2p.NodeInfo {
}
func
setSocketBuffer
(
conn
net
.
Conn
,
socketReadBuffer
int
,
socketWriteBuffer
int
)
error
{
switch
v
:=
conn
.
(
type
)
{
case
*
net
.
UnixConn
:
if
v
,
ok
:=
conn
.
(
*
net
.
UnixConn
);
ok
{
err
:=
v
.
SetReadBuffer
(
socketReadBuffer
)
if
err
!=
nil
{
return
err
...
...
signer/core/abihelper.go
View file @
d42ce0f2
...
...
@@ -43,11 +43,11 @@ type decodedCallData struct {
// String implements stringer interface, tries to use the underlying value-type
func
(
arg
decodedArgument
)
String
()
string
{
var
value
string
switch
arg
.
value
.
(
type
)
{
switch
val
:=
arg
.
value
.
(
type
)
{
case
fmt
.
Stringer
:
value
=
arg
.
value
.
(
fmt
.
Stringer
)
.
String
()
value
=
val
.
String
()
default
:
value
=
fmt
.
Sprintf
(
"%v"
,
arg
.
value
)
value
=
fmt
.
Sprintf
(
"%v"
,
val
)
}
return
fmt
.
Sprintf
(
"%v: %v"
,
arg
.
soltype
.
Type
.
String
(),
value
)
}
...
...
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