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
d81c9d9b
Unverified
Commit
d81c9d9b
authored
Sep 09, 2020
by
Marius van der Wijden
Committed by
GitHub
Sep 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts/abi/bind/backends: reverted some stylistic changes (#21535)
parent
8d35b1eb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
25 deletions
+25
-25
simulated.go
accounts/abi/bind/backends/simulated.go
+22
-22
simulated_test.go
accounts/abi/bind/backends/simulated_test.go
+3
-3
No files found.
accounts/abi/bind/backends/simulated.go
View file @
d81c9d9b
...
@@ -195,7 +195,7 @@ func (b *SimulatedBackend) StorageAt(ctx context.Context, contract common.Addres
...
@@ -195,7 +195,7 @@ func (b *SimulatedBackend) StorageAt(ctx context.Context, contract common.Addres
}
}
// TransactionReceipt returns the receipt of a transaction.
// TransactionReceipt returns the receipt of a transaction.
func
(
b
*
SimulatedBackend
)
TransactionReceipt
(
_
context
.
Context
,
txHash
common
.
Hash
)
(
*
types
.
Receipt
,
error
)
{
func
(
b
*
SimulatedBackend
)
TransactionReceipt
(
ctx
context
.
Context
,
txHash
common
.
Hash
)
(
*
types
.
Receipt
,
error
)
{
b
.
mu
.
Lock
()
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
defer
b
.
mu
.
Unlock
()
...
@@ -207,7 +207,7 @@ func (b *SimulatedBackend) TransactionReceipt(_ context.Context, txHash common.H
...
@@ -207,7 +207,7 @@ func (b *SimulatedBackend) TransactionReceipt(_ context.Context, txHash common.H
// blockchain. The isPending return value indicates whether the transaction has been
// blockchain. The isPending return value indicates whether the transaction has been
// mined yet. Note that the transaction may not be part of the canonical chain even if
// mined yet. Note that the transaction may not be part of the canonical chain even if
// it's not pending.
// it's not pending.
func
(
b
*
SimulatedBackend
)
TransactionByHash
(
_
context
.
Context
,
txHash
common
.
Hash
)
(
*
types
.
Transaction
,
bool
,
error
)
{
func
(
b
*
SimulatedBackend
)
TransactionByHash
(
ctx
context
.
Context
,
txHash
common
.
Hash
)
(
*
types
.
Transaction
,
bool
,
error
)
{
b
.
mu
.
Lock
()
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
defer
b
.
mu
.
Unlock
()
...
@@ -223,7 +223,7 @@ func (b *SimulatedBackend) TransactionByHash(_ context.Context, txHash common.Ha
...
@@ -223,7 +223,7 @@ func (b *SimulatedBackend) TransactionByHash(_ context.Context, txHash common.Ha
}
}
// BlockByHash retrieves a block based on the block hash.
// BlockByHash retrieves a block based on the block hash.
func
(
b
*
SimulatedBackend
)
BlockByHash
(
_
context
.
Context
,
hash
common
.
Hash
)
(
*
types
.
Block
,
error
)
{
func
(
b
*
SimulatedBackend
)
BlockByHash
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
*
types
.
Block
,
error
)
{
b
.
mu
.
Lock
()
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
defer
b
.
mu
.
Unlock
()
...
@@ -250,7 +250,7 @@ func (b *SimulatedBackend) BlockByNumber(ctx context.Context, number *big.Int) (
...
@@ -250,7 +250,7 @@ func (b *SimulatedBackend) BlockByNumber(ctx context.Context, number *big.Int) (
// blockByNumberNoLock retrieves a block from the database by number, caching it
// blockByNumberNoLock retrieves a block from the database by number, caching it
// (associated with its hash) if found without Lock.
// (associated with its hash) if found without Lock.
func
(
b
*
SimulatedBackend
)
blockByNumberNoLock
(
_
context
.
Context
,
number
*
big
.
Int
)
(
*
types
.
Block
,
error
)
{
func
(
b
*
SimulatedBackend
)
blockByNumberNoLock
(
ctx
context
.
Context
,
number
*
big
.
Int
)
(
*
types
.
Block
,
error
)
{
if
number
==
nil
||
number
.
Cmp
(
b
.
pendingBlock
.
Number
())
==
0
{
if
number
==
nil
||
number
.
Cmp
(
b
.
pendingBlock
.
Number
())
==
0
{
return
b
.
blockchain
.
CurrentBlock
(),
nil
return
b
.
blockchain
.
CurrentBlock
(),
nil
}
}
...
@@ -264,7 +264,7 @@ func (b *SimulatedBackend) blockByNumberNoLock(_ context.Context, number *big.In
...
@@ -264,7 +264,7 @@ func (b *SimulatedBackend) blockByNumberNoLock(_ context.Context, number *big.In
}
}
// HeaderByHash returns a block header from the current canonical chain.
// HeaderByHash returns a block header from the current canonical chain.
func
(
b
*
SimulatedBackend
)
HeaderByHash
(
_
context
.
Context
,
hash
common
.
Hash
)
(
*
types
.
Header
,
error
)
{
func
(
b
*
SimulatedBackend
)
HeaderByHash
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
*
types
.
Header
,
error
)
{
b
.
mu
.
Lock
()
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
defer
b
.
mu
.
Unlock
()
...
@@ -282,7 +282,7 @@ func (b *SimulatedBackend) HeaderByHash(_ context.Context, hash common.Hash) (*t
...
@@ -282,7 +282,7 @@ func (b *SimulatedBackend) HeaderByHash(_ context.Context, hash common.Hash) (*t
// HeaderByNumber returns a block header from the current canonical chain. If number is
// HeaderByNumber returns a block header from the current canonical chain. If number is
// nil, the latest known header is returned.
// nil, the latest known header is returned.
func
(
b
*
SimulatedBackend
)
HeaderByNumber
(
_
context
.
Context
,
block
*
big
.
Int
)
(
*
types
.
Header
,
error
)
{
func
(
b
*
SimulatedBackend
)
HeaderByNumber
(
ctx
context
.
Context
,
block
*
big
.
Int
)
(
*
types
.
Header
,
error
)
{
b
.
mu
.
Lock
()
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
defer
b
.
mu
.
Unlock
()
...
@@ -294,7 +294,7 @@ func (b *SimulatedBackend) HeaderByNumber(_ context.Context, block *big.Int) (*t
...
@@ -294,7 +294,7 @@ func (b *SimulatedBackend) HeaderByNumber(_ context.Context, block *big.Int) (*t
}
}
// TransactionCount returns the number of transactions in a given block.
// TransactionCount returns the number of transactions in a given block.
func
(
b
*
SimulatedBackend
)
TransactionCount
(
_
context
.
Context
,
blockHash
common
.
Hash
)
(
uint
,
error
)
{
func
(
b
*
SimulatedBackend
)
TransactionCount
(
ctx
context
.
Context
,
blockHash
common
.
Hash
)
(
uint
,
error
)
{
b
.
mu
.
Lock
()
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
defer
b
.
mu
.
Unlock
()
...
@@ -311,7 +311,7 @@ func (b *SimulatedBackend) TransactionCount(_ context.Context, blockHash common.
...
@@ -311,7 +311,7 @@ func (b *SimulatedBackend) TransactionCount(_ context.Context, blockHash common.
}
}
// TransactionInBlock returns the transaction for a specific block at a specific index.
// TransactionInBlock returns the transaction for a specific block at a specific index.
func
(
b
*
SimulatedBackend
)
TransactionInBlock
(
_
context
.
Context
,
blockHash
common
.
Hash
,
index
uint
)
(
*
types
.
Transaction
,
error
)
{
func
(
b
*
SimulatedBackend
)
TransactionInBlock
(
ctx
context
.
Context
,
blockHash
common
.
Hash
,
index
uint
)
(
*
types
.
Transaction
,
error
)
{
b
.
mu
.
Lock
()
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
defer
b
.
mu
.
Unlock
()
...
@@ -338,7 +338,7 @@ func (b *SimulatedBackend) TransactionInBlock(_ context.Context, blockHash commo
...
@@ -338,7 +338,7 @@ func (b *SimulatedBackend) TransactionInBlock(_ context.Context, blockHash commo
}
}
// PendingCodeAt returns the code associated with an account in the pending state.
// PendingCodeAt returns the code associated with an account in the pending state.
func
(
b
*
SimulatedBackend
)
PendingCodeAt
(
_
context
.
Context
,
contract
common
.
Address
)
([]
byte
,
error
)
{
func
(
b
*
SimulatedBackend
)
PendingCodeAt
(
ctx
context
.
Context
,
contract
common
.
Address
)
([]
byte
,
error
)
{
b
.
mu
.
Lock
()
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
defer
b
.
mu
.
Unlock
()
...
@@ -417,7 +417,7 @@ func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call ethereu
...
@@ -417,7 +417,7 @@ func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call ethereu
// PendingNonceAt implements PendingStateReader.PendingNonceAt, retrieving
// PendingNonceAt implements PendingStateReader.PendingNonceAt, retrieving
// the nonce currently pending for the account.
// the nonce currently pending for the account.
func
(
b
*
SimulatedBackend
)
PendingNonceAt
(
_
context
.
Context
,
account
common
.
Address
)
(
uint64
,
error
)
{
func
(
b
*
SimulatedBackend
)
PendingNonceAt
(
ctx
context
.
Context
,
account
common
.
Address
)
(
uint64
,
error
)
{
b
.
mu
.
Lock
()
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
defer
b
.
mu
.
Unlock
()
...
@@ -426,7 +426,7 @@ func (b *SimulatedBackend) PendingNonceAt(_ context.Context, account common.Addr
...
@@ -426,7 +426,7 @@ func (b *SimulatedBackend) PendingNonceAt(_ context.Context, account common.Addr
// SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated
// SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated
// chain doesn't have miners, we just return a gas price of 1 for any call.
// chain doesn't have miners, we just return a gas price of 1 for any call.
func
(
b
*
SimulatedBackend
)
SuggestGasPrice
(
_
context
.
Context
)
(
*
big
.
Int
,
error
)
{
func
(
b
*
SimulatedBackend
)
SuggestGasPrice
(
ctx
context
.
Context
)
(
*
big
.
Int
,
error
)
{
return
big
.
NewInt
(
1
),
nil
return
big
.
NewInt
(
1
),
nil
}
}
...
@@ -525,7 +525,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
...
@@ -525,7 +525,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
// callContract implements common code between normal and pending contract calls.
// callContract implements common code between normal and pending contract calls.
// state is modified during execution, make sure to copy it if necessary.
// state is modified during execution, make sure to copy it if necessary.
func
(
b
*
SimulatedBackend
)
callContract
(
_
context
.
Context
,
call
ethereum
.
CallMsg
,
block
*
types
.
Block
,
stateDB
*
state
.
StateDB
)
(
*
core
.
ExecutionResult
,
error
)
{
func
(
b
*
SimulatedBackend
)
callContract
(
ctx
context
.
Context
,
call
ethereum
.
CallMsg
,
block
*
types
.
Block
,
stateDB
*
state
.
StateDB
)
(
*
core
.
ExecutionResult
,
error
)
{
// Ensure message is initialized properly.
// Ensure message is initialized properly.
if
call
.
GasPrice
==
nil
{
if
call
.
GasPrice
==
nil
{
call
.
GasPrice
=
big
.
NewInt
(
1
)
call
.
GasPrice
=
big
.
NewInt
(
1
)
...
@@ -553,7 +553,7 @@ func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg
...
@@ -553,7 +553,7 @@ func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg
// SendTransaction updates the pending block to include the given transaction.
// SendTransaction updates the pending block to include the given transaction.
// It panics if the transaction is invalid.
// It panics if the transaction is invalid.
func
(
b
*
SimulatedBackend
)
SendTransaction
(
_
context
.
Context
,
tx
*
types
.
Transaction
)
error
{
func
(
b
*
SimulatedBackend
)
SendTransaction
(
ctx
context
.
Context
,
tx
*
types
.
Transaction
)
error
{
b
.
mu
.
Lock
()
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
defer
b
.
mu
.
Unlock
()
...
@@ -615,7 +615,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
...
@@ -615,7 +615,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
// SubscribeFilterLogs creates a background log filtering operation, returning a
// SubscribeFilterLogs creates a background log filtering operation, returning a
// subscription immediately, which can be used to stream the found events.
// subscription immediately, which can be used to stream the found events.
func
(
b
*
SimulatedBackend
)
SubscribeFilterLogs
(
_
context
.
Context
,
query
ethereum
.
FilterQuery
,
ch
chan
<-
types
.
Log
)
(
ethereum
.
Subscription
,
error
)
{
func
(
b
*
SimulatedBackend
)
SubscribeFilterLogs
(
ctx
context
.
Context
,
query
ethereum
.
FilterQuery
,
ch
chan
<-
types
.
Log
)
(
ethereum
.
Subscription
,
error
)
{
// Subscribe to contract events
// Subscribe to contract events
sink
:=
make
(
chan
[]
*
types
.
Log
)
sink
:=
make
(
chan
[]
*
types
.
Log
)
...
@@ -648,7 +648,7 @@ func (b *SimulatedBackend) SubscribeFilterLogs(_ context.Context, query ethereum
...
@@ -648,7 +648,7 @@ func (b *SimulatedBackend) SubscribeFilterLogs(_ context.Context, query ethereum
}
}
// SubscribeNewHead returns an event subscription for a new header.
// SubscribeNewHead returns an event subscription for a new header.
func
(
b
*
SimulatedBackend
)
SubscribeNewHead
(
_
context
.
Context
,
ch
chan
<-
*
types
.
Header
)
(
ethereum
.
Subscription
,
error
)
{
func
(
b
*
SimulatedBackend
)
SubscribeNewHead
(
ctx
context
.
Context
,
ch
chan
<-
*
types
.
Header
)
(
ethereum
.
Subscription
,
error
)
{
// subscribe to a new head
// subscribe to a new head
sink
:=
make
(
chan
*
types
.
Header
)
sink
:=
make
(
chan
*
types
.
Header
)
sub
:=
b
.
events
.
SubscribeNewHeads
(
sink
)
sub
:=
b
.
events
.
SubscribeNewHeads
(
sink
)
...
@@ -724,18 +724,18 @@ type filterBackend struct {
...
@@ -724,18 +724,18 @@ type filterBackend struct {
func
(
fb
*
filterBackend
)
ChainDb
()
ethdb
.
Database
{
return
fb
.
db
}
func
(
fb
*
filterBackend
)
ChainDb
()
ethdb
.
Database
{
return
fb
.
db
}
func
(
fb
*
filterBackend
)
EventMux
()
*
event
.
TypeMux
{
panic
(
"not supported"
)
}
func
(
fb
*
filterBackend
)
EventMux
()
*
event
.
TypeMux
{
panic
(
"not supported"
)
}
func
(
fb
*
filterBackend
)
HeaderByNumber
(
_
context
.
Context
,
block
rpc
.
BlockNumber
)
(
*
types
.
Header
,
error
)
{
func
(
fb
*
filterBackend
)
HeaderByNumber
(
ctx
context
.
Context
,
block
rpc
.
BlockNumber
)
(
*
types
.
Header
,
error
)
{
if
block
==
rpc
.
LatestBlockNumber
{
if
block
==
rpc
.
LatestBlockNumber
{
return
fb
.
bc
.
CurrentHeader
(),
nil
return
fb
.
bc
.
CurrentHeader
(),
nil
}
}
return
fb
.
bc
.
GetHeaderByNumber
(
uint64
(
block
.
Int64
())),
nil
return
fb
.
bc
.
GetHeaderByNumber
(
uint64
(
block
.
Int64
())),
nil
}
}
func
(
fb
*
filterBackend
)
HeaderByHash
(
_
context
.
Context
,
hash
common
.
Hash
)
(
*
types
.
Header
,
error
)
{
func
(
fb
*
filterBackend
)
HeaderByHash
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
*
types
.
Header
,
error
)
{
return
fb
.
bc
.
GetHeaderByHash
(
hash
),
nil
return
fb
.
bc
.
GetHeaderByHash
(
hash
),
nil
}
}
func
(
fb
*
filterBackend
)
GetReceipts
(
_
context
.
Context
,
hash
common
.
Hash
)
(
types
.
Receipts
,
error
)
{
func
(
fb
*
filterBackend
)
GetReceipts
(
ctx
context
.
Context
,
hash
common
.
Hash
)
(
types
.
Receipts
,
error
)
{
number
:=
rawdb
.
ReadHeaderNumber
(
fb
.
db
,
hash
)
number
:=
rawdb
.
ReadHeaderNumber
(
fb
.
db
,
hash
)
if
number
==
nil
{
if
number
==
nil
{
return
nil
,
nil
return
nil
,
nil
...
@@ -743,7 +743,7 @@ func (fb *filterBackend) GetReceipts(_ context.Context, hash common.Hash) (types
...
@@ -743,7 +743,7 @@ func (fb *filterBackend) GetReceipts(_ context.Context, hash common.Hash) (types
return
rawdb
.
ReadReceipts
(
fb
.
db
,
hash
,
*
number
,
fb
.
bc
.
Config
()),
nil
return
rawdb
.
ReadReceipts
(
fb
.
db
,
hash
,
*
number
,
fb
.
bc
.
Config
()),
nil
}
}
func
(
fb
*
filterBackend
)
GetLogs
(
_
context
.
Context
,
hash
common
.
Hash
)
([][]
*
types
.
Log
,
error
)
{
func
(
fb
*
filterBackend
)
GetLogs
(
ctx
context
.
Context
,
hash
common
.
Hash
)
([][]
*
types
.
Log
,
error
)
{
number
:=
rawdb
.
ReadHeaderNumber
(
fb
.
db
,
hash
)
number
:=
rawdb
.
ReadHeaderNumber
(
fb
.
db
,
hash
)
if
number
==
nil
{
if
number
==
nil
{
return
nil
,
nil
return
nil
,
nil
...
@@ -759,7 +759,7 @@ func (fb *filterBackend) GetLogs(_ context.Context, hash common.Hash) ([][]*type
...
@@ -759,7 +759,7 @@ func (fb *filterBackend) GetLogs(_ context.Context, hash common.Hash) ([][]*type
return
logs
,
nil
return
logs
,
nil
}
}
func
(
fb
*
filterBackend
)
SubscribeNewTxsEvent
(
_
chan
<-
core
.
NewTxsEvent
)
event
.
Subscription
{
func
(
fb
*
filterBackend
)
SubscribeNewTxsEvent
(
ch
chan
<-
core
.
NewTxsEvent
)
event
.
Subscription
{
return
nullSubscription
()
return
nullSubscription
()
}
}
...
@@ -775,13 +775,13 @@ func (fb *filterBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscr
...
@@ -775,13 +775,13 @@ func (fb *filterBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscr
return
fb
.
bc
.
SubscribeLogsEvent
(
ch
)
return
fb
.
bc
.
SubscribeLogsEvent
(
ch
)
}
}
func
(
fb
*
filterBackend
)
SubscribePendingLogsEvent
(
_
chan
<-
[]
*
types
.
Log
)
event
.
Subscription
{
func
(
fb
*
filterBackend
)
SubscribePendingLogsEvent
(
ch
chan
<-
[]
*
types
.
Log
)
event
.
Subscription
{
return
nullSubscription
()
return
nullSubscription
()
}
}
func
(
fb
*
filterBackend
)
BloomStatus
()
(
uint64
,
uint64
)
{
return
4096
,
0
}
func
(
fb
*
filterBackend
)
BloomStatus
()
(
uint64
,
uint64
)
{
return
4096
,
0
}
func
(
fb
*
filterBackend
)
ServiceFilter
(
_
context
.
Context
,
_
*
bloombits
.
MatcherSession
)
{
func
(
fb
*
filterBackend
)
ServiceFilter
(
ctx
context
.
Context
,
ms
*
bloombits
.
MatcherSession
)
{
panic
(
"not supported"
)
panic
(
"not supported"
)
}
}
...
...
accounts/abi/bind/backends/simulated_test.go
View file @
d81c9d9b
...
@@ -1086,12 +1086,12 @@ func TestSimulatedBackend_CallContractRevert(t *testing.T) {
...
@@ -1086,12 +1086,12 @@ func TestSimulatedBackend_CallContractRevert(t *testing.T) {
t
.
Errorf
(
"result from %v was not nil: %v"
,
key
,
res
)
t
.
Errorf
(
"result from %v was not nil: %v"
,
key
,
res
)
}
}
if
val
!=
nil
{
if
val
!=
nil
{
r
E
rr
,
ok
:=
err
.
(
*
revertError
)
r
e
rr
,
ok
:=
err
.
(
*
revertError
)
if
!
ok
{
if
!
ok
{
t
.
Errorf
(
"expect revert error"
)
t
.
Errorf
(
"expect revert error"
)
}
}
if
r
E
rr
.
Error
()
!=
"execution reverted: "
+
val
.
(
string
)
{
if
r
e
rr
.
Error
()
!=
"execution reverted: "
+
val
.
(
string
)
{
t
.
Errorf
(
"error was malformed: got %v want %v"
,
r
E
rr
.
Error
(),
val
)
t
.
Errorf
(
"error was malformed: got %v want %v"
,
r
e
rr
.
Error
(),
val
)
}
}
}
else
{
}
else
{
// revert(0x0,0x0)
// revert(0x0,0x0)
...
...
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