forked from TrueCloudLab/neoneo-go
Fix bug where channel for peers events is called after it's closed (#34)
* Disconnect once go routines signal so * Send msg if cmd is other than cmdUnknown * Remove typo * Fix lock file * Updates README * Comment typo * Fix issue * Revert old changes * Handle error
This commit is contained in:
parent
b6b8542caf
commit
e09c870f7f
3 changed files with 33 additions and 7 deletions
7
Makefile
7
Makefile
|
@ -1,5 +1,7 @@
|
||||||
BRANCH = "master"
|
BRANCH = "master"
|
||||||
VERSION = $(shell cat ./VERSION)
|
VERSION = $(shell cat ./VERSION)
|
||||||
|
SEEDS ?= "127.0.0.1:20333"
|
||||||
|
PORT ?= "3000"
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@go build -o ./bin/neo-go ./cli/main.go
|
@go build -o ./bin/neo-go ./cli/main.go
|
||||||
|
@ -16,8 +18,11 @@ push-tag:
|
||||||
git tag ${VERSION}
|
git tag ${VERSION}
|
||||||
git push origin ${BRANCH} --tags
|
git push origin ${BRANCH} --tags
|
||||||
|
|
||||||
|
run: build
|
||||||
|
./bin/neo-go node -seed ${SEEDS} -tcp ${PORT}
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@go test ./... -cover
|
@go test ./... -cover
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
@go vet ./...
|
@go vet ./...
|
||||||
|
|
10
README.md
10
README.md
|
@ -75,18 +75,24 @@ If you dont, take a look at [docker-privnet-with-gas](https://hub.docker.com/r/m
|
||||||
Start a NEO node:
|
Start a NEO node:
|
||||||
|
|
||||||
```
|
```
|
||||||
./bin/neo-go node -seed 127.0.0.1:20333
|
make run
|
||||||
```
|
```
|
||||||
|
|
||||||
You can add multiple seeds if you want:
|
You can add multiple seeds if you want:
|
||||||
|
|
||||||
```
|
```
|
||||||
./bin/neo-go node -seed 127.0.0.1:20333,127.0.01:20334
|
make run -e SEEDS="127.0.0.1:20333,127.0.01:20334"
|
||||||
```
|
```
|
||||||
|
|
||||||
By default the server will currently run on port 3000, for testing purposes.
|
By default the server will currently run on port 3000, for testing purposes.
|
||||||
You can change that by setting the tcp flag:
|
You can change that by setting the tcp flag:
|
||||||
|
|
||||||
|
```
|
||||||
|
make run -e PORT="1337"
|
||||||
|
```
|
||||||
|
|
||||||
|
To run the binary directly:
|
||||||
|
|
||||||
```
|
```
|
||||||
./bin/neo-go node -seed 127.0.0.1:20333 -tcp 1337
|
./bin/neo-go node -seed 127.0.0.1:20333 -tcp 1337
|
||||||
```
|
```
|
||||||
|
|
|
@ -141,10 +141,25 @@ func (m *Message) commandType() commandType {
|
||||||
|
|
||||||
// decode a Message from the given reader.
|
// decode a Message from the given reader.
|
||||||
func (m *Message) decode(r io.Reader) error {
|
func (m *Message) decode(r io.Reader) error {
|
||||||
binary.Read(r, binary.LittleEndian, &m.Magic)
|
err := binary.Read(r, binary.LittleEndian, &m.Magic)
|
||||||
binary.Read(r, binary.LittleEndian, &m.Command)
|
if err != nil {
|
||||||
binary.Read(r, binary.LittleEndian, &m.Length)
|
return err
|
||||||
binary.Read(r, binary.LittleEndian, &m.Checksum)
|
}
|
||||||
|
|
||||||
|
err = binary.Read(r, binary.LittleEndian, &m.Command)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = binary.Read(r, binary.LittleEndian, &m.Length)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = binary.Read(r, binary.LittleEndian, &m.Checksum)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// return if their is no payload.
|
// return if their is no payload.
|
||||||
if m.Length == 0 {
|
if m.Length == 0 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue