Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
fff6e03a
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fff6e03a
编写于
8月 08, 2017
作者:
F
Felföldi Zsolt
提交者:
Péter Szilágyi
8月 08, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
les: fix megacheck warnings (#14941)
* les: fix megacheck warnings * les: fixed testGetProofs
上级
d3751937
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
6 addition
and
96 deletion
+6
-96
les/backend.go
les/backend.go
+1
-2
les/flowcontrol/control.go
les/flowcontrol/control.go
+1
-3
les/handler.go
les/handler.go
+0
-6
les/handler_test.go
les/handler_test.go
+2
-2
les/helper_test.go
les/helper_test.go
+1
-41
les/peer.go
les/peer.go
+1
-4
les/protocol.go
les/protocol.go
+0
-27
les/server.go
les/server.go
+0
-11
未找到文件。
les/backend.go
浏览文件 @
fff6e03a
...
...
@@ -70,8 +70,7 @@ type LightEthereum struct {
networkId
uint64
netRPCService
*
ethapi
.
PublicNetAPI
quitSync
chan
struct
{}
wg
sync
.
WaitGroup
wg
sync
.
WaitGroup
}
func
New
(
ctx
*
node
.
ServiceContext
,
config
*
eth
.
Config
)
(
*
LightEthereum
,
error
)
{
...
...
les/flowcontrol/control.go
浏览文件 @
fff6e03a
...
...
@@ -157,9 +157,7 @@ func (peer *ServerNode) QueueRequest(reqID, maxCost uint64) {
peer
.
bufEstimate
-=
maxCost
peer
.
sumCost
+=
maxCost
if
reqID
>=
0
{
peer
.
pending
[
reqID
]
=
peer
.
sumCost
}
peer
.
pending
[
reqID
]
=
peer
.
sumCost
}
// GotReply adjusts estimated buffer value according to the value included in
...
...
les/handler.go
浏览文件 @
fff6e03a
...
...
@@ -69,8 +69,6 @@ func errResp(code errCode, format string, v ...interface{}) error {
return
fmt
.
Errorf
(
"%v - %v"
,
code
,
fmt
.
Sprintf
(
format
,
v
...
))
}
type
hashFetcherFn
func
(
common
.
Hash
)
error
type
BlockChain
interface
{
HasHeader
(
hash
common
.
Hash
)
bool
GetHeader
(
hash
common
.
Hash
,
number
uint64
)
*
types
.
Header
...
...
@@ -119,10 +117,6 @@ type ProtocolManager struct {
quitSync
chan
struct
{}
noMorePeers
chan
struct
{}
syncMu
sync
.
Mutex
syncing
bool
syncDone
chan
struct
{}
// wait group is used for graceful shutdowns during downloading
// and processing
wg
*
sync
.
WaitGroup
...
...
les/handler_test.go
浏览文件 @
fff6e03a
...
...
@@ -305,7 +305,7 @@ func testGetReceipt(t *testing.T, protocol int) {
}
// Tests that trie merkle proofs can be retrieved
func
TestGetProofsLes1
(
t
*
testing
.
T
)
{
testGet
Receipt
(
t
,
1
)
}
func
TestGetProofsLes1
(
t
*
testing
.
T
)
{
testGet
Proofs
(
t
,
1
)
}
func
testGetProofs
(
t
*
testing
.
T
,
protocol
int
)
{
// Assemble the test environment
...
...
@@ -327,7 +327,7 @@ func testGetProofs(t *testing.T, protocol int) {
for
_
,
acc
:=
range
accounts
{
req
:=
ProofReq
{
BHash
:
header
.
Hash
(),
Key
:
acc
[
:
]
,
Key
:
crypto
.
Keccak256
(
acc
[
:
])
,
}
proofreqs
=
append
(
proofreqs
,
req
)
...
...
les/helper_test.go
浏览文件 @
fff6e03a
...
...
@@ -20,7 +20,6 @@
package
les
import
(
"crypto/ecdsa"
"crypto/rand"
"math/big"
"sync"
...
...
@@ -140,7 +139,7 @@ func newTestProtocolManager(lightSync bool, blocks int, generator func(int, *cor
Alloc
:
core
.
GenesisAlloc
{
testBankAddress
:
{
Balance
:
testBankFunds
}},
}
genesis
=
gspec
.
MustCommit
(
db
)
chain
BlockChain
chain
BlockChain
)
if
peers
==
nil
{
peers
=
newPeerSet
()
...
...
@@ -189,45 +188,6 @@ func newTestProtocolManagerMust(t *testing.T, lightSync bool, blocks int, genera
return
pm
}
// testTxPool is a fake, helper transaction pool for testing purposes
type
testTxPool
struct
{
pool
[]
*
types
.
Transaction
// Collection of all transactions
added
chan
<-
[]
*
types
.
Transaction
// Notification channel for new transactions
lock
sync
.
RWMutex
// Protects the transaction pool
}
// AddTransactions appends a batch of transactions to the pool, and notifies any
// listeners if the addition channel is non nil
func
(
p
*
testTxPool
)
AddBatch
(
txs
[]
*
types
.
Transaction
)
{
p
.
lock
.
Lock
()
defer
p
.
lock
.
Unlock
()
p
.
pool
=
append
(
p
.
pool
,
txs
...
)
if
p
.
added
!=
nil
{
p
.
added
<-
txs
}
}
// GetTransactions returns all the transactions known to the pool
func
(
p
*
testTxPool
)
GetTransactions
()
types
.
Transactions
{
p
.
lock
.
RLock
()
defer
p
.
lock
.
RUnlock
()
txs
:=
make
([]
*
types
.
Transaction
,
len
(
p
.
pool
))
copy
(
txs
,
p
.
pool
)
return
txs
}
// newTestTransaction create a new dummy transaction.
func
newTestTransaction
(
from
*
ecdsa
.
PrivateKey
,
nonce
uint64
,
datasize
int
)
*
types
.
Transaction
{
tx
:=
types
.
NewTransaction
(
nonce
,
common
.
Address
{},
big
.
NewInt
(
0
),
big
.
NewInt
(
100000
),
big
.
NewInt
(
0
),
make
([]
byte
,
datasize
))
tx
,
_
=
types
.
SignTx
(
tx
,
types
.
HomesteadSigner
{},
from
)
return
tx
}
// testPeer is a simulated peer to allow testing direct network calls.
type
testPeer
struct
{
net
p2p
.
MsgReadWriter
// Network layer reader/writer to simulate remote messaging
...
...
les/peer.go
浏览文件 @
fff6e03a
...
...
@@ -38,10 +38,7 @@ var (
errNotRegistered
=
errors
.
New
(
"peer is not registered"
)
)
const
(
maxHeadInfoLen
=
20
maxResponseErrors
=
50
// number of invalid responses tolerated (makes the protocol less brittle but still avoids spam)
)
const
maxResponseErrors
=
50
// number of invalid responses tolerated (makes the protocol less brittle but still avoids spam)
type
peer
struct
{
*
p2p
.
Peer
...
...
les/protocol.go
浏览文件 @
fff6e03a
...
...
@@ -23,7 +23,6 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rlp"
)
...
...
@@ -105,12 +104,6 @@ var errorToString = map[int]string{
ErrHandshakeMissingKey
:
"Key missing from handshake message"
,
}
type
chainManager
interface
{
GetBlockHashesFromHash
(
hash
common
.
Hash
,
amount
uint64
)
(
hashes
[]
common
.
Hash
)
GetBlock
(
hash
common
.
Hash
)
(
block
*
types
.
Block
)
Status
()
(
td
*
big
.
Int
,
currentBlock
common
.
Hash
,
genesisBlock
common
.
Hash
)
}
// announceData is the network packet for the block announcements.
type
announceData
struct
{
Hash
common
.
Hash
// Hash of one particular block being announced
...
...
@@ -118,11 +111,6 @@ type announceData struct {
Td
*
big
.
Int
// Total difficulty of one particular block being announced
ReorgDepth
uint64
Update
keyValueList
haveHeaders
uint64
// we have the headers of the remote peer's chain up to this number
headKnown
bool
requested
bool
next
*
announceData
}
type
blockInfo
struct
{
...
...
@@ -131,12 +119,6 @@ type blockInfo struct {
Td
*
big
.
Int
// Total difficulty of one particular block being announced
}
// getBlockHashesData is the network packet for the hash based hash retrieval.
type
getBlockHashesData
struct
{
Hash
common
.
Hash
Amount
uint64
}
// getBlockHeadersData represents a block header query.
type
getBlockHeadersData
struct
{
Origin
hashOrNumber
// Block from which to retrieve headers
...
...
@@ -181,15 +163,6 @@ func (hn *hashOrNumber) DecodeRLP(s *rlp.Stream) error {
return
err
}
// newBlockData is the network packet for the block propagation message.
type
newBlockData
struct
{
Block
*
types
.
Block
TD
*
big
.
Int
}
// blockBodiesData is the network packet for block content distribution.
type
blockBodiesData
[]
*
types
.
Body
// CodeData is the network response packet for a node data retrieval.
type
CodeData
[]
struct
{
Value
[]
byte
...
...
les/server.go
浏览文件 @
fff6e03a
...
...
@@ -44,7 +44,6 @@ type LesServer struct {
defParams
*
flowcontrol
.
ServerParams
lesTopic
discv5
.
Topic
quitSync
chan
struct
{}
stopped
bool
}
func
NewLesServer
(
eth
*
eth
.
Ethereum
,
config
*
eth
.
Config
)
(
*
LesServer
,
error
)
{
...
...
@@ -118,16 +117,6 @@ func (list RequestCostList) decode() requestCostTable {
return
table
}
func
(
table
requestCostTable
)
encode
()
RequestCostList
{
list
:=
make
(
RequestCostList
,
len
(
table
))
for
idx
,
code
:=
range
reqList
{
list
[
idx
]
.
MsgCode
=
code
list
[
idx
]
.
BaseCost
=
table
[
code
]
.
baseCost
list
[
idx
]
.
ReqCost
=
table
[
code
]
.
reqCost
}
return
list
}
type
linReg
struct
{
sumX
,
sumY
,
sumXX
,
sumXY
float64
cnt
uint64
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录