Merge pull request #40 from kdeme/bug/temp-fix-32bit-issue

Quick fix for overflow on 32bit systems
This commit is contained in:
Eugene Kabanov 2019-04-12 22:10:32 +03:00 committed by GitHub
commit 29407afeb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -175,9 +175,8 @@ proc updateRechargingParams(peer: LesPeer, network: LesNetwork) =
peer.reqCostGradient = rechargingScale / network.reqCount
if peer.isRecharging:
peer.reqCostGradient = (network.rechargingRate * peer.rechargingPower /
network.totalRechargingPower )
peer.reqCostGradient = (network.rechargingRate * (peer.rechargingPower /
network.totalRechargingPower).int64).int
peer.rechargingEndsAt = peer.lastRechargeTime +
LesTime(peer.reqCostVal * rechargingScale /
-peer.reqCostGradient )
@ -263,8 +262,8 @@ proc delistFromFlowControl*(network: LesNetwork, peer: LesPeer) =
proc initFlowControl*(network: LesNetwork, les: ProtocolInfo,
maxReqCount, maxReqCostSum, reqCostTarget: int,
db: AbstractChainDB = nil) =
network.rechargingRate = (rechargingScale * rechargingScale) /
(100 * rechargingScale / reqCostTarget - rechargingScale)
network.rechargingRate = rechargingScale * (rechargingScale /
(100 * rechargingScale / reqCostTarget - rechargingScale))
network.maxReqCount = maxReqCount
network.maxReqCostSum = maxReqCostSum

View File

@ -85,7 +85,7 @@ type
reqCount*, maxReqCount*: int
sumWeigth*: int
rechargingRate*: int
rechargingRate*: int64
totalRechargedUnits*: int
totalRechargingPower*: int