Skip to content

Commit a44764a

Browse files
committed
Merge branch 'master' into dev
# Conflicts: # go.mod # go.sum
2 parents 427425d + 7c61949 commit a44764a

File tree

11 files changed

+30
-37
lines changed

11 files changed

+30
-37
lines changed

.github/workflows/sonar.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,14 @@ on:
44
push:
55
branches:
66
- master
7-
- dev
87
- development
8+
- dev
99
pull_request:
1010
types: [opened, synchronize, reopened]
1111

12+
workflow_dispatch:
13+
1214
jobs:
13-
build:
14-
name: Build and analyze
15-
runs-on: ubuntu-latest
16-
17-
steps:
18-
- uses: actions/checkout@v4
19-
with:
20-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
21-
- uses: SonarSource/sonarqube-scan-action@v6.0.0
22-
env:
23-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
24-
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
15+
sonar:
16+
uses: singnet/security-workflows/.github/workflows/sonar.yml@master
17+
secrets: inherit

blockchain/org_metadata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func InitOrganizationMetaDataFromJson(jsonData []byte) (metaData *OrganizationMe
123123

124124
func checkMandatoryFields(metaData *OrganizationMetaData) (err error) {
125125
if metaData.daemonGroup.PaymentDetails.PaymentChannelStorageClient.Endpoints == nil {
126-
err = fmt.Errorf("Mandatory field : ETCD Client Endpoints are mising for the Group %v ", metaData.daemonGroup.GroupName)
126+
err = fmt.Errorf("Mandatory field : ETCD Client Endpoints are missing for the Group %v ", metaData.daemonGroup.GroupName)
127127
}
128128

129129
if metaData.recipientPaymentAddress == (common.Address{}) {

escrow/escrow.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
// lockingPaymentChannelService implements PaymentChannelService interface
1212
// using locks around proxied service call to guarantee that only one payment
13-
// at time is applied to channel
13+
// at a time is applied to channel
1414
type lockingPaymentChannelService struct {
1515
storage *PaymentChannelStorage
1616
paymentStorage *PaymentStorage
@@ -52,8 +52,8 @@ func (h *lockingPaymentChannelService) PaymentChannel(key *PaymentChannelKey) (c
5252
blockchainChannel, blockchainOk, err := h.blockchainReader.GetChannelStateFromBlockchain(key)
5353

5454
if !storageOk {
55-
// Group ID check is only done for the first time, when the channel is added to storage from the blockchain,
56-
// if the channel is already present in the storage, the group ID check is skipped.
55+
// Group ID check is only done for the first time, when the channel is added to storage from the blockchain.
56+
// If the channel is already present in the storage, the group ID check is skipped.
5757
if blockchainChannel != nil {
5858
blockChainGroupID := h.replicaGroupID()
5959
if err = h.verifyGroupId(blockChainGroupID, blockchainChannel.GroupID); err != nil {

escrow/payment_channel_storage.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (storage *PaymentChannelStorage) Put(key *PaymentChannelKey, state *Payment
7878
return storage.delegate.Put(key, state)
7979
}
8080

81-
// PutIfAbsent storage payment channel by key if key is absent
81+
// PutIfAbsent stores a payment channel by key if the key is absent
8282
func (storage *PaymentChannelStorage) PutIfAbsent(key *PaymentChannelKey, state *PaymentChannelData) (ok bool, err error) {
8383
return storage.delegate.PutIfAbsent(key, state)
8484
}
@@ -107,7 +107,7 @@ func NewBlockchainChannelReader(processor blockchain.Processor, cfg *viper.Viper
107107
}
108108

109109
// GetChannelStateFromBlockchain returns channel state from Ethereum
110-
// blockchain. ok is false if channel was not found.
110+
// blockchain. ok is false if the channel is not found.
111111
func (reader *BlockchainChannelReader) GetChannelStateFromBlockchain(key *PaymentChannelKey) (channel *PaymentChannelData, ok bool, err error) {
112112
ch, ok, err := reader.readChannelFromBlockchain(key.ID)
113113
if err != nil || !ok {

escrow/payment_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (h *paymentChannelPaymentHandler) Payment(context *handler.GrpcStreamContex
6060
income.Sub(internalPayment.Amount, transaction.Channel().AuthorizedAmount)
6161
e = h.incomeValidator.Validate(&IncomeStreamData{Income: income, GrpcContext: context})
6262
if e != nil {
63-
//Make sure the transaction is Rolled back , else this will cause a lock on the channel
63+
// Make sure the transaction is rolled back, else this will cause a lock on the channel
6464
transaction.Rollback()
6565
return nil, paymentErrorToGrpcError(e)
6666
}

escrow/state_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (service *BlockChainDisabledStateService) GetChannelState(context context.C
4646
return &ChannelStateReply{}, nil
4747
}
4848

49-
// verifies whether storage channel nonce is equal to blockchain nonce or not
49+
// StorageNonceMatchesWithBlockchainNonce verifies whether storage channel nonce is equal to blockchain nonce or not
5050
func (service *PaymentChannelStateService) StorageNonceMatchesWithBlockchainNonce(storageChannel *PaymentChannelData) (equal bool, err error) {
5151
h := service.channelService
5252

@@ -128,7 +128,7 @@ func (service *PaymentChannelStateService) GetChannelState(context context.Conte
128128
return nil, err
129129

130130
} else if !nonceEqual {
131-
// check for payments in the payment storage with current nonce - 1, this will happen cli has issues in claiming process
131+
// check for payments in the payment storage with current nonce - 1, this will happen if cli has issues in claiming process
132132

133133
paymentID := PaymentID(channel.ChannelID, (&big.Int{}).Sub(channel.Nonce, big.NewInt(1)))
134134
payment, ok, err := service.paymentStorage.Get(paymentID)

escrow/token_service.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (service *TokenService) verifySignatureAndSignedAmountEligibility(channelId
8080
if channel.FullAmount.Cmp(latestAuthorizedAmount) < 0 {
8181
return nil, fmt.Errorf("signed amount for token request cannot be greater than full amount in channel")
8282
}
83-
//verify signature
83+
// Verify signature
8484
signer, err := service.verifySignature(request, channel)
8585
if err != nil {
8686
return nil, err
@@ -89,7 +89,7 @@ func (service *TokenService) verifySignatureAndSignedAmountEligibility(channelId
8989
if err = service.validator.Validate(payment, channel); err != nil {
9090
return nil, err
9191
}
92-
//update the channel Signature if you have a new Signed Amount received
92+
// Update the channel Signature if you have a new Signed Amount received
9393
if latestAuthorizedAmount.Cmp(channel.AuthorizedAmount) > 0 {
9494
transaction, err := service.channelService.StartPaymentTransaction(payment)
9595
if err != nil {
@@ -140,7 +140,7 @@ func (service *TokenService) verifySignature(request *TokenRequest, channel *Pay
140140

141141
func (service *TokenService) GetToken(ctx context.Context, request *TokenRequest) (reply *TokenReply, err error) {
142142

143-
//Check for update state
143+
// Check for update state
144144
channelID := big.NewInt(0).SetUint64(request.ChannelId)
145145
latestAuthorizedAmount := big.NewInt(0).SetUint64(request.SignedAmount)
146146

escrow/train_pay_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (t trainStreamPaymentHandler) Payment(context *handler.GrpcStreamContext) (
4848
income.Sub(internalPayment.Amount, transaction.Channel().AuthorizedAmount)
4949
e = t.incomeValidator.Validate(&IncomeStreamData{Income: income, GrpcContext: context})
5050
if e != nil {
51-
//Make sure the transaction is Rolled back , else this will cause a lock on the channel
51+
// Make sure the transaction is rolled back, else this will cause a lock on the channel
5252
transaction.Rollback()
5353
return nil, paymentErrorToGrpcError(e)
5454
}
@@ -143,7 +143,7 @@ func (h *trainUnaryPaymentHandler) Payment(context *handler.GrpcUnaryContext) (p
143143
income.Sub(internalPayment.Amount, transaction.Channel().AuthorizedAmount)
144144
e = h.incomeValidator.Validate(&IncomeUnaryData{Income: income, GrpcContext: context})
145145
if e != nil {
146-
//Make sure the transaction is Rolled back , else this will cause a lock on the channel
146+
// Make sure the transaction is rolled back, else this will cause a lock on the channel
147147
transaction.Rollback()
148148
return nil, paymentErrorToGrpcError(e)
149149
}

handler/stream_interceptor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ const (
4545
// PaymentChannelSignatureHeader is a signature of the client to confirm
4646
// amount withdrawing authorization. Value is an array of bytes.
4747
PaymentChannelSignatureHeader = "snet-payment-channel-signature-bin"
48-
// This is useful information in the header sent in by the client
48+
// This is useful information in the header sent by the client
4949
// All clients will have this information and they need this to Sign anyways
50-
// When Daemon is running in the block chain disabled mode , it would use this
50+
// When Daemon is running in the block chain disabled mode, it would use this
5151
// header to get the MPE address. The goal here is to keep the client oblivious to the
5252
// Daemon block chain enabled or disabled mode and also standardize the signatures.
5353
// id. Value is a string containing a decimal number.

pricing/fixed_method_pricing.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import (
99
)
1010

1111
type FixedMethodPrice struct {
12-
//Service/Method is the key and value is he price
12+
// Service/Method is the key and value is the price
1313
methodToPriceMap map[string]*big.Int
1414
}
1515

1616
func (priceType FixedMethodPrice) GetPrice(GrpcContext *handler.GrpcStreamContext) (price *big.Int, err error) {
17-
//The returned string is in the format of "/packagename.service/method", for example /example_service.Calculator/mul
17+
// The returned string is in the format of "/packagename.service/method", for example /example_service.Calculator/mul
1818
methodName := GrpcContext.Info.FullMethod
1919
if price, ok := priceType.methodToPriceMap[methodName]; !ok {
2020
return nil, fmt.Errorf("price is not defined for the Method %v", methodName)

0 commit comments

Comments
 (0)