good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
52fb3b41
Commit
52fb3b41
authored
11 years ago
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Increased buffer size
parent
39bb2c94
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
peer.go
+20
-3
20 additions, 3 deletions
peer.go
server.go
+2
-3
2 additions, 3 deletions
server.go
with
22 additions
and
6 deletions
peer.go
+
20
−
3
View file @
52fb3b41
...
...
@@ -9,6 +9,11 @@ import (
"time"
)
const
(
// The size of the output buffer for writing messages
outputBufferSize
=
50
)
type
Peer
struct
{
// Server interface
server
*
Server
...
...
@@ -24,11 +29,12 @@ type Peer struct {
connected
int32
disconnect
int32
lastSend
time
.
Time
versionKnown
bool
}
func
NewPeer
(
conn
net
.
Conn
,
server
*
Server
,
inbound
bool
)
*
Peer
{
return
&
Peer
{
outputQueue
:
make
(
chan
*
ethwire
.
InOutMsg
,
1
),
// Buffered chan of 1 is enough
outputQueue
:
make
(
chan
*
ethwire
.
InOutMsg
,
outputBufferSize
),
quit
:
make
(
chan
bool
),
server
:
server
,
conn
:
conn
,
...
...
@@ -40,7 +46,7 @@ func NewPeer(conn net.Conn, server *Server, inbound bool) *Peer {
func
NewOutboundPeer
(
addr
string
,
server
*
Server
)
*
Peer
{
p
:=
&
Peer
{
outputQueue
:
make
(
chan
*
ethwire
.
InOutMsg
,
1
),
// Buffered chan of 1 is enough
outputQueue
:
make
(
chan
*
ethwire
.
InOutMsg
,
outputBufferSize
),
quit
:
make
(
chan
bool
),
server
:
server
,
inbound
:
false
,
...
...
@@ -61,6 +67,8 @@ func NewOutboundPeer(addr string, server *Server) *Peer {
atomic
.
StoreInt32
(
&
p
.
disconnect
,
0
)
log
.
Println
(
"Connected to peer ::"
,
conn
.
RemoteAddr
())
p
.
Start
()
}()
return
p
...
...
@@ -77,6 +85,14 @@ func (p *Peer) writeMessage(msg *ethwire.InOutMsg) {
return
}
if
!
p
.
versionKnown
{
switch
msg
.
MsgType
{
case
"verack"
:
// Ok
default
:
// Anything but ack is allowed
return
}
}
err
:=
ethwire
.
WriteMessage
(
p
.
conn
,
msg
)
if
err
!=
nil
{
log
.
Println
(
"Can't send message:"
,
err
)
...
...
@@ -191,10 +207,11 @@ func (p *Peer) handleVersionAck(msg *ethwire.InOutMsg) {
log
.
Println
(
"Peer connected to self, disconnecting"
)
p
.
Stop
()
return
}
log
.
Println
(
"mnonce"
,
msg
.
Nonce
,
"snonce"
,
p
.
server
.
Nonce
)
p
.
versionKnown
=
true
// If this is an inbound connection send an ack back
if
p
.
inbound
{
...
...
This diff is collapsed.
Click to expand it.
server.go
+
2
−
3
View file @
52fb3b41
...
...
@@ -71,9 +71,6 @@ func (s *Server) ConnectToPeer(addr string) error {
s
.
peers
.
PushBack
(
peer
)
peer
.
Start
()
return
nil
}
...
...
@@ -106,6 +103,8 @@ func (s *Server) Start() {
// TMP
go
func
()
{
//time.Sleep(500 * time.Millisecond)
for
{
s
.
Broadcast
(
"block"
,
s
.
blockManager
.
bc
.
GenesisBlock
()
.
MarshalRlp
())
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment