Skip to content

Commit

Permalink
Merge pull request #375 from anandrgitnirman/meter
Browse files Browse the repository at this point in the history
Isseu 374: Sender can also be a potential signer
  • Loading branch information
anandrgitnirman authored Aug 14, 2019
2 parents ad0282e + bd6943a commit ef56fc9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions escrow/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ func (validator *ChannelPaymentValidator) Validate(payment *Payment, channel *Pa
}

log = log.WithField("signerAddress", blockchain.AddressToHex(signerAddress))
if *signerAddress != channel.Signer {
log.WithField("signerAddress", blockchain.AddressToHex(signerAddress)).Warn("Channel signer is not equal to payment signer")
return NewPaymentError(Unauthenticated, "payment is not signed by channel signer")
if *signerAddress != channel.Signer && *signerAddress != channel.Sender {
log.WithField("signerAddress", blockchain.AddressToHex(signerAddress)).Warn("Channel signer is not equal to payment signer/sender")
return NewPaymentError(Unauthenticated, "payment is not signed by channel signer/sender")
}
currentBlock, e := validator.currentBlock()
if e != nil {
Expand Down
2 changes: 1 addition & 1 deletion escrow/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (suite *ValidationTestSuite) TestValidatePaymentIncorrectSigner() {

err := suite.validator.Validate(payment, suite.channel())

assert.Equal(suite.T(), NewPaymentError(Unauthenticated, "payment is not signed by channel signer"), err)
assert.Equal(suite.T(), NewPaymentError(Unauthenticated, "payment is not signed by channel signer/sender"), err)
}

func (suite *ValidationTestSuite) TestValidatePaymentChannelCannotGetCurrentBlock() {
Expand Down
9 changes: 8 additions & 1 deletion ratelimit/rateLimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/singnet/snet-daemon/config"
"golang.org/x/time/rate"
"math"
"strconv"
"time"
)

Expand All @@ -19,7 +20,13 @@ func NewRateLimiter() rate.Limiter {
}

func getLimit() rate.Limit {
ratePerMin := config.GetInt(config.RateLimitPerMinute)


ratePerMin, err := strconv.ParseFloat(config.GetString(config.RateLimitPerMinute), 32)
if err != nil {
return rate.Inf
}

//If the rate limit parameter Value is not defined we will assume it to be Infinity ( no Rate Limiting) ,
if ratePerMin == 0 {
return rate.Inf
Expand Down
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ for d in */ ; do
done
echo "mode: set">>coverage.out
grep -h -v "mode: set" *.part >>coverage.out
# /go/bin/goveralls -coverprofile=coverage.out -service=circleci -repotoken ${COVERALLS_REPO_TOKEN}
/go/bin/goveralls -coverprofile=coverage.out -service=circleci -repotoken ${COVERALLS_REPO_TOKEN}
popd

0 comments on commit ef56fc9

Please sign in to comment.