And make the node fail gracefully if it's unable to bind. Before this commit:
-----
Server is starting up
Connection manager started
Error connecting to outbound listen tcp 127.0.0.1:20332: bind: address already in use
We have connected successfully to: 127.0.0.1:20334
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x6bbfa2]
goroutine 12 [running]:
github.com/CityOfZion/neo-go/pkg/connmgr.New.func1.1(0x0, 0x0)
/home/rik/dev/neo-go/pkg/connmgr/connmgr.go:47 +0x22
panic(0x718980, 0xa22f70)
/usr/lib64/go/1.12/src/runtime/panic.go:522 +0x1b5
github.com/CityOfZion/neo-go/pkg/connmgr.New.func1(0xc000013430, 0xc000013450, 0xc000013440, 0xc0005265f0, 0xf, 0x0)
/home/rik/dev/neo-go/pkg/connmgr/connmgr.go:52 +0x15e
created by github.com/CityOfZion/neo-go/pkg/connmgr.New
/home/rik/dev/neo-go/pkg/connmgr/connmgr.go:38 +0xfe
exit status 2
-----
After this commit:
-----
listen tcp 127.0.0.1:20332: bind: address already in use
-----
GolangCI complains:
U1000: func (*RandomAccess).items is unused
And it looks like everyone and their dog just use ras.vals without any
wrappers when there is a need to access it, so drop the wrapper.
GolangCI complained:
testArray is unused (from deadcode)
But this function was actually wrong being a copy-paste of testMakeStackMap(),
it also didn't conform to testMake... naming scheme, so this fixes it. To make
thing more uniform NewArray() was also changed to return error, map_test.go
code adjusted to this changes and finally array_test.go was added as a stub
for future Array testing.
Like:
Error return value of alg.Write is not checked (from errcheck)
Actually even though the hash.Hash implements an io.Writer interface (that
return meaningful things on .Write()) it has this comment in its
documentation:
// Write (via the embedded io.Writer interface) adds more data to the running hash.
// It never returns an error.
so it should be OK to ignore return results here.
* Added
1) ReverseString method to the Uint160 type
2) ToReverseScriptHash method to convert a base58 address to a reverse script hash
* Simplified ToScriptHash method
- refactored OnBlockBlockMode to use blockPool
- syncmgr now checks for future blocks, instead of looking for a
FutureBlockErr from the Chain. This makes it so that syncmgr does not
depend on the Chain package.
- removed GetBestBlockHash function from config(unused)
- refactored all tests in the syncmgr package
- refactor syncmgr for blockpool
- add nextBlockIndex so that we can add blocks to the blockPool by
comparing their index
- add processBlock helper method,wraps around cfg.ProcessBlock and increments the nextBlockIndex
internally
[peermgr]
- Add request cache with tests
- Add requestCache to peermgr
- refactored peer manager tests
- Added blockInfo struct, to allow sorting on the blockIndex
- added helper methods for cache, pickItem, pickFirstItem, removeHash,
findHash and refactored tests
- renamed requestcache to blockcache
- refactored peer manager to use block cache for block requests *only*
- added blockCallPeer function to handle block requests only
- refactored onDisconnect to add back any pending peer requests that the
disconnected peer did not complete into the peer manager queue
[peermgr/server]
- Modify onBlock handler in server, to send peermgr a BlockInfo struct
[peermgr/syncmgr/server]
- Modified blockIndex in BlockInfo to be uint32 and not uint64
- RequestBlocks in syncmgr now takes an index along with the hash
- modified syncmgr code to pass index along with hash in all methods