Skip to content

Commit

Permalink
Merge pull request #368 from anandrgitnirman/etcdcheckout
Browse files Browse the repository at this point in the history
When blockchain is disabled , do not use ETCD
  • Loading branch information
anandrgitnirman authored Aug 8, 2019
2 parents 5b3b795 + 5566a5e commit 69f541d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
2 changes: 2 additions & 0 deletions blockchain/orginzationMetadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ func GetOrganizationMetaData() *OrganizationMetaData {
if config.GetBool(config.BlockchainEnabledKey) {
ipfsHash := string(getMetaDataURI())
metadata, err = GetOrganizationMetaDataFromIPFS(FormatHash(ipfsHash))
} else {
metadata = &OrganizationMetaData{daemonGroup:&Group{}}
}
if err != nil {
log.WithError(err).
Expand Down
17 changes: 17 additions & 0 deletions escrow/control_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ type ProviderControlService struct {
mpeAddress common.Address
}


type BlockChainDisabledProviderControlService struct {

}

func (service *BlockChainDisabledProviderControlService) GetListUnclaimed(ctx context.Context, request *GetPaymentsListRequest) (paymentReply *PaymentsListReply, err error) {
return &PaymentsListReply{},nil
}

func (service *BlockChainDisabledProviderControlService) GetListInProgress(ctx context.Context, request *GetPaymentsListRequest) (reply *PaymentsListReply, err error) {
return &PaymentsListReply{},nil
}

func (service *BlockChainDisabledProviderControlService) StartClaim(ctx context.Context, startClaim *StartClaimRequest) (paymentReply *PaymentReply, err error) {
return &PaymentReply{},nil
}

func NewProviderControlService(channelService PaymentChannelService, serMetaData *blockchain.ServiceMetadata,
orgMetadata *blockchain.OrganizationMetaData) *ProviderControlService {
return &ProviderControlService{
Expand Down
8 changes: 8 additions & 0 deletions escrow/state_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ type PaymentChannelStateService struct {
mpeAddress func() (address common.Address)
}

type BlockChainDisabledStateService struct {

}

func (service *BlockChainDisabledStateService) GetChannelState(context context.Context, request *ChannelStateRequest) (reply *ChannelStateReply, err error) {
return &ChannelStateReply{},nil
}

// verifies whether storage channel nonce is equal to blockchain nonce or not
func (service *PaymentChannelStateService) StorageNonceMatchesWithBlockchainNonce(storageChannel *PaymentChannelData) (equal bool, err error) {
h := service.channelService
Expand Down
12 changes: 10 additions & 2 deletions snetd/cmd/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,11 @@ func (components *Components) GrpcPaymentValidationInterceptor() grpc.StreamServ
}
}

func (components *Components) PaymentChannelStateService() (service *escrow.PaymentChannelStateService) {
func (components *Components) PaymentChannelStateService() (service escrow.PaymentChannelStateServiceServer) {
if !config.GetBool(config.BlockchainEnabledKey){
return &escrow.BlockChainDisabledStateService{}
}

if components.paymentChannelStateService != nil {
return components.paymentChannelStateService
}
Expand All @@ -285,7 +289,11 @@ func (components *Components) PaymentChannelStateService() (service *escrow.Paym

//NewProviderControlService

func (components *Components) ProviderControlService() (service *escrow.ProviderControlService) {
func (components *Components) ProviderControlService() (service escrow.ProviderControlServiceServer) {

if !config.GetBool(config.BlockchainEnabledKey){
return &escrow.BlockChainDisabledProviderControlService{}
}
if components.providerControlService != nil {
return components.providerControlService
}
Expand Down

0 comments on commit 69f541d

Please sign in to comment.