Skip to content

Commit

Permalink
Improved events
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrinivas8687 committed Aug 14, 2023
1 parent 346c3ea commit e45b878
Show file tree
Hide file tree
Showing 21 changed files with 2,641 additions and 548 deletions.
9 changes: 5 additions & 4 deletions proto/sentinel/node/v2/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ message EventUpdateDetails {
}

message EventUpdateStatus {
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
sentinel.types.v1.Status status = 2
sentinel.types.v1.Status status = 1
[ (gogoproto.moretags) = "yaml:\"status\"" ];
string address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
}

message EventCreateSubscription {
uint64 id = 1
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string node_address = 2 [ (gogoproto.moretags) = "yaml:\"node_address\"" ];
uint64 id = 3
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
}
27 changes: 17 additions & 10 deletions proto/sentinel/plan/v2/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,40 @@ option (gogoproto.equal_all) = false;
option (gogoproto.goproto_getters_all) = false;

message EventCreate {
uint64 id = 1
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
uint64 id = 2
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
}

message EventUpdateStatus {
uint64 id = 1
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
sentinel.types.v1.Status status = 3
sentinel.types.v1.Status status = 1
[ (gogoproto.moretags) = "yaml:\"status\"" ];
string address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
uint64 id = 3
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
}

message EventLinkNode {
uint64 id = 1
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string node_address = 2 [ (gogoproto.moretags) = "yaml:\"node_address\"" ];
uint64 id = 3
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
string address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
}

message EventUnlinkNode {
uint64 id = 1
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string node_address = 2 [ (gogoproto.moretags) = "yaml:\"node_address\"" ];
uint64 id = 3
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
string address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
}

message EventCreateSubscription {
uint64 id = 1
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string provider_address = 2
[ (gogoproto.moretags) = "yaml:\"provider_address\"" ];
uint64 id = 3
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
uint64 plan_id = 2 [
uint64 plan_id = 4 [
(gogoproto.customname) = "PlanID",
(gogoproto.moretags) = "yaml:\"plan_id\""
];
Expand Down
37 changes: 26 additions & 11 deletions proto/sentinel/session/v2/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,48 @@ option (gogoproto.equal_all) = false;
option (gogoproto.goproto_getters_all) = false;

message EventStart {
uint64 id = 1
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string node_address = 2 [ (gogoproto.moretags) = "yaml:\"node_address\"" ];
uint64 id = 3
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
uint64 subscription_id = 2 [
uint64 plan_id = 4 [
(gogoproto.customname) = "PlanID",
(gogoproto.moretags) = "yaml:\"plan_id\""
];
uint64 subscription_id = 5 [
(gogoproto.customname) = "SubscriptionID",
(gogoproto.moretags) = "yaml:\"subscription_id\""
];
string node_address = 3 [ (gogoproto.moretags) = "yaml:\"node_address\"" ];
}

message EventUpdateDetails {
uint64 id = 1
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string node_address = 2 [ (gogoproto.moretags) = "yaml:\"node_address\"" ];
uint64 id = 3
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
uint64 subscription_id = 2 [
uint64 plan_id = 4 [
(gogoproto.customname) = "PlanID",
(gogoproto.moretags) = "yaml:\"plan_id\""
];
uint64 subscription_id = 5 [
(gogoproto.customname) = "SubscriptionID",
(gogoproto.moretags) = "yaml:\"subscription_id\""
];
string node_address = 3 [ (gogoproto.moretags) = "yaml:\"node_address\"" ];
}

message EventUpdateStatus {
uint64 id = 1
sentinel.types.v1.Status status = 1
[ (gogoproto.moretags) = "yaml:\"status\"" ];
string address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string node_address = 3 [ (gogoproto.moretags) = "yaml:\"node_address\"" ];
uint64 id = 4
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
uint64 subscription_id = 2 [
uint64 plan_id = 5 [
(gogoproto.customname) = "PlanID",
(gogoproto.moretags) = "yaml:\"plan_id\""
];
uint64 subscription_id = 6 [
(gogoproto.customname) = "SubscriptionID",
(gogoproto.moretags) = "yaml:\"subscription_id\""
];
string node_address = 3 [ (gogoproto.moretags) = "yaml:\"node_address\"" ];
sentinel.types.v1.Status status = 4
[ (gogoproto.moretags) = "yaml:\"status\"" ];
}
75 changes: 64 additions & 11 deletions proto/sentinel/subscription/v2/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,78 @@ option (gogoproto.equal_all) = false;
option (gogoproto.goproto_getters_all) = false;

message EventUpdateStatus {
uint64 id = 1
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
sentinel.types.v1.Status status = 2
sentinel.types.v1.Status status = 1
[ (gogoproto.moretags) = "yaml:\"status\"" ];
string address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
uint64 id = 3
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
uint64 plan_id = 4 [
(gogoproto.customname) = "PlanID",
(gogoproto.moretags) = "yaml:\"plan_id\""
];
}

message EventAllocate {
uint64 id = 1
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
string address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string bytes = 3 [
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string granted_bytes = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
string utilised_bytes = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
uint64 id = 4
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
}

message EventCreatePayout {
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string node_address = 2 [ (gogoproto.moretags) = "yaml:\"node_address\"" ];
uint64 id = 3
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
}

message EventPayForPayout {
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string node_address = 2 [ (gogoproto.moretags) = "yaml:\"node_address\"" ];
string payment = 3 [ (gogoproto.moretags) = "yaml:\"payment\"" ];
string staking_reward = 4
[ (gogoproto.moretags) = "yaml:\"staking_reward\"" ];
uint64 id = 5
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
}

message EventPayout {
uint64 id = 1
message EventPayForPlan {
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string payment = 2 [ (gogoproto.moretags) = "yaml:\"payment\"" ];
string provider_address = 3
[ (gogoproto.moretags) = "yaml:\"provider_address\"" ];
string staking_reward = 4
[ (gogoproto.moretags) = "yaml:\"staking_reward\"" ];
uint64 id = 5
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
string address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string node_address = 3 [ (gogoproto.moretags) = "yaml:\"node_address\"" ];
}

message EventPayForSession {
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string node_address = 2 [ (gogoproto.moretags) = "yaml:\"node_address\"" ];
string payment = 3 [ (gogoproto.moretags) = "yaml:\"payment\"" ];
string staking_reward = 4
[ (gogoproto.moretags) = "yaml:\"staking_reward\"" ];
uint64 session_id = 5 [
(gogoproto.customname) = "SessionID",
(gogoproto.moretags) = "yaml:\"session_id\""
];
uint64 subscription_id = 6 [
(gogoproto.customname) = "SubscriptionID",
(gogoproto.moretags) = "yaml:\"subscription_id\""
];
}

message EventRefund {
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
string amount = 2 [ (gogoproto.moretags) = "yaml:\"amount\"" ];
uint64 id = 3
[ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ];
}
8 changes: 7 additions & 1 deletion x/node/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ func (k *Keeper) EndBlock(ctx sdk.Context) []abcitypes.ValidatorUpdate {
}

k.SetNode(ctx, item)
ctx.EventManager().EmitTypedEvent(
&types.EventUpdateDetails{
Address: item.Address,
},
)

return false
})
}
Expand All @@ -113,8 +119,8 @@ func (k *Keeper) EndBlock(ctx sdk.Context) []abcitypes.ValidatorUpdate {
k.SetNode(ctx, item)
ctx.EventManager().EmitTypedEvent(
&types.EventUpdateStatus{
Address: item.Address,
Status: hubtypes.StatusInactive,
Address: item.Address,
},
)

Expand Down
5 changes: 3 additions & 2 deletions x/node/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ func (k *msgServer) MsgUpdateStatus(c context.Context, msg *types.MsgUpdateStatu
// Emit an event to notify that the node status has been updated.
ctx.EventManager().EmitTypedEvent(
&types.EventUpdateStatus{
Address: node.Address,
Status: node.Status,
Address: node.Address,
},
)

Expand Down Expand Up @@ -246,8 +246,9 @@ func (k *msgServer) MsgSubscribe(c context.Context, msg *types.MsgSubscribeReque
// Emit an event to notify that a new subscription has been created.
ctx.EventManager().EmitTypedEvent(
&types.EventCreateSubscription{
ID: subscription.ID,
Address: subscription.Address,
NodeAddress: subscription.NodeAddress,
ID: subscription.ID,
},
)

Expand Down
Loading

0 comments on commit e45b878

Please sign in to comment.