Skip to content

Commit

Permalink
Merge branch 'development' into testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
vekexasia committed Sep 19, 2018
2 parents d8a328b + c47e5f0 commit 29726d2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/apis/transportv2API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,7 @@ export class TransportV2API {
where: { id: lastBlockId },
});
if (lastBlock != null) {
// TODO: We limit the number of blocks to return to not overload this node.
// We might implement a way to avoid spamming nodes by using some kind of PoW upon requesting the block. or by limiting this
// endpoint on the IP requesting the resource.
const blocksToLoad = Math.ceil(Math.min(500, (await this.calcNumBlocksToLoad(lastBlock)) * 0.5));
const blocksToLoad = await this.calcNumBlocksToLoad(lastBlock);
const dbBlocks = await this.blocksModuleUtils.loadBlocksData({
lastId: lastBlockId,
limit: blocksToLoad,
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default {
maxConfirmations : 77 * 100,
maxPayloadLength : 1024 * 1024,
maxPeers : 100,
maxProtoBufPayloadLength : 1572864, // (1.5MB) Maximum number of bytes for a Protocol Buffer Request/Response Body
maxProtoBufPayloadLength : 100 * 1024, // (100KB) Maximum number of bytes for a Protocol Buffer Request/Response Body
maxRequests : 10000 * 12,
maxSharedTxs : 100,
maxSignaturesLength : 196 * 256,
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/apis/transportV2API.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,21 +584,21 @@ describe('apis/transportV2API', () => {
});
});

it('should call loadBlocksData with limit 500 ', async () => {
it('should call loadBlocksData with limit 2100 ', async () => {
await instance.getBlocks('123');
expect(blocksSubmoduleUtilsStub.stubs.loadBlocksData.calledOnce).to.be.true;
expect(blocksSubmoduleUtilsStub.stubs.loadBlocksData.firstCall.args).to.be.deep.equal([{
lastId: '123',
limit : 500,
limit : 2100,
}]);
});
it('should call loadBlocksData with limit 400 ', async () => {
it('should call loadBlocksData with limit 800 ', async () => {
numblocksToLoadStub.resolves(800);
await instance.getBlocks('123');
expect(blocksSubmoduleUtilsStub.stubs.loadBlocksData.calledOnce).to.be.true;
expect(blocksSubmoduleUtilsStub.stubs.loadBlocksData.firstCall.args).to.be.deep.equal([{
lastId: '123',
limit : 400,
limit : 800,
}]);
});

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/logic/peers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,13 @@ describe('logic/peers', () => {

it('should return true if removal was less than 15 minutes ago', () => {
(instance as any).lastRemoved = {};
(instance as any).lastRemoved[peerLogicStub.string] = Date.now() - config.peers.banTime + 1;
(instance as any).lastRemoved[peerLogicStub.string] = Date.now() - config.peers.banTime + 1000;
expect((instance as any).wasRecentlyRemoved(peerLogicStub)).to.be.true;
});

it('should return false if removal was more than 15 minutes ago', () => {
(instance as any).lastRemoved = {};
(instance as any).lastRemoved[peerLogicStub.string] = Date.now() - config.peers.banTime - 1;
(instance as any).lastRemoved[peerLogicStub.string] = Date.now() - config.peers.banTime - 1000;
expect((instance as any).wasRecentlyRemoved(peerLogicStub)).to.be.false;
});
});
Expand Down

0 comments on commit 29726d2

Please sign in to comment.