Skip to content

Commit

Permalink
Merge Bid and Payment messages, add way to specify dynamic job cost o…
Browse files Browse the repository at this point in the history
…n completion, add api to wait for payments
  • Loading branch information
riccardobl committed Jun 1, 2024
1 parent 1a16b48 commit f33efcb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 32 deletions.
10 changes: 0 additions & 10 deletions proto/Bid.proto

This file was deleted.

3 changes: 1 addition & 2 deletions proto/Job.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "JobInput.proto";
import "JobState.proto";
import "JobResult.proto";
import "Payment.proto";
import "Bid.proto";

option php_namespace = 'App\\Grpc\\nostr';
option php_metadata_namespace = 'App\\Grpc\\nostr\\GPBMetadata';
Expand Down Expand Up @@ -44,7 +43,7 @@ message Job {
string outputFormat = 16;
optional bool encrypted = 17;

optional Bid bid = 19;
optional Payment bid = 19;



Expand Down
2 changes: 1 addition & 1 deletion proto/Payment.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ option php_metadata_namespace = 'App\\Grpc\\nostr\\GPBMetadata';
import "PaymentStatus.proto";

message Payment {
string id = 1;
optional string id = 1;
uint64 amount = 2;
string currency = 3;
string protocol = 4;
Expand Down
11 changes: 6 additions & 5 deletions proto/PaymentStatus.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ option php_namespace = 'App\\Grpc\\nostr';
option php_metadata_namespace = 'App\\Grpc\\nostr\\GPBMetadata';

enum PaymentStatus {
PAYMENT_SENT = 0;
PAYMENT_RECEIVED = 1;
PAYMENT_REFUNDED = 2;
PAYMENT_FAILED = 3;
PAYMENT_PENDING = 4;
PAYMENT_REQUESTED = 0;
PAYMENT_SENT = 1;
PAYMENT_RECEIVED = 2;
PAYMENT_REFUNDED = 3;
PAYMENT_FAILED = 4;
PAYMENT_PENDING = 5;
PAYMENT_UNKNOWN_STATUS = 99;
}
28 changes: 14 additions & 14 deletions proto/rpc.proto
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
syntax = "proto3";

import "Log.proto";
import "JobStatus.proto";
import "JobState.proto";
import "JobParam.proto";
import "JobInput.proto";
import "JobResult.proto";
import "Job.proto";
import "Payment.proto";
import "PaymentStatus.proto";
import "Bid.proto";

option php_namespace = 'App\\Grpc\\nostr';
option php_metadata_namespace = 'App\\Grpc\\nostr\\GPBMetadata';
Expand All @@ -25,7 +20,7 @@ message RpcRequestJob {
optional bool encrypted = 10;
optional string userId = 11;
optional uint32 minWorkers = 12;
optional Bid bid = 13;
optional Payment bid = 13;
}

message RpcGetJob {
Expand All @@ -43,7 +38,7 @@ message RpcGetPendingJobs {
optional string filterByDescription = 3;
optional string filterById = 4;
optional string filterByKind = 5;
repeated Bid filterByBids = 6;
repeated Payment filterByBids = 6;
repeated string excludeId = 98; // which job ids to exclude, optional
optional uint32 wait = 99; // max time to wait in ms , 0 or unset means no wait

Expand Down Expand Up @@ -76,6 +71,17 @@ message RpcJobComplete{
string jobId = 1;
string output = 2;
optional string info = 3;
optional Payment cost = 4;
}

message RpcRequestPayment{
optional Payment payment = 1;
optional bool waitForPayments = 2 ;

}

message RpcRequestPaymentResponse{
PaymentStatus status=1;
}

message RpcJobLog {
Expand Down Expand Up @@ -320,6 +326,7 @@ service PoolConnector {
rpc completeJob(RpcJobComplete) returns (Job);
rpc logForJob(RpcJobLog) returns (Job);
rpc payJob(RpcPayJobRequest) returns (Job);
rpc requestPayment(RpcRequestPayment) returns (RpcRequestPaymentResponse);


// discovery
Expand Down Expand Up @@ -357,13 +364,6 @@ service PoolConnector {
rpc cacheGet(RpcCacheGetRequest) returns (stream RpcCacheGetResponse);


// pay
// rpc requestPayment(RpcRequestPayment) returns (RpcRequestPaymentResponse);
// rpc cancelAndRefundPayment(RpcCancelAndRefundPayment) returns (RpcCancelAndRefundPaymentResponse);

// rpc getPayment(RpcGetPayment) returns (RpcGetPaymentResponse);
// rpc sendPayment(RpcSendPayment) returns (RpcSendPaymentResponse);




Expand Down

0 comments on commit f33efcb

Please sign in to comment.