This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 456
Peers communication protocol change to WS - Closes #446 #660
Merged
Merged
Changes from all commits
Commits
Show all changes
140 commits
Select commit
Hold shift + click to select a range
fcbc361
basic socket cluster setup
MaciejBaj 5463a97
:changed ws transport concurrency concept
MaciejBaj 1d2d2df
move responsibility for concurrency to wamp-socket-cluster lib
MaciejBaj 71da101
use reassign endpoints with ConcurrentWAMPServer
MaciejBaj 9a25299
register add / remove peer functions in transactions
MaciejBaj 028cd62
web socket example test
MaciejBaj 93436fb
provide layer of rpc integrated with WS
MaciejBaj ed99bb4
update sinon to 2.0.0 v
MaciejBaj d8a8680
link to newest wamp-sc version
MaciejBaj 721a9b5
for travis fixes
MaciejBaj 0b84cbc
revert handshake in transport for http compatibility
MaciejBaj c8f9f7b
add rpc client in every peer instance
MaciejBaj 2f3480e
initialize rpc server in app file
MaciejBaj e17f414
fix RPC file
MaciejBaj fdf721d
change port header to int
MaciejBaj 0a31fca
include all internal transport fn and add basic fun tests
MaciejBaj b56ba27
fix indent
MaciejBaj 2bd3a6c
add condition for undefined trs
MaciejBaj e0e8903
initModule without node.js file
MaciejBaj 3bba706
merge with 446-ws-peers-rc
MaciejBaj 396fc3c
revert handshake in transport for http compatibility
MaciejBaj 1b3088f
add rpc client in every peer instance
MaciejBaj a776319
initialize rpc server in app file
MaciejBaj 05dc834
fix RPC file
MaciejBaj 73c2c9d
change port header to int
MaciejBaj 8c1630e
include all internal transport fn and add basic fun tests
MaciejBaj 4b5d86d
fix indent
MaciejBaj c8eac90
add condition for undefined trs
MaciejBaj 51d0ed8
fix handshake tests
MaciejBaj afbcd49
init worker process with data from master, include nonce
MaciejBaj 68ef8c8
rpc integration in process
MaciejBaj 3ec8539
attach rpc api in sync way
MaciejBaj 8f9a5cc
discovering peers via web sockets
MaciejBaj 3452194
include integration tests
MaciejBaj 5e8b87f
add me as peers getter
MaciejBaj 8e6bd9e
change getting transactions, signatures , common block, block into WS
MaciejBaj f2fb5b3
switch broadcasts into WS
MaciejBaj b2cdfc5
getSignatures and getTransactions as WS
MaciejBaj fea07cf
WSRPCServer as object not function
MaciejBaj d006779
test fixed
MaciejBaj 182ef79
remove shared logic from RPC fix tests
MaciejBaj 6727ca8
include nonce in randomPeer obj
MaciejBaj 4a4255b
rewrite unit tests after moving to WS
MaciejBaj 92aa012
use newest version of wamp-socket-cluster lib
MaciejBaj 4432221
remove unused files
MaciejBaj 02c89b5
prepare code for review
MaciejBaj 69aff6c
remove logs file
MaciejBaj e32539d
remove dockerfiles
MaciejBaj 8324ec9
ensure that folder exists before creating log file
MaciejBaj cda4dbb
add itself as frozen peer in test config.json
MaciejBaj 28676d8
peer.blocks func tests rewrite to WS
MaciejBaj 589e103
peer signature tests rewritten to WS
MaciejBaj 9b584f3
peers collision functional test rewritten to WS
MaciejBaj 427669e
peer delegates functional rewritten to WS
MaciejBaj 230a1a3
peer transaction main rewritten to WS
MaciejBaj 22de0ab
peer transaction signatures rewritten to WS
MaciejBaj 0244919
peer transactions stress rewritten to WS
MaciejBaj b06cddf
remove dapp support in peer communication
MaciejBaj f7576b0
remove opt http support
MaciejBaj 610d4b7
peer transaction votes rewritten to WS
MaciejBaj 2ec9f3e
revert removal of dapp requests messages in transport module
MaciejBaj 11214fe
integration tests fixes
MaciejBaj d4b5696
after merge with development changes
MaciejBaj 5cc3d11
peer transaction votes rewritten to WS
MaciejBaj 2fdf9d4
revert removal of dapp requests messages in transport module
MaciejBaj 5aaa8c0
integration tests fixes
MaciejBaj e8fc1ed
polishing before PR
MaciejBaj 604630e
fix workers controller paths so it works for build also
MaciejBaj 1146abc
socket cluster runs app.js file for every process
MaciejBaj e072740
get remote peer address from different field
MaciejBaj c25939b
changes after merge with 446-ws-peers-test
MaciejBaj edca46a
start separate processes from workersController file
MaciejBaj 8373ca1
initialize connection only once for every peer
MaciejBaj 83d4128
lazy establishing WS connection
MaciejBaj 07f8c99
event based WS handshake
MaciejBaj 44996cc
go back to handshake middleware
MaciejBaj 4f88cdb
update peers after sync fix
MaciejBaj 0447eaf
upsert peer after updated headers
MaciejBaj 86dd6ff
fix WS tests setup after changes in logic
MaciejBaj 370e8ba
add blocks propagation integration tests
MaciejBaj 85eb71b
fix tests and remove console logs
MaciejBaj 936dcce
fix calling same callback twice when seeding peers
MaciejBaj 52c7671
add new tests
MaciejBaj d18761c
broadcasting transactions and signatures fix
MaciejBaj dc80dad
always insert seed peers into peers list
MaciejBaj 02b0329
trace sync peers
MaciejBaj c79ccaa
change RPC client
MaciejBaj ab45e29
include obfuscating of workersController in build process
MaciejBaj 99af6bc
move workersController to root directory
MaciejBaj 9b6b94f
split RPC file into smaller modules
MaciejBaj 494b85c
use webpack to generate bundled workersController file
MaciejBaj d71a654
merge ws rpc features in one file
MaciejBaj a73d4c2
add commonjs2 webpack bundle option
MaciejBaj 7d6ad86
remove console logs
MaciejBaj 443117b
add transport/blocks functional test
MaciejBaj bdff334
revert unwanted changes against dev branch
MaciejBaj f1488b5
update headers with height and broadhash
MaciejBaj 1a7e8ef
fix peer undefined err
MaciejBaj 9a0659b
apply acceptable fn before inserting a peer
MaciejBaj 819bc9f
update peer after receiving post data from it
MaciejBaj 6cb6df6
change checking myself in acceptable function
MaciejBaj 15d12d7
fix peers list from having wrong height and broadhash sometimes
MaciejBaj 313ad33
Make separate ports for HTTP and WS connection configurable
MaciejBaj a66958a
fix http port assign from app parameters
MaciejBaj ca5290c
calculate broadhash more often
MaciejBaj 52f6323
peers acceptable fix
MaciejBaj cc31345
fix tests after http port change
MaciejBaj 3474dd5
count consensus every time when accessed
MaciejBaj 28079c3
add trace logging about myself when inserting peer
MaciejBaj 6e5a066
peers random list refactor
MaciejBaj aed51cc
tests fix
MaciejBaj d6a6279
change transaction log info from peer string to address
MaciejBaj d07b1d6
add logs for tracking connection with itself
MaciejBaj 75b7973
rely on nonce only while broadcasting data
MaciejBaj d32a96a
fix unit tests
MaciejBaj cb8afb8
peers logic unit tests fix
MaciejBaj cf26e08
fix forging on multiple nodes
MaciejBaj c457121
calculate consensus basing on max 100 matched peers
MaciejBaj 37ee125
after merge syntax fixes
MaciejBaj 0ecf5f5
functional and integration tests fix
MaciejBaj 4705bf7
apply indent eslint rule for switch case
MaciejBaj 5b8964b
Merge remote-tracking branch 'origin/1.0.0' into 446-ws-peers-rebased
MaciejBaj 8589a94
include peers functional tests in Jenkins build
MaciejBaj 8120a1e
fix functional and unit tests
MaciejBaj 1d2151e
Merge remote-tracking branch 'origin/1.0.0' into 446-ws-peers-rebased
MaciejBaj 830a150
copy workersController to new folder in build task
MaciejBaj 09830ba
Synchronize Jenkins file
b6ffb71
Add transport layer tests to Jenkinsfile
9f35dc9
Fix duplicate stage naming in Jenkinsfile
8baada3
change ws and http port numbers, log ip after trs received
MaciejBaj b365c5b
Merge remote-tracking branch 'origin/1.0.0' into 446-ws-peers-rebased
MaciejBaj ea21a3d
fix ws and http port switching tests
MaciejBaj 0b765c0
migrate from Q to bluebird
MaciejBaj 16ec4d4
switch http and ws ports in mainnet config.json
MaciejBaj 83eebec
get headers from modules/system instead of helpers/constants
MaciejBaj d416fef
after review changes
MaciejBaj d5a864f
Merge remote-tracking branch 'origin/1.0.0' into 446-ws-peers-rebased
MaciejBaj 963241e
extend handshake unit tests coverage
MaciejBaj 3bbbeef
read workers number from config file
MaciejBaj 475992d
restore chunking secrets between nodes in integration tests
MaciejBaj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,111 +0,0 @@ | ||
'use strict'; | ||
|
||
var Router = require('../../helpers/router'); | ||
var httpApi = require('../../helpers/httpApi'); | ||
var schema = require('../../schema/transport'); | ||
|
||
/** | ||
* Binds api with modules and creates common url. | ||
* - End point: `/peer` | ||
* - Private API: | ||
* - get /blocks/common | ||
* - get /blocks | ||
* - get /list | ||
* - get /height | ||
* - get /ping | ||
* - get /signatures | ||
* - get /transactions | ||
* - post /blocks | ||
* - post /signatures | ||
* - post /transactions | ||
* @memberof module:transport | ||
* @requires helpers/Router | ||
* @requires helpers/httpApi | ||
* @constructor | ||
* @param {Object} transportModule - Module transport instance. | ||
* @param {scope} app - Network app. | ||
* @param {function} logger | ||
*/ | ||
// Constructor | ||
function TransportHttpApi (transportModule, app, logger, cache) { | ||
|
||
var router = new Router(); | ||
|
||
router.use(httpApi.middleware.attachResponseHeaders.bind(null, transportModule.headers)); | ||
router.use(httpApi.middleware.blockchainReady.bind(null, transportModule.isLoaded)); | ||
|
||
router.use(handshakeMiddleware); | ||
|
||
router.get('/blocks/common', getCommonBlocksMiddleware); | ||
router.get('/blocks', httpApi.middleware.sanitize('query', schema.blocks, transportModule.internal.blocks)); | ||
|
||
router.map(transportModule.internal, { | ||
'get /list': 'list', | ||
'get /height': 'height', | ||
'get /ping': 'ping', | ||
'get /signatures': 'getSignatures', | ||
'get /transactions': 'getTransactions' | ||
|
||
}); | ||
|
||
// Custom parameters internal functions | ||
router.post('/blocks', function (req, res) { | ||
transportModule.internal.postBlock(req.body.block, req.peer, req.method + ' ' + req.url, httpApi.respond.bind(null, res)); | ||
}); | ||
|
||
router.post('/signatures', function (req, res) { | ||
transportModule.internal.postSignatures({signatures: req.body.signatures, signature: req.body.signature}, httpApi.respond.bind(null, res)); | ||
}); | ||
|
||
router.post('/transactions', function (req, res) { | ||
transportModule.internal.postTransactions({ | ||
transactions: req.body.transactions, | ||
transaction: req.body.transaction | ||
}, req.peer, req.method + ' ' + req.url, httpApi.respond.bind(null, res)); | ||
}); | ||
|
||
router.use(httpApi.middleware.notFound); | ||
|
||
app.use('/peer', router); | ||
|
||
function handshakeMiddleware (req, res, next) { | ||
transportModule.internal.handshake(req.ip, req.headers.port, req.headers, validateHeaders, function (err, peer) { | ||
if (err) { | ||
return res.status(500).send(err); | ||
} | ||
|
||
req.peer = peer; | ||
|
||
return next(); | ||
}); | ||
|
||
function validateHeaders (headers, cb) { | ||
return req.sanitize(headers, schema.headers, function (err, report, sanitized) { | ||
if (err) { | ||
return cb(err.toString()); | ||
} else if (!report.isValid) { | ||
return cb(report.issues); | ||
} | ||
|
||
return cb(); | ||
}); | ||
} | ||
} | ||
|
||
function getCommonBlocksMiddleware (req, res, next) { | ||
req.sanitize(req.query, schema.commonBlock, function (err, report, query) { | ||
if (err) { | ||
logger.debug('Common block request validation failed', {err: err.toString(), req: req.query}); | ||
return next(err); | ||
} | ||
if (!report.isValid) { | ||
logger.debug('Common block request validation failed', {err: report, req: req.query}); | ||
return res.json({success: false, error: report.issues}); | ||
} | ||
|
||
return transportModule.internal.blocksCommon(query.ids, req.peer, req.method + ' ' + req.url, httpApi.respond.bind(null, res)); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = TransportHttpApi; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not move those tests to
test/api/ws/....
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after discussion with @karmacoma we decided to move WS tests to
transport
folder and rename them accordingly