|
|
@ -230,7 +230,7 @@ func (p *peer) RequestReceipts(hashes []common.Hash) error { |
|
|
|
|
|
|
|
|
|
|
|
// Handshake executes the eth protocol handshake, negotiating version number,
|
|
|
|
// Handshake executes the eth protocol handshake, negotiating version number,
|
|
|
|
// network IDs, difficulties, head and genesis blocks.
|
|
|
|
// network IDs, difficulties, head and genesis blocks.
|
|
|
|
func (p *peer) Handshake(network int, td *big.Int, head common.Hash, genesis common.Hash) error { |
|
|
|
func (p *peer) Handshake(network uint64, td *big.Int, head common.Hash, genesis common.Hash) error { |
|
|
|
// Send out own handshake in a new thread
|
|
|
|
// Send out own handshake in a new thread
|
|
|
|
errc := make(chan error, 2) |
|
|
|
errc := make(chan error, 2) |
|
|
|
var status statusData // safe to read after two values have been received from errc
|
|
|
|
var status statusData // safe to read after two values have been received from errc
|
|
|
@ -238,7 +238,7 @@ func (p *peer) Handshake(network int, td *big.Int, head common.Hash, genesis com |
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
errc <- p2p.Send(p.rw, StatusMsg, &statusData{ |
|
|
|
errc <- p2p.Send(p.rw, StatusMsg, &statusData{ |
|
|
|
ProtocolVersion: uint32(p.version), |
|
|
|
ProtocolVersion: uint32(p.version), |
|
|
|
NetworkId: uint32(network), |
|
|
|
NetworkId: network, |
|
|
|
TD: td, |
|
|
|
TD: td, |
|
|
|
CurrentBlock: head, |
|
|
|
CurrentBlock: head, |
|
|
|
GenesisBlock: genesis, |
|
|
|
GenesisBlock: genesis, |
|
|
@ -263,7 +263,7 @@ func (p *peer) Handshake(network int, td *big.Int, head common.Hash, genesis com |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (p *peer) readStatus(network int, status *statusData, genesis common.Hash) (err error) { |
|
|
|
func (p *peer) readStatus(network uint64, status *statusData, genesis common.Hash) (err error) { |
|
|
|
msg, err := p.rw.ReadMsg() |
|
|
|
msg, err := p.rw.ReadMsg() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
@ -281,7 +281,7 @@ func (p *peer) readStatus(network int, status *statusData, genesis common.Hash) |
|
|
|
if status.GenesisBlock != genesis { |
|
|
|
if status.GenesisBlock != genesis { |
|
|
|
return errResp(ErrGenesisBlockMismatch, "%x (!= %x)", status.GenesisBlock[:8], genesis[:8]) |
|
|
|
return errResp(ErrGenesisBlockMismatch, "%x (!= %x)", status.GenesisBlock[:8], genesis[:8]) |
|
|
|
} |
|
|
|
} |
|
|
|
if int(status.NetworkId) != network { |
|
|
|
if status.NetworkId != network { |
|
|
|
return errResp(ErrNetworkIdMismatch, "%d (!= %d)", status.NetworkId, network) |
|
|
|
return errResp(ErrNetworkIdMismatch, "%d (!= %d)", status.NetworkId, network) |
|
|
|
} |
|
|
|
} |
|
|
|
if int(status.ProtocolVersion) != p.version { |
|
|
|
if int(status.ProtocolVersion) != p.version { |
|
|
|