From e45b878864db2f05c0e899562c65393463f18fad Mon Sep 17 00:00:00 2001 From: Srinivas Baride Date: Mon, 14 Aug 2023 06:54:28 +0530 Subject: [PATCH] Improved events --- proto/sentinel/node/v2/events.proto | 9 +- proto/sentinel/plan/v2/events.proto | 27 +- proto/sentinel/session/v2/events.proto | 37 +- proto/sentinel/subscription/v2/events.proto | 75 +- x/node/keeper/abci.go | 8 +- x/node/keeper/msg_server.go | 5 +- x/node/types/events.pb.go | 174 +- x/plan/keeper/msg_server.go | 24 +- x/plan/types/events.pb.go | 432 ++++- x/session/keeper/abci.go | 16 +- x/session/keeper/hooks.go | 6 +- x/session/keeper/msg_server.go | 40 +- x/session/types/events.pb.go | 475 ++++-- x/subscription/expected/keeper.go | 2 + x/subscription/keeper/abci.go | 45 +- x/subscription/keeper/alias.go | 5 + x/subscription/keeper/hooks.go | 51 +- x/subscription/keeper/migrator.go | 4 +- x/subscription/keeper/msg_server.go | 28 +- x/subscription/keeper/subscription.go | 29 +- x/subscription/types/events.pb.go | 1697 +++++++++++++++++-- 21 files changed, 2641 insertions(+), 548 deletions(-) diff --git a/proto/sentinel/node/v2/events.proto b/proto/sentinel/node/v2/events.proto index 0ac9e810..44a1dc3a 100644 --- a/proto/sentinel/node/v2/events.proto +++ b/proto/sentinel/node/v2/events.proto @@ -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\"" ]; } diff --git a/proto/sentinel/plan/v2/events.proto b/proto/sentinel/plan/v2/events.proto index f216a333..df2fadfb 100644 --- a/proto/sentinel/plan/v2/events.proto +++ b/proto/sentinel/plan/v2/events.proto @@ -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\"" ]; diff --git a/proto/sentinel/session/v2/events.proto b/proto/sentinel/session/v2/events.proto index 0f105cbc..08c9fab6 100644 --- a/proto/sentinel/session/v2/events.proto +++ b/proto/sentinel/session/v2/events.proto @@ -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\"" ]; } diff --git a/proto/sentinel/subscription/v2/events.proto b/proto/sentinel/subscription/v2/events.proto index bc4abefe..d61b0083 100644 --- a/proto/sentinel/subscription/v2/events.proto +++ b/proto/sentinel/subscription/v2/events.proto @@ -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\"" ]; +} \ No newline at end of file diff --git a/x/node/keeper/abci.go b/x/node/keeper/abci.go index f947a8ca..b84bcba0 100644 --- a/x/node/keeper/abci.go +++ b/x/node/keeper/abci.go @@ -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 }) } @@ -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, }, ) diff --git a/x/node/keeper/msg_server.go b/x/node/keeper/msg_server.go index 8be80b27..4f86b02b 100644 --- a/x/node/keeper/msg_server.go +++ b/x/node/keeper/msg_server.go @@ -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, }, ) @@ -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, }, ) diff --git a/x/node/types/events.pb.go b/x/node/types/events.pb.go index ed85bff2..f2cc43fe 100644 --- a/x/node/types/events.pb.go +++ b/x/node/types/events.pb.go @@ -99,8 +99,8 @@ func (m *EventUpdateDetails) XXX_DiscardUnknown() { var xxx_messageInfo_EventUpdateDetails proto.InternalMessageInfo type EventUpdateStatus struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` - Status types.Status `protobuf:"varint,2,opt,name=status,proto3,enum=sentinel.types.v1.Status" json:"status,omitempty" yaml:"status"` + Status types.Status `protobuf:"varint,1,opt,name=status,proto3,enum=sentinel.types.v1.Status" json:"status,omitempty" yaml:"status"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` } func (m *EventUpdateStatus) Reset() { *m = EventUpdateStatus{} } @@ -137,8 +137,9 @@ func (m *EventUpdateStatus) XXX_DiscardUnknown() { var xxx_messageInfo_EventUpdateStatus proto.InternalMessageInfo type EventCreateSubscription struct { - ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` NodeAddress string `protobuf:"bytes,2,opt,name=node_address,json=nodeAddress,proto3" json:"node_address,omitempty" yaml:"node_address"` + ID uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` } func (m *EventCreateSubscription) Reset() { *m = EventCreateSubscription{} } @@ -184,31 +185,31 @@ func init() { func init() { proto.RegisterFile("sentinel/node/v2/events.proto", fileDescriptor_d02d789f2b133ff1) } var fileDescriptor_d02d789f2b133ff1 = []byte{ - // 375 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x31, 0x8e, 0xda, 0x40, - 0x18, 0x85, 0x6d, 0x2b, 0x22, 0x62, 0x12, 0x50, 0x30, 0x91, 0x20, 0x48, 0x19, 0xa3, 0x49, 0x43, - 0x11, 0x3c, 0x82, 0x74, 0x48, 0x29, 0xe2, 0x90, 0x22, 0x55, 0x24, 0x47, 0x69, 0xd2, 0xac, 0x6c, - 0x3c, 0x98, 0x91, 0x8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, 0x9e, 0xbc, 0xe8, 0x0e, 0x0c, - 0x64, 0x90, 0x9f, 0x29, 0xa9, 0x83, 0x64, 0x3e, 0x5f, 0xa5, 0x34, 0x11, 0x94, 0xc5, 0xe6, 0x17, - 0x60, 0xd0, 0x40, 0x26, 0x79, 0xe3, 0xf4, 0xcb, 0xc2, 0x32, 0x7e, 0x2f, 0xab, 0xc2, 0x6a, 0x2b, - 0x0e, 0x0d, 0x90, 0x6b, 0xd0, 0xc0, 0x5c, 0x80, 0xf7, 0xf5, 0x35, 0x6e, 0x9a, 0xe0, 0x86, 0x0c, - 0x3e, 0xa8, 0x0a, 0xab, 0xaf, 0x16, 0x2f, 0x55, 0xe4, 0xbe, 0xab, 0xc7, 0x1f, 0x6a, 0x72, 0xfe, - 0xec, 0x5f, 0xa0, 0xf6, 0x58, 0x42, 0x6d, 0x5f, 0x42, 0xfd, 0x50, 0x42, 0xfd, 0xb9, 0x84, 0xfa, - 0xc3, 0x11, 0x6a, 0x87, 0x23, 0xd4, 0x9e, 0x8e, 0x50, 0xfb, 0x3f, 0x0d, 0xa9, 0xd8, 0x64, 0xbe, - 0xbd, 0x62, 0x5b, 0xdc, 0xb4, 0x9b, 0xb2, 0xf5, 0x9a, 0xae, 0xa8, 0x17, 0xe1, 0x4d, 0xe6, 0xe3, - 0x5b, 0xf5, 0x56, 0x64, 0x63, 0xbf, 0x25, 0x0f, 0xfc, 0xed, 0x35, 0x00, 0x00, 0xff, 0xff, 0xb9, - 0x61, 0xde, 0x7c, 0x49, 0x02, 0x00, 0x00, + // 379 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xb1, 0xae, 0xda, 0x30, + 0x14, 0x86, 0xe3, 0xb4, 0xa2, 0xc2, 0x2d, 0xa8, 0x84, 0x4a, 0x50, 0xa4, 0x3a, 0x28, 0x5d, 0x18, + 0x4a, 0x2c, 0xe8, 0x86, 0xd4, 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ad, 0x4a, 0x9d, 0x5e, 0x55, + 0x98, 0x1d, 0x45, 0x57, 0x16, 0xcb, 0x6d, 0xbc, 0xd7, 0x49, 0xf4, 0xa7, 0x93, 0xec, 0x01, 0x1c, + 0xc8, 0x24, 0x5f, 0x52, 0x52, 0x27, 0xc9, 0x7c, 0xbe, 0x4a, 0x69, 0x22, 0x28, 0x8b, 0x6f, 0xeb, + 0xc9, 0x58, 0xc0, 0x57, 0xf5, 0xbf, 0xfc, 0x7e, 0xfc, 0xf8, 0xa0, 0x2a, 0xcc, 0xbe, 0xb2, 0x5c, + 0xab, 0x96, 0xfb, 0xb2, 0xbe, 0x7e, 0x6e, 0xbc, 0xef, 0xa1, 0x4e, 0x83, 0xe1, 0xb3, 0x31, 0x98, + 0x3c, 0x77, 0xfa, 0x65, 0x61, 0xea, 0xdf, 0x96, 0x55, 0x61, 0xb6, 0x95, 0x8f, 0x06, 0x96, 0xab, + 0xd3, 0xc0, 0xf9, 0x7e, 0xb8, 0x47, 0xda, 0xbe, 0x44, 0xda, 0xa1, 0x44, 0xe0, 0x58, 0x22, 0x70, + 0x57, 0x22, 0xf0, 0xef, 0x84, 0xb4, 0xe3, 0x09, 0x69, 0xff, 0x4f, 0x48, 0xfb, 0x35, 0x0d, 0xa9, + 0xd8, 0x64, 0xbe, 0xbd, 0x62, 0x5b, 0x7c, 0x1e, 0xdd, 0x94, 0xad, 0xd7, 0x74, 0x45, 0xbd, 0x08, + 0x6f, 0x32, 0x1f, 0xff, 0x51, 0xab, 0x25, 0xc7, 0xe9, 0xb7, 0xe4, 0x3e, 0x7c, 0x7c, 0x08, 0x00, + 0x00, 0xff, 0xff, 0x5c, 0x4a, 0x53, 0xbe, 0x78, 0x02, 0x00, 0x00, } func (m *EventRegister) Marshal() (dAtA []byte, err error) { @@ -291,17 +292,17 @@ func (m *EventUpdateStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Status != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x10 - } if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + if m.Status != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -326,6 +327,11 @@ func (m *EventCreateSubscription) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l + if m.ID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x18 + } if len(m.NodeAddress) > 0 { i -= len(m.NodeAddress) copy(dAtA[i:], m.NodeAddress) @@ -333,10 +339,12 @@ func (m *EventCreateSubscription) MarshalToSizedBuffer(dAtA []byte) (int, error) i-- dAtA[i] = 0x12 } - if m.ID != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.ID)) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -384,13 +392,13 @@ func (m *EventUpdateStatus) Size() (n int) { } var l int _ = l + if m.Status != 0 { + n += 1 + sovEvents(uint64(m.Status)) + } l = len(m.Address) if l > 0 { n += 1 + l + sovEvents(uint64(l)) } - if m.Status != 0 { - n += 1 + sovEvents(uint64(m.Status)) - } return n } @@ -400,13 +408,17 @@ func (m *EventCreateSubscription) Size() (n int) { } var l int _ = l - if m.ID != 0 { - n += 1 + sovEvents(uint64(m.ID)) + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) } l = len(m.NodeAddress) if l > 0 { n += 1 + l + sovEvents(uint64(l)) } + if m.ID != 0 { + n += 1 + sovEvents(uint64(m.ID)) + } return n } @@ -610,6 +622,25 @@ func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= types.Status(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } @@ -641,25 +672,6 @@ func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { } m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= types.Status(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) @@ -711,10 +723,10 @@ func (m *EventCreateSubscription) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - m.ID = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -724,11 +736,24 @@ func (m *EventCreateSubscription) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ID |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NodeAddress", wireType) @@ -761,6 +786,25 @@ func (m *EventCreateSubscription) Unmarshal(dAtA []byte) error { } m.NodeAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) diff --git a/x/plan/keeper/msg_server.go b/x/plan/keeper/msg_server.go index 43d5c579..53e6bb9e 100644 --- a/x/plan/keeper/msg_server.go +++ b/x/plan/keeper/msg_server.go @@ -60,7 +60,8 @@ func (k *msgServer) MsgCreate(c context.Context, msg *types.MsgCreateRequest) (* // Emit an event to notify that a new plan has been created. ctx.EventManager().EmitTypedEvent( &types.EventCreate{ - ID: plan.ID, + Address: plan.ProviderAddress, + ID: plan.ID, }, ) @@ -107,8 +108,9 @@ func (k *msgServer) MsgUpdateStatus(c context.Context, msg *types.MsgUpdateStatu // Emit an event to notify that the plan status has been updated. ctx.EventManager().EmitTypedEvent( &types.EventUpdateStatus{ - ID: plan.ID, - Status: plan.Status, + Status: plan.Status, + Address: plan.ProviderAddress, + ID: plan.ID, }, ) @@ -148,8 +150,9 @@ func (k *msgServer) MsgLinkNode(c context.Context, msg *types.MsgLinkNodeRequest // Emit an event to notify that a node has been linked to the plan. ctx.EventManager().EmitTypedEvent( &types.EventLinkNode{ - ID: plan.ID, - Address: nodeAddr.String(), + Address: plan.ProviderAddress, + NodeAddress: msg.NodeAddress, + ID: plan.ID, }, ) @@ -184,8 +187,9 @@ func (k *msgServer) MsgUnlinkNode(c context.Context, msg *types.MsgUnlinkNodeReq // Emit an event to notify that a node has been unlinked from the plan. ctx.EventManager().EmitTypedEvent( &types.EventUnlinkNode{ - ID: plan.ID, - Address: nodeAddr.String(), + Address: plan.ProviderAddress, + NodeAddress: msg.NodeAddress, + ID: plan.ID, }, ) @@ -212,8 +216,10 @@ 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, - PlanID: subscription.PlanID, + Address: subscription.Address, + ProviderAddress: "", + ID: subscription.ID, + PlanID: subscription.PlanID, }, ) diff --git a/x/plan/types/events.pb.go b/x/plan/types/events.pb.go index 6c9c0fd8..759d1357 100644 --- a/x/plan/types/events.pb.go +++ b/x/plan/types/events.pb.go @@ -25,7 +25,8 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type EventCreate struct { - ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + ID uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` } func (m *EventCreate) Reset() { *m = EventCreate{} } @@ -62,8 +63,9 @@ func (m *EventCreate) XXX_DiscardUnknown() { var xxx_messageInfo_EventCreate proto.InternalMessageInfo type EventUpdateStatus struct { - ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` - Status types.Status `protobuf:"varint,3,opt,name=status,proto3,enum=sentinel.types.v1.Status" json:"status,omitempty" yaml:"status"` + Status types.Status `protobuf:"varint,1,opt,name=status,proto3,enum=sentinel.types.v1.Status" json:"status,omitempty" yaml:"status"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + ID uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` } func (m *EventUpdateStatus) Reset() { *m = EventUpdateStatus{} } @@ -100,8 +102,9 @@ func (m *EventUpdateStatus) XXX_DiscardUnknown() { var xxx_messageInfo_EventUpdateStatus proto.InternalMessageInfo type EventLinkNode struct { - ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + NodeAddress string `protobuf:"bytes,2,opt,name=node_address,json=nodeAddress,proto3" json:"node_address,omitempty" yaml:"node_address"` + ID uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` } func (m *EventLinkNode) Reset() { *m = EventLinkNode{} } @@ -138,8 +141,9 @@ func (m *EventLinkNode) XXX_DiscardUnknown() { var xxx_messageInfo_EventLinkNode proto.InternalMessageInfo type EventUnlinkNode struct { - ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + NodeAddress string `protobuf:"bytes,2,opt,name=node_address,json=nodeAddress,proto3" json:"node_address,omitempty" yaml:"node_address"` + ID uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` } func (m *EventUnlinkNode) Reset() { *m = EventUnlinkNode{} } @@ -176,8 +180,10 @@ func (m *EventUnlinkNode) XXX_DiscardUnknown() { var xxx_messageInfo_EventUnlinkNode proto.InternalMessageInfo type EventCreateSubscription struct { - ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` - PlanID uint64 `protobuf:"varint,2,opt,name=plan_id,json=planId,proto3" json:"plan_id,omitempty" yaml:"plan_id"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + ProviderAddress string `protobuf:"bytes,2,opt,name=provider_address,json=providerAddress,proto3" json:"provider_address,omitempty" yaml:"provider_address"` + ID uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` + PlanID uint64 `protobuf:"varint,4,opt,name=plan_id,json=planId,proto3" json:"plan_id,omitempty" yaml:"plan_id"` } func (m *EventCreateSubscription) Reset() { *m = EventCreateSubscription{} } @@ -224,32 +230,36 @@ func init() { func init() { proto.RegisterFile("sentinel/plan/v2/events.proto", fileDescriptor_4222ab50472303c2) } var fileDescriptor_4222ab50472303c2 = []byte{ - // 388 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x52, 0xbf, 0x8e, 0xd3, 0x30, - 0x18, 0x4f, 0xc2, 0x29, 0xa7, 0x33, 0xba, 0x83, 0x0b, 0x48, 0x94, 0x0a, 0x9c, 0xca, 0x2c, 0x1d, - 0x68, 0xac, 0x06, 0xb1, 0x30, 0x86, 0x32, 0x54, 0x42, 0x80, 0x52, 0xb1, 0xb0, 0x20, 0xa7, 0x76, - 0x5b, 0x8b, 0xd4, 0x8e, 0x12, 0x27, 0xa2, 0x0b, 0xcf, 0xc0, 0x63, 0xf0, 0x28, 0x1d, 0x3b, 0x32, - 0x45, 0x90, 0xbe, 0x41, 0x9f, 0x00, 0xc5, 0x4e, 0x2b, 0xc6, 0x2e, 0xb7, 0x59, 0xfa, 0xfd, 0xfb, - 0x3e, 0xff, 0x3e, 0xf0, 0xbc, 0x60, 0x42, 0x71, 0xc1, 0x52, 0x9c, 0xa5, 0x44, 0xe0, 0x2a, 0xc4, - 0xac, 0x62, 0x42, 0x15, 0x41, 0x96, 0x4b, 0x25, 0xbd, 0x87, 0x47, 0x38, 0x68, 0xe1, 0xa0, 0x0a, - 0xfb, 0x8f, 0x97, 0x72, 0x29, 0x35, 0x88, 0xdb, 0x97, 0xe1, 0xf5, 0xe1, 0xc9, 0x46, 0x6d, 0x32, - 0x56, 0xe0, 0x6a, 0x8c,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 0x8d, 0x3e, 0x6e, 0xff, 0x42, 0xeb, 0x57, - 0x03, 0xad, 0x6d, 0x03, 0xed, 0x5d, 0x03, 0xed, 0x3f, 0x0d, 0xb4, 0x7f, 0xee, 0xa1, 0xb5, 0xdb, - 0x43, 0xeb, 0xf7, 0x1e, 0x5a, 0x5f, 0x46, 0x4b, 0xae, 0x56, 0x65, 0x12, 0xcc, 0xe5, 0x1a, 0x1f, - 0x2b, 0x1a, 0xc9, 0xc5, 0x82, 0xcf, 0x39, 0x49, 0xf1, 0xaa, 0x4c, 0xf0, 0x77, 0x73, 0x97, 0xba, - 0xb6, 0xc4, 0xd5, 0xc7, 0xf4, 0xea, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x57, 0x13, 0x29, - 0xb5, 0x02, 0x00, 0x00, + // 455 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x93, 0x3f, 0x6f, 0xd4, 0x30, + 0x18, 0xc6, 0xe3, 0x50, 0x5d, 0x55, 0x97, 0xfe, 0x4b, 0x91, 0xee, 0x28, 0xe0, 0x54, 0x66, 0xe9, + 0x40, 0x63, 0xf5, 0x10, 0x4b, 0x37, 0x8e, 0x82, 0x54, 0x09, 0x01, 0x4a, 0xc5, 0xc2, 0x52, 0x7c, + 0x67, 0xf7, 0x6a, 0x91, 0xda, 0x51, 0xe2, 0x44, 0xf4, 0x5b, 0xf0, 0x09, 0x10, 0x23, 0x03, 0x1f, + 0xa4, 0x63, 0x47, 0xa6, 0x08, 0x72, 0x23, 0x5b, 0x3e, 0x01, 0x8a, 0x9d, 0x54, 0xc7, 0x0d, 0x88, + 0x6c, 0x6c, 0x4e, 0x9e, 0xe7, 0x7d, 0xde, 0x9f, 0xad, 0xf7, 0x85, 0x0f, 0x52, 0x2e, 0xb5, 0x90, + 0x3c, 0x22, 0x71, 0x44, 0x25, 0xc9, 0x87, 0x84, 0xe7,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xf0, 0xb7, + 0x6d, 0xc9, 0xbc, 0x8a, 0xc3, 0xd5, 0xfa, 0xf3, 0x69, 0x17, 0xc0, 0x2f, 0x00, 0x6e, 0xd8, 0xf7, + 0x94, 0xd1, 0x7f, 0x8a, 0xf8, 0x0b, 0xc0, 0xfe, 0xdc, 0x54, 0x9d, 0x64, 0xe3, 0x74, 0x92, 0x88, + 0x58, 0x0b, 0x25, 0x3b, 0xa2, 0xbe, 0x80, 0x9b, 0x71, 0xa2, 0x72, 0xc1, 0x78, 0xb2, 0x80, 0x7b, + 0xaf, 0x2a, 0xfc, 0xbe, 0x2d, 0x5b, 0x74, 0xe0, 0x70, 0xa3, 0xfd, 0xd5, 0x05, 0xdb, 0x7b, 0x02, + 0x97, 0xeb, 0x65, 0x3a, 0x15, 0x6c, 0xb0, 0x64, 0x9c, 0xf7, 0xcb, 0xc2, 0xef, 0xbd, 0x89, 0xa8, + 0x34, 0xee, 0x06, 0xb2, 0xb1, 0xe0, 0xb0, 0x57, 0x9f, 0x8e, 0xd9, 0xe8, 0xf5, 0xd5, 0x4f, 0xe4, + 0x7c, 0x2d, 0x91, 0x73, 0x55, 0x22, 0x70, 0x5d, 0x22, 0xf0, 0xa3, 0x44, 0xe0, 0xd3, 0x0c, 0x39, + 0xd7, 0x33, 0xe4, 0x7c, 0x9f, 0x21, 0xe7, 0xdd, 0xfe, 0x54, 0xe8, 0xf3, 0x6c, 0x1c, 0x4c, 0xd4, + 0x05, 0x69, 0xc7, 0x7c, 0x5f, 0x9d, 0x9d, 0x89, 0x89, 0xa0, 0x11, 0x39, 0xcf, 0xc6, 0xe4, 0xa3, + 0xdd, 0x72, 0x33, 0xfa, 0xe3, 0x9e, 0x59, 0xcd, 0xc7, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x8c, + 0x33, 0x2b, 0xfd, 0x03, 0x04, 0x00, 0x00, } func (m *EventCreate) Marshal() (dAtA []byte, err error) { @@ -275,7 +285,14 @@ func (m *EventCreate) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.ID != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.ID)) i-- - dAtA[i] = 0x8 + dAtA[i] = 0x10 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -300,13 +317,20 @@ func (m *EventUpdateStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Status != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.Status)) + if m.ID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ID)) i-- dAtA[i] = 0x18 } - if m.ID != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.ID)) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if m.Status != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Status)) i-- dAtA[i] = 0x8 } @@ -333,17 +357,24 @@ func (m *EventLinkNode) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x18 + } + if len(m.NodeAddress) > 0 { + i -= len(m.NodeAddress) + copy(dAtA[i:], m.NodeAddress) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NodeAddress))) + i-- + dAtA[i] = 0x12 + } if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) i-- - dAtA[i] = 0x12 - } - if m.ID != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.ID)) - i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -368,17 +399,24 @@ func (m *EventUnlinkNode) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x18 + } + if len(m.NodeAddress) > 0 { + i -= len(m.NodeAddress) + copy(dAtA[i:], m.NodeAddress) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NodeAddress))) + i-- + dAtA[i] = 0x12 + } if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) i-- - dAtA[i] = 0x12 - } - if m.ID != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.ID)) - i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -406,12 +444,26 @@ func (m *EventCreateSubscription) MarshalToSizedBuffer(dAtA []byte) (int, error) if m.PlanID != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.PlanID)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x20 } if m.ID != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.ID)) i-- - dAtA[i] = 0x8 + dAtA[i] = 0x18 + } + if len(m.ProviderAddress) > 0 { + i -= len(m.ProviderAddress) + copy(dAtA[i:], m.ProviderAddress) + i = encodeVarintEvents(dAtA, i, uint64(len(m.ProviderAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -433,6 +485,10 @@ func (m *EventCreate) Size() (n int) { } var l int _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } if m.ID != 0 { n += 1 + sovEvents(uint64(m.ID)) } @@ -445,12 +501,16 @@ func (m *EventUpdateStatus) Size() (n int) { } var l int _ = l - if m.ID != 0 { - n += 1 + sovEvents(uint64(m.ID)) - } if m.Status != 0 { n += 1 + sovEvents(uint64(m.Status)) } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.ID != 0 { + n += 1 + sovEvents(uint64(m.ID)) + } return n } @@ -460,13 +520,17 @@ func (m *EventLinkNode) Size() (n int) { } var l int _ = l - if m.ID != 0 { - n += 1 + sovEvents(uint64(m.ID)) - } l = len(m.Address) if l > 0 { n += 1 + l + sovEvents(uint64(l)) } + l = len(m.NodeAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.ID != 0 { + n += 1 + sovEvents(uint64(m.ID)) + } return n } @@ -476,13 +540,17 @@ func (m *EventUnlinkNode) Size() (n int) { } var l int _ = l - if m.ID != 0 { - n += 1 + sovEvents(uint64(m.ID)) - } l = len(m.Address) if l > 0 { n += 1 + l + sovEvents(uint64(l)) } + l = len(m.NodeAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.ID != 0 { + n += 1 + sovEvents(uint64(m.ID)) + } return n } @@ -492,6 +560,14 @@ func (m *EventCreateSubscription) Size() (n int) { } var l int _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.ProviderAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } if m.ID != 0 { n += 1 + sovEvents(uint64(m.ID)) } @@ -537,6 +613,38 @@ func (m *EventCreate) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) } @@ -607,9 +715,9 @@ func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } - m.ID = 0 + m.Status = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -619,16 +727,48 @@ func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ID |= uint64(b&0x7F) << shift + m.Status |= types.Status(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) } - m.Status = 0 + m.ID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -638,7 +778,7 @@ func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Status |= types.Status(b&0x7F) << shift + m.ID |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -694,10 +834,10 @@ func (m *EventLinkNode) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - m.ID = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -707,14 +847,27 @@ func (m *EventLinkNode) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ID |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NodeAddress", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -742,8 +895,27 @@ func (m *EventLinkNode) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.NodeAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) @@ -795,10 +967,10 @@ func (m *EventUnlinkNode) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - m.ID = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -808,14 +980,27 @@ func (m *EventUnlinkNode) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ID |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NodeAddress", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -843,8 +1028,27 @@ func (m *EventUnlinkNode) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.NodeAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) @@ -896,6 +1100,70 @@ func (m *EventCreateSubscription) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProviderAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) } @@ -914,7 +1182,7 @@ func (m *EventCreateSubscription) Unmarshal(dAtA []byte) error { break } } - case 2: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field PlanID", wireType) } diff --git a/x/session/keeper/abci.go b/x/session/keeper/abci.go index 57906290..171681d9 100644 --- a/x/session/keeper/abci.go +++ b/x/session/keeper/abci.go @@ -34,10 +34,12 @@ func (k *Keeper) EndBlock(ctx sdk.Context) []abcitypes.ValidatorUpdate { // Emit an event to notify that the session status has been updated. ctx.EventManager().EmitTypedEvent( &types.EventUpdateStatus{ + Status: hubtypes.StatusInactivePending, + Address: item.Address, + NodeAddress: item.NodeAddress, ID: item.ID, + PlanID: 0, SubscriptionID: item.SubscriptionID, - NodeAddress: item.NodeAddress, - Status: hubtypes.StatusInactivePending, }, ) @@ -54,9 +56,9 @@ func (k *Keeper) EndBlock(ctx sdk.Context) []abcitypes.ValidatorUpdate { ) // Call the SessionInactiveHook method of the subscription handler to notify the subscription - // module that the session has ended. The method handles the necessary logic for refunds + // module that the session has ended. The method handles the necessary logic for payments // or other actions related to the session's termination. - if err := k.subscription.SessionInactiveHook(ctx, item.SubscriptionID, accAddr, nodeAddr, item.Bandwidth.Sum()); err != nil { + if err := k.subscription.SessionInactiveHook(ctx, item.ID, accAddr, nodeAddr, item.Bandwidth.Sum()); err != nil { // If an error occurs during the hook execution, panic to halt the chain. // This is done to prevent any inconsistencies or unexpected behavior. panic(err) @@ -72,10 +74,12 @@ func (k *Keeper) EndBlock(ctx sdk.Context) []abcitypes.ValidatorUpdate { // Emit an event to notify that the session has been terminated. ctx.EventManager().EmitTypedEvent( &types.EventUpdateStatus{ + Status: hubtypes.StatusInactive, + Address: item.Address, + NodeAddress: item.NodeAddress, ID: item.ID, + PlanID: 0, SubscriptionID: item.SubscriptionID, - NodeAddress: item.NodeAddress, - Status: hubtypes.StatusInactive, }, ) diff --git a/x/session/keeper/hooks.go b/x/session/keeper/hooks.go index bf142d6c..e6e9c208 100644 --- a/x/session/keeper/hooks.go +++ b/x/session/keeper/hooks.go @@ -35,10 +35,12 @@ func (k *Keeper) SubscriptionInactivePendingHook(ctx sdk.Context, id uint64) err // Emit an event to notify that the session status has been updated. ctx.EventManager().EmitTypedEvent( &types.EventUpdateStatus{ + Status: hubtypes.StatusInactivePending, + Address: item.Address, + NodeAddress: item.NodeAddress, ID: item.ID, + PlanID: 0, SubscriptionID: item.SubscriptionID, - NodeAddress: item.NodeAddress, - Status: hubtypes.StatusInactivePending, }, ) diff --git a/x/session/keeper/msg_server.go b/x/session/keeper/msg_server.go index 5255c9a3..7b0eff4d 100644 --- a/x/session/keeper/msg_server.go +++ b/x/session/keeper/msg_server.go @@ -134,6 +134,10 @@ func (k *msgServer) MsgStart(c context.Context, msg *types.MsgStartRequest) (*ty return nil, types.NewErrorDuplicateActiveSession(session.ID) } + // + // Get the status change delay from the Store. + statusChangeDelay := k.StatusChangeDelay(ctx) + // Increment the session count to assign a new session ID. count := k.GetCount(ctx) session = types.Session{ @@ -143,11 +147,9 @@ func (k *msgServer) MsgStart(c context.Context, msg *types.MsgStartRequest) (*ty Address: accAddr.String(), Bandwidth: hubtypes.NewBandwidthFromInt64(0, 0), Duration: 0, - InactiveAt: ctx.BlockTime().Add( - k.StatusChangeDelay(ctx), - ), - Status: hubtypes.StatusActive, - StatusAt: ctx.BlockTime(), + InactiveAt: ctx.BlockTime().Add(statusChangeDelay), + Status: hubtypes.StatusActive, + StatusAt: ctx.BlockTime(), } // Save the new session to the store. @@ -162,9 +164,11 @@ func (k *msgServer) MsgStart(c context.Context, msg *types.MsgStartRequest) (*ty // Emit an event to notify that a new session has started. ctx.EventManager().EmitTypedEvent( &types.EventStart{ + Address: session.Address, + NodeAddress: session.NodeAddress, ID: session.ID, + PlanID: 0, SubscriptionID: session.SubscriptionID, - NodeAddress: session.NodeAddress, }, ) @@ -208,13 +212,14 @@ func (k *msgServer) MsgUpdateDetails(c context.Context, msg *types.MsgUpdateDeta // If the session status is 'Active', update the session's InactiveAt value based on the status change delay. if session.Status.Equal(hubtypes.StatusActive) { + // Get the status change delay from the Store. + statusChangeDelay := k.StatusChangeDelay(ctx) + // Delete the session's entry from the InactiveAt index before updating the InactiveAt value. k.DeleteSessionForInactiveAt(ctx, session.InactiveAt, session.ID) // Calculate the new InactiveAt value by adding the status change delay to the current block time. - session.InactiveAt = ctx.BlockTime().Add( - k.StatusChangeDelay(ctx), - ) + session.InactiveAt = ctx.BlockTime().Add(statusChangeDelay) // Update the session entry in the InactiveAt index with the new InactiveAt value. k.SetSessionForInactiveAt(ctx, session.InactiveAt, session.ID) @@ -230,9 +235,11 @@ func (k *msgServer) MsgUpdateDetails(c context.Context, msg *types.MsgUpdateDeta // Emit an event to notify that the session details have been updated. ctx.EventManager().EmitTypedEvent( &types.EventUpdateDetails{ + Address: session.Address, + NodeAddress: session.NodeAddress, ID: session.ID, + PlanID: 0, SubscriptionID: session.SubscriptionID, - NodeAddress: session.NodeAddress, }, ) @@ -265,13 +272,14 @@ func (k *msgServer) MsgEnd(c context.Context, msg *types.MsgEndRequest) (*types. return nil, types.NewErrorUnauthorized(msg.From) } + // Get the status change delay from the Store. + statusChangeDelay := k.StatusChangeDelay(ctx) + // Delete the session's entry from the InactiveAt index before updating the InactiveAt value. k.DeleteSessionForInactiveAt(ctx, session.InactiveAt, session.ID) // Calculate the new InactiveAt value by adding the status change delay to the current block time. - session.InactiveAt = ctx.BlockTime().Add( - k.StatusChangeDelay(ctx), - ) + session.InactiveAt = ctx.BlockTime().Add(statusChangeDelay) // Set the session status to 'InactivePending' to mark it for an upcoming status update. session.Status = hubtypes.StatusInactivePending @@ -288,10 +296,12 @@ func (k *msgServer) MsgEnd(c context.Context, msg *types.MsgEndRequest) (*types. // Emit an event to notify that the session status has been updated. ctx.EventManager().EmitTypedEvent( &types.EventUpdateStatus{ + Status: hubtypes.StatusInactivePending, + Address: session.Address, + NodeAddress: session.NodeAddress, ID: session.ID, + PlanID: 0, SubscriptionID: session.SubscriptionID, - NodeAddress: session.NodeAddress, - Status: hubtypes.StatusInactivePending, }, ) diff --git a/x/session/types/events.pb.go b/x/session/types/events.pb.go index c3d19896..e010f60a 100644 --- a/x/session/types/events.pb.go +++ b/x/session/types/events.pb.go @@ -25,9 +25,11 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type EventStart struct { - ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` - SubscriptionID uint64 `protobuf:"varint,2,opt,name=subscription_id,json=subscriptionId,proto3" json:"subscription_id,omitempty" yaml:"subscription_id"` - NodeAddress string `protobuf:"bytes,3,opt,name=node_address,json=nodeAddress,proto3" json:"node_address,omitempty" yaml:"node_address"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + NodeAddress string `protobuf:"bytes,2,opt,name=node_address,json=nodeAddress,proto3" json:"node_address,omitempty" yaml:"node_address"` + ID uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` + PlanID uint64 `protobuf:"varint,4,opt,name=plan_id,json=planId,proto3" json:"plan_id,omitempty" yaml:"plan_id"` + SubscriptionID uint64 `protobuf:"varint,5,opt,name=subscription_id,json=subscriptionId,proto3" json:"subscription_id,omitempty" yaml:"subscription_id"` } func (m *EventStart) Reset() { *m = EventStart{} } @@ -64,9 +66,11 @@ func (m *EventStart) XXX_DiscardUnknown() { var xxx_messageInfo_EventStart proto.InternalMessageInfo type EventUpdateDetails struct { - ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` - SubscriptionID uint64 `protobuf:"varint,2,opt,name=subscription_id,json=subscriptionId,proto3" json:"subscription_id,omitempty" yaml:"subscription_id"` - NodeAddress string `protobuf:"bytes,3,opt,name=node_address,json=nodeAddress,proto3" json:"node_address,omitempty" yaml:"node_address"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + NodeAddress string `protobuf:"bytes,2,opt,name=node_address,json=nodeAddress,proto3" json:"node_address,omitempty" yaml:"node_address"` + ID uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` + PlanID uint64 `protobuf:"varint,4,opt,name=plan_id,json=planId,proto3" json:"plan_id,omitempty" yaml:"plan_id"` + SubscriptionID uint64 `protobuf:"varint,5,opt,name=subscription_id,json=subscriptionId,proto3" json:"subscription_id,omitempty" yaml:"subscription_id"` } func (m *EventUpdateDetails) Reset() { *m = EventUpdateDetails{} } @@ -103,10 +107,12 @@ func (m *EventUpdateDetails) XXX_DiscardUnknown() { var xxx_messageInfo_EventUpdateDetails proto.InternalMessageInfo type EventUpdateStatus struct { - ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` - SubscriptionID uint64 `protobuf:"varint,2,opt,name=subscription_id,json=subscriptionId,proto3" json:"subscription_id,omitempty" yaml:"subscription_id"` + Status types.Status `protobuf:"varint,1,opt,name=status,proto3,enum=sentinel.types.v1.Status" json:"status,omitempty" yaml:"status"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` NodeAddress string `protobuf:"bytes,3,opt,name=node_address,json=nodeAddress,proto3" json:"node_address,omitempty" yaml:"node_address"` - Status types.Status `protobuf:"varint,4,opt,name=status,proto3,enum=sentinel.types.v1.Status" json:"status,omitempty" yaml:"status"` + ID uint64 `protobuf:"varint,4,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` + PlanID uint64 `protobuf:"varint,5,opt,name=plan_id,json=planId,proto3" json:"plan_id,omitempty" yaml:"plan_id"` + SubscriptionID uint64 `protobuf:"varint,6,opt,name=subscription_id,json=subscriptionId,proto3" json:"subscription_id,omitempty" yaml:"subscription_id"` } func (m *EventUpdateStatus) Reset() { *m = EventUpdateStatus{} } @@ -151,31 +157,36 @@ func init() { func init() { proto.RegisterFile("sentinel/session/v2/events.proto", fileDescriptor_b22d66b3bd957014) } var fileDescriptor_b22d66b3bd957014 = []byte{ - // 382 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x53, 0xb1, 0xae, 0xda, 0x30, - 0x14, 0x8d, 0x53, 0x84, 0x84, 0xdb, 0x52, 0x11, 0xaa, 0x36, 0x65, 0x70, 0xa2, 0x74, 0x61, 0x68, - 0xe3, 0x42, 0x37, 0xb6, 0x46, 0x74, 0x60, 0x0d, 0x62, 0xe9, 0x82, 0x12, 0x6c, 0xc0, 0x52, 0x88, - 0xa3, 0xd8, 0x89, 0xca, 0x5f, 0xb4, 0x7f, 0xd1, 0x0f, 0xe9, 0xc0, 0xd0, 0x81, 0xb1, 0x53, 0xf4, - 0x5e, 0xf8, 0x03, 0xbe, 0xe0, 0x09, 0x27, 0xa0, 0xe8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- 0x52, 0x19, 0xb0, 0x48, 0xdc, 0xad, 0x9d, 0xdf, 0x3a, 0xec, 0x35, 0xec, 0xcc, 0xd5, 0x8b, 0xdd, - 0xab, 0x1b, 0x63, 0x0a, 0xdb, 0x55, 0xe6, 0xcc, 0x96, 0x0d, 0x86, 0xdd, 0xf1, 0x07, 0xf7, 0x96, - 0x5f, 0x15, 0x4a, 0x37, 0x1f, 0xb9, 0x95, 0x45, 0xaf, 0x77, 0x2e, 0xac, 0xd7, 0xf5, 0x2f, 0xa9, - 0x8e, 0xe3, 0xd7, 0x5c, 0xcf, 0x3f, 0x3c, 0x22, 0xed, 0x4f, 0x89, 0xb4, 0x43, 0x89, 0xc0, 0xb1, - 0x44, 0xe0, 0xa1, 0x44, 0xe0, 0xd7, 0x09, 0x69, 0xc7, 0x13, 0xd2, 0xfe, 0x9f, 0x90, 0xf6, 0xe3, - 0xcb, 0x86, 0xc9, 0x6d, 0x16, 0xba, 0x2b, 0xbe, 0xc3, 0xd7, 0x0d, 0x9f, 0xf9, 0x7a, 0xcd, 0x56, - 0x2c, 0x88, 0xf0, 0x36, 0x0b, 0xf1, 0xcf, 0xdb, 0x49, 0xa9, 0xc5, 0x61, 0x5b, 0x1d, 0xc1, 0xd7, - 0xa7, 0x00, 0x00, 0x00, 0xff, 0xff, 0x40, 0xe8, 0x89, 0xbc, 0x73, 0x03, 0x00, 0x00, + // 452 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x94, 0xb1, 0x6e, 0xd3, 0x40, + 0x18, 0xc7, 0xed, 0x6b, 0xea, 0xaa, 0x07, 0x04, 0xf5, 0x82, 0x20, 0x54, 0xe8, 0x1c, 0x1d, 0x4b, + 0x87, 0xe2, 0xa3, 0x41, 0x2c, 0xdd, 0x88, 0xc2, 0x90, 0x0d, 0x39, 0xea, 0xc2, 0x52, 0x5d, 0x72, + 0xd7, 0xf4, 0x24, 0xd7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0xfe, + 0x57, 0xea, 0xe2, 0x42, 0xce, 0x25, 0x4b, 0xe8, 0xe5, 0x6a, 0x46, 0x3f, 0x6d, 0x37, 0x90, 0xfd, + 0x2b, 0xb3, 0xc0, 0xee, 0x8c, 0x37, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xe4, 0x71, 0x03, 0x06, + 0xa2, 0x04, 0x00, 0x00, } func (m *EventStart) Marshal() (dAtA []byte, err error) { @@ -198,22 +209,34 @@ func (m *EventStart) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.NodeAddress) > 0 { - i -= len(m.NodeAddress) - copy(dAtA[i:], m.NodeAddress) - i = encodeVarintEvents(dAtA, i, uint64(len(m.NodeAddress))) - i-- - dAtA[i] = 0x1a - } if m.SubscriptionID != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.SubscriptionID)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x28 + } + if m.PlanID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.PlanID)) + i-- + dAtA[i] = 0x20 } if m.ID != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.ID)) i-- - dAtA[i] = 0x8 + dAtA[i] = 0x18 + } + if len(m.NodeAddress) > 0 { + i -= len(m.NodeAddress) + copy(dAtA[i:], m.NodeAddress) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NodeAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -238,22 +261,34 @@ func (m *EventUpdateDetails) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.NodeAddress) > 0 { - i -= len(m.NodeAddress) - copy(dAtA[i:], m.NodeAddress) - i = encodeVarintEvents(dAtA, i, uint64(len(m.NodeAddress))) - i-- - dAtA[i] = 0x1a - } if m.SubscriptionID != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.SubscriptionID)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x28 + } + if m.PlanID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.PlanID)) + i-- + dAtA[i] = 0x20 } if m.ID != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.ID)) i-- - dAtA[i] = 0x8 + dAtA[i] = 0x18 + } + if len(m.NodeAddress) > 0 { + i -= len(m.NodeAddress) + copy(dAtA[i:], m.NodeAddress) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NodeAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -278,8 +313,18 @@ func (m *EventUpdateStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Status != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.Status)) + if m.SubscriptionID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.SubscriptionID)) + i-- + dAtA[i] = 0x30 + } + if m.PlanID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.PlanID)) + i-- + dAtA[i] = 0x28 + } + if m.ID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ID)) i-- dAtA[i] = 0x20 } @@ -290,13 +335,15 @@ func (m *EventUpdateStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if m.SubscriptionID != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.SubscriptionID)) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x12 } - if m.ID != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.ID)) + if m.Status != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Status)) i-- dAtA[i] = 0x8 } @@ -320,16 +367,23 @@ func (m *EventStart) Size() (n int) { } var l int _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NodeAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } if m.ID != 0 { n += 1 + sovEvents(uint64(m.ID)) } + if m.PlanID != 0 { + n += 1 + sovEvents(uint64(m.PlanID)) + } if m.SubscriptionID != 0 { n += 1 + sovEvents(uint64(m.SubscriptionID)) } - l = len(m.NodeAddress) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } return n } @@ -339,16 +393,23 @@ func (m *EventUpdateDetails) Size() (n int) { } var l int _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NodeAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } if m.ID != 0 { n += 1 + sovEvents(uint64(m.ID)) } + if m.PlanID != 0 { + n += 1 + sovEvents(uint64(m.PlanID)) + } if m.SubscriptionID != 0 { n += 1 + sovEvents(uint64(m.SubscriptionID)) } - l = len(m.NodeAddress) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } return n } @@ -358,18 +419,25 @@ func (m *EventUpdateStatus) Size() (n int) { } var l int _ = l - if m.ID != 0 { - n += 1 + sovEvents(uint64(m.ID)) + if m.Status != 0 { + n += 1 + sovEvents(uint64(m.Status)) } - if m.SubscriptionID != 0 { - n += 1 + sovEvents(uint64(m.SubscriptionID)) + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) } l = len(m.NodeAddress) if l > 0 { n += 1 + l + sovEvents(uint64(l)) } - if m.Status != 0 { - n += 1 + sovEvents(uint64(m.Status)) + if m.ID != 0 { + n += 1 + sovEvents(uint64(m.ID)) + } + if m.PlanID != 0 { + n += 1 + sovEvents(uint64(m.PlanID)) + } + if m.SubscriptionID != 0 { + n += 1 + sovEvents(uint64(m.SubscriptionID)) } return n } @@ -410,10 +478,10 @@ func (m *EventStart) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - m.ID = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -423,31 +491,25 @@ func (m *EventStart) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ID |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SubscriptionID", wireType) + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents } - m.SubscriptionID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SubscriptionID |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents } - case 3: + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NodeAddress", wireType) } @@ -479,6 +541,63 @@ func (m *EventStart) Unmarshal(dAtA []byte) error { } m.NodeAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PlanID", wireType) + } + m.PlanID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PlanID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubscriptionID", wireType) + } + m.SubscriptionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubscriptionID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) @@ -530,10 +649,10 @@ func (m *EventUpdateDetails) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - m.ID = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -543,31 +662,25 @@ func (m *EventUpdateDetails) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ID |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SubscriptionID", wireType) + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents } - m.SubscriptionID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SubscriptionID |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents } - case 3: + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NodeAddress", wireType) } @@ -599,6 +712,63 @@ func (m *EventUpdateDetails) Unmarshal(dAtA []byte) error { } m.NodeAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PlanID", wireType) + } + m.PlanID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PlanID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubscriptionID", wireType) + } + m.SubscriptionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubscriptionID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) @@ -651,9 +821,9 @@ func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } - m.ID = 0 + m.Status = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -663,16 +833,16 @@ func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ID |= uint64(b&0x7F) << shift + m.Status |= types.Status(b&0x7F) << shift if b < 0x80 { break } } case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SubscriptionID", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - m.SubscriptionID = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -682,11 +852,24 @@ func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.SubscriptionID |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NodeAddress", wireType) @@ -721,9 +904,9 @@ func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) } - m.Status = 0 + m.ID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -733,7 +916,45 @@ func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Status |= types.Status(b&0x7F) << shift + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PlanID", wireType) + } + m.PlanID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PlanID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubscriptionID", wireType) + } + m.SubscriptionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubscriptionID |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/subscription/expected/keeper.go b/x/subscription/expected/keeper.go index ab9fd13e..17e2a9e7 100644 --- a/x/subscription/expected/keeper.go +++ b/x/subscription/expected/keeper.go @@ -9,6 +9,7 @@ import ( hubtypes "github.com/sentinel-official/hub/types" nodetypes "github.com/sentinel-official/hub/x/node/types" plantypes "github.com/sentinel-official/hub/x/plan/types" + sessiontypes "github.com/sentinel-official/hub/x/session/types" ) type AccountKeeper interface { @@ -42,5 +43,6 @@ type PlanKeeper interface { } type SessionKeeper interface { + GetSession(ctx sdk.Context, id uint64) (sessiontypes.Session, bool) SubscriptionInactivePendingHook(ctx sdk.Context, id uint64) error } diff --git a/x/subscription/keeper/abci.go b/x/subscription/keeper/abci.go index 1f639603..35795b35 100644 --- a/x/subscription/keeper/abci.go +++ b/x/subscription/keeper/abci.go @@ -41,6 +41,17 @@ func (k *Keeper) BeginBlock(ctx sdk.Context) { panic(err) } + // Emit an event for the payout payment. + ctx.EventManager().EmitTypedEvent( + &types.EventPayForPayout{ + Address: item.Address, + NodeAddress: item.NodeAddress, + Payment: payment.String(), + StakingReward: stakingReward.String(), + ID: item.ID, + }, + ) + // Decrement the remaining payout duration (in hours) by 1 and update the NextAt value. item.Hours = item.Hours - 1 item.NextAt = item.NextAt.Add(time.Hour) @@ -80,9 +91,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context) []abcitypes.ValidatorUpdate { panic(err) } - item.SetInactiveAt( - ctx.BlockTime().Add(statusChangeDelay), - ) + item.SetInactiveAt(ctx.BlockTime().Add(statusChangeDelay)) item.SetStatus(hubtypes.StatusInactivePending) item.SetStatusAt(ctx.BlockTime()) @@ -93,8 +102,10 @@ func (k *Keeper) EndBlock(ctx sdk.Context) []abcitypes.ValidatorUpdate { // Emit an event to notify that the subscription status has been updated. ctx.EventManager().EmitTypedEvent( &types.EventUpdateStatus{ - ID: item.GetID(), - Status: hubtypes.StatusInactivePending, + Status: hubtypes.StatusInactivePending, + Address: item.GetAddress().String(), + ID: item.GetID(), + PlanID: 0, }, ) @@ -154,6 +165,15 @@ func (k *Keeper) EndBlock(ctx sdk.Context) []abcitypes.ValidatorUpdate { if err := k.SubtractDeposit(ctx, accAddr, refund); err != nil { panic(err) } + + // Emit an event for the refund. + ctx.EventManager().EmitTypedEvent( + &types.EventRefund{ + Address: s.Address, + Amount: refund.String(), + ID: s.ID, + }, + ) } // Check if the number of hours for the subscription is not zero. @@ -177,6 +197,15 @@ func (k *Keeper) EndBlock(ctx sdk.Context) []abcitypes.ValidatorUpdate { if err := k.SubtractDeposit(ctx, accAddr, refund); err != nil { panic(err) } + + // Emit an event for the refund. + ctx.EventManager().EmitTypedEvent( + &types.EventRefund{ + Address: s.Address, + Amount: refund.String(), + ID: s.ID, + }, + ) } } @@ -206,8 +235,10 @@ func (k *Keeper) EndBlock(ctx sdk.Context) []abcitypes.ValidatorUpdate { k.DeleteSubscription(ctx, item.GetID()) ctx.EventManager().EmitTypedEvent( &types.EventUpdateStatus{ - ID: item.GetID(), - Status: hubtypes.StatusInactive, + Status: hubtypes.StatusInactive, + Address: item.GetAddress().String(), + ID: item.GetID(), + PlanID: 0, }, ) diff --git a/x/subscription/keeper/alias.go b/x/subscription/keeper/alias.go index 2222243c..a4cb2149 100644 --- a/x/subscription/keeper/alias.go +++ b/x/subscription/keeper/alias.go @@ -6,6 +6,7 @@ import ( hubtypes "github.com/sentinel-official/hub/types" nodetypes "github.com/sentinel-official/hub/x/node/types" plantypes "github.com/sentinel-official/hub/x/plan/types" + sessiontypes "github.com/sentinel-official/hub/x/session/types" ) func (k *Keeper) SendCoin(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, coin sdk.Coin) error { @@ -64,6 +65,10 @@ func (k *Keeper) GetPlan(ctx sdk.Context, id uint64) (plantypes.Plan, bool) { return k.plan.GetPlan(ctx, id) } +func (k *Keeper) GetSession(ctx sdk.Context, id uint64) (sessiontypes.Session, bool) { + return k.session.GetSession(ctx, id) +} + func (k *Keeper) SubscriptionInactivePendingHook(ctx sdk.Context, id uint64) error { return k.session.SubscriptionInactivePendingHook(ctx, id) } diff --git a/x/subscription/keeper/hooks.go b/x/subscription/keeper/hooks.go index 975fb881..69a3fe05 100644 --- a/x/subscription/keeper/hooks.go +++ b/x/subscription/keeper/hooks.go @@ -12,11 +12,22 @@ import ( // SessionInactiveHook is a function that handles the end of a session. // It updates the allocation's utilized bytes, calculates and sends payments, and staking rewards. -func (k *Keeper) SessionInactiveHook(ctx sdk.Context, id uint64, accAddr sdk.AccAddress, nodeAddr hubtypes.NodeAddress, bytes sdk.Int) error { - // Get the subscription associated with the provided subscription ID. - subscription, found := k.GetSubscription(ctx, id) +func (k *Keeper) SessionInactiveHook(ctx sdk.Context, id uint64, accAddr sdk.AccAddress, nodeAddr hubtypes.NodeAddress, utilisedBytes sdk.Int) error { + // Retrieve the session associated with the provided session ID. + session, found := k.GetSession(ctx, id) if !found { - return fmt.Errorf("subscription %d does not exist", id) + return fmt.Errorf("session %d does not exist", id) + } + + // Check if the session has the correct status for processing. + if !session.Status.Equal(hubtypes.StatusInactivePending) { + return fmt.Errorf("invalid status %s for session %d", session.Status, session.ID) + } + + // Retrieve the subscription associated with the session. + subscription, found := k.GetSubscription(ctx, session.SubscriptionID) + if !found { + return fmt.Errorf("subscription %d does not exist", session.SubscriptionID) } // If the subscription is a NodeSubscription with non-zero duration (hours), no further action is needed. @@ -24,7 +35,7 @@ func (k *Keeper) SessionInactiveHook(ctx sdk.Context, id uint64, accAddr sdk.Acc return nil } - // Get the allocation associated with the subscription and account address. + // Retrieve the allocation associated with the subscription and account address. alloc, found := k.GetAllocation(ctx, subscription.GetID(), accAddr) if !found { return fmt.Errorf("subscription allocation %d/%s does not exist", subscription.GetID(), accAddr) @@ -35,7 +46,7 @@ func (k *Keeper) SessionInactiveHook(ctx sdk.Context, id uint64, accAddr sdk.Acc previousAmount = sdk.ZeroInt() // Amount paid for previous utilization (for NodeSubscription). ) - // Based on the subscription type (NodeSubscription), calculate the payment amounts. + // Calculate payment amounts based on the subscription type (NodeSubscription). if s, ok := subscription.(*types.NodeSubscription); ok && s.Gigabytes != 0 { gigabytePrice = sdk.NewCoin( s.Deposit.Denom, @@ -45,7 +56,7 @@ func (k *Keeper) SessionInactiveHook(ctx sdk.Context, id uint64, accAddr sdk.Acc } // Update the allocation's utilized bytes by adding the provided bytes. - alloc.UtilisedBytes = alloc.UtilisedBytes.Add(bytes) + alloc.UtilisedBytes = alloc.UtilisedBytes.Add(utilisedBytes) // Ensure that the utilized bytes don't exceed the granted bytes. if alloc.UtilisedBytes.GT(alloc.GrantedBytes) { alloc.UtilisedBytes = alloc.GrantedBytes @@ -53,8 +64,16 @@ func (k *Keeper) SessionInactiveHook(ctx sdk.Context, id uint64, accAddr sdk.Acc // Save the updated allocation to the store. k.SetAllocation(ctx, alloc) + ctx.EventManager().EmitTypedEvent( + &types.EventAllocate{ + Address: alloc.Address, + GrantedBytes: alloc.GrantedBytes, + UtilisedBytes: alloc.UtilisedBytes, + ID: alloc.ID, + }, + ) - // Based on the subscription type (NodeSubscription), calculate the current payment amount. + // Calculate the current payment amount based on the subscription type (NodeSubscription). if s, ok := subscription.(*types.NodeSubscription); ok && s.Gigabytes != 0 { // Calculate the payment to be made for the current utilization. var ( @@ -73,7 +92,21 @@ func (k *Keeper) SessionInactiveHook(ctx sdk.Context, id uint64, accAddr sdk.Acc payment = payment.Sub(stakingReward) // Send the payment amount from the deposit to the node address. - return k.SendCoinFromDepositToAccount(ctx, accAddr, nodeAddr.Bytes(), payment) + if err := k.SendCoinFromDepositToAccount(ctx, accAddr, nodeAddr.Bytes(), payment); err != nil { + return err + } + + // Emit an event for the session payment. + ctx.EventManager().EmitTypedEvent( + &types.EventPayForSession{ + Address: session.NodeAddress, + NodeAddress: session.NodeAddress, + Payment: payment.String(), + StakingReward: stakingReward.String(), + SessionID: session.ID, + SubscriptionID: session.SubscriptionID, + }, + ) } return nil diff --git a/x/subscription/keeper/migrator.go b/x/subscription/keeper/migrator.go index 08efd901..a0214337 100644 --- a/x/subscription/keeper/migrator.go +++ b/x/subscription/keeper/migrator.go @@ -113,9 +113,7 @@ func (k Migrator) migrateSubscriptions(ctx sdk.Context) error { } if value.Status.Equal(hubtypes.StatusInactivePending) { - subscription.SetInactiveAt( - value.StatusAt.Add(statusChangeDelay), - ) + subscription.SetInactiveAt(value.StatusAt.Add(statusChangeDelay)) } k.SetSubscription(ctx, subscription) diff --git a/x/subscription/keeper/msg_server.go b/x/subscription/keeper/msg_server.go index 77f98255..8f5aa3a0 100644 --- a/x/subscription/keeper/msg_server.go +++ b/x/subscription/keeper/msg_server.go @@ -52,6 +52,9 @@ func (k *msgServer) MsgCancel(c context.Context, msg *types.MsgCancelRequest) (* return nil, types.NewErrorUnauthorized(msg.From) } + // Get the status change delay from the store. + statusChangeDelay := k.StatusChangeDelay(ctx) + // Delete the subscription from the Store for the time it becomes inactive. k.DeleteSubscriptionForInactiveAt(ctx, subscription.GetInactiveAt(), subscription.GetID()) @@ -61,10 +64,7 @@ func (k *msgServer) MsgCancel(c context.Context, msg *types.MsgCancelRequest) (* } // Calculate the duration for which the subscription will be in the inactive state. - statusChangeDelay := k.StatusChangeDelay(ctx) - subscription.SetInactiveAt( - ctx.BlockTime().Add(statusChangeDelay), - ) + subscription.SetInactiveAt(ctx.BlockTime().Add(statusChangeDelay)) subscription.SetStatus(hubtypes.StatusInactivePending) subscription.SetStatusAt(ctx.BlockTime()) @@ -77,8 +77,10 @@ func (k *msgServer) MsgCancel(c context.Context, msg *types.MsgCancelRequest) (* // Emit an event to notify that the subscription status has been updated. ctx.EventManager().EmitTypedEvent( &types.EventUpdateStatus{ - ID: subscription.GetID(), - Status: hubtypes.StatusInactivePending, + Status: hubtypes.StatusInactivePending, + Address: subscription.GetAddress().String(), + ID: subscription.GetID(), + PlanID: 0, }, ) @@ -181,9 +183,10 @@ func (k *msgServer) MsgAllocate(c context.Context, msg *types.MsgAllocateRequest // Emit an event to notify that the sender's allocation has been updated. ctx.EventManager().EmitTypedEvent( &types.EventAllocate{ - ID: subscription.GetID(), - Address: fromAlloc.Address, - Bytes: fromAlloc.GrantedBytes, + Address: fromAlloc.Address, + GrantedBytes: fromAlloc.GrantedBytes, + UtilisedBytes: fromAlloc.UtilisedBytes, + ID: fromAlloc.ID, }, ) @@ -199,9 +202,10 @@ func (k *msgServer) MsgAllocate(c context.Context, msg *types.MsgAllocateRequest // Emit an event to notify that the receiver's allocation has been updated. ctx.EventManager().EmitTypedEvent( &types.EventAllocate{ - ID: subscription.GetID(), - Address: toAlloc.Address, - Bytes: toAlloc.GrantedBytes, + Address: toAlloc.Address, + GrantedBytes: toAlloc.GrantedBytes, + UtilisedBytes: toAlloc.UtilisedBytes, + ID: toAlloc.ID, }, ) diff --git a/x/subscription/keeper/subscription.go b/x/subscription/keeper/subscription.go index 3ce643de..9ee843c3 100644 --- a/x/subscription/keeper/subscription.go +++ b/x/subscription/keeper/subscription.go @@ -344,9 +344,10 @@ func (k *Keeper) CreateSubscriptionForNode(ctx sdk.Context, accAddr sdk.AccAddre k.SetAllocation(ctx, alloc) ctx.EventManager().EmitTypedEvent( &types.EventAllocate{ - ID: subscription.GetID(), - Address: alloc.Address, - Bytes: alloc.GrantedBytes, + Address: alloc.Address, + GrantedBytes: alloc.GrantedBytes, + UtilisedBytes: alloc.UtilisedBytes, + ID: alloc.ID, }, ) } @@ -371,10 +372,10 @@ func (k *Keeper) CreateSubscriptionForNode(ctx sdk.Context, accAddr sdk.AccAddre k.SetPayoutForAccountByNode(ctx, accAddr, nodeAddr, payout.ID) k.SetPayoutForNextAt(ctx, payout.NextAt, payout.ID) ctx.EventManager().EmitTypedEvent( - &types.EventPayout{ - ID: payout.ID, + &types.EventCreatePayout{ Address: payout.Address, NodeAddress: payout.NodeAddress, + ID: payout.ID, }, ) } @@ -421,6 +422,17 @@ func (k *Keeper) CreateSubscriptionForPlan(ctx sdk.Context, accAddr sdk.AccAddre return nil, err } + // Emit an event for the plan payment. + ctx.EventManager().EmitTypedEvent( + &types.EventPayForPlan{ + Address: accAddr.String(), + Payment: payment.String(), + ProviderAddress: plan.ProviderAddress, + StakingReward: stakingReward.String(), + ID: plan.ID, + }, + ) + // Retrieve the current count and create a new PlanSubscription. count := k.GetCount(ctx) subscription := &types.PlanSubscription{ @@ -453,9 +465,10 @@ func (k *Keeper) CreateSubscriptionForPlan(ctx sdk.Context, accAddr sdk.AccAddre k.SetAllocation(ctx, alloc) ctx.EventManager().EmitTypedEvent( &types.EventAllocate{ - ID: subscription.GetID(), - Address: alloc.Address, - Bytes: alloc.GrantedBytes, + Address: alloc.Address, + GrantedBytes: alloc.GrantedBytes, + UtilisedBytes: alloc.UtilisedBytes, + ID: alloc.ID, }, ) diff --git a/x/subscription/types/events.pb.go b/x/subscription/types/events.pb.go index a019b085..92456220 100644 --- a/x/subscription/types/events.pb.go +++ b/x/subscription/types/events.pb.go @@ -26,8 +26,10 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type EventUpdateStatus struct { - ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` - Status types.Status `protobuf:"varint,2,opt,name=status,proto3,enum=sentinel.types.v1.Status" json:"status,omitempty" yaml:"status"` + Status types.Status `protobuf:"varint,1,opt,name=status,proto3,enum=sentinel.types.v1.Status" json:"status,omitempty" yaml:"status"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + ID uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` + PlanID uint64 `protobuf:"varint,4,opt,name=plan_id,json=planId,proto3" json:"plan_id,omitempty" yaml:"plan_id"` } func (m *EventUpdateStatus) Reset() { *m = EventUpdateStatus{} } @@ -64,9 +66,10 @@ func (m *EventUpdateStatus) XXX_DiscardUnknown() { var xxx_messageInfo_EventUpdateStatus proto.InternalMessageInfo type EventAllocate struct { - ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` - Bytes github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=bytes,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"bytes"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + GrantedBytes github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=granted_bytes,json=grantedBytes,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"granted_bytes"` + UtilisedBytes github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=utilised_bytes,json=utilisedBytes,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"utilised_bytes"` + ID uint64 `protobuf:"varint,4,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` } func (m *EventAllocate) Reset() { *m = EventAllocate{} } @@ -102,24 +105,24 @@ func (m *EventAllocate) XXX_DiscardUnknown() { var xxx_messageInfo_EventAllocate proto.InternalMessageInfo -type EventPayout struct { - ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` - NodeAddress string `protobuf:"bytes,3,opt,name=node_address,json=nodeAddress,proto3" json:"node_address,omitempty" yaml:"node_address"` +type EventCreatePayout struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + NodeAddress string `protobuf:"bytes,2,opt,name=node_address,json=nodeAddress,proto3" json:"node_address,omitempty" yaml:"node_address"` + ID uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` } -func (m *EventPayout) Reset() { *m = EventPayout{} } -func (m *EventPayout) String() string { return proto.CompactTextString(m) } -func (*EventPayout) ProtoMessage() {} -func (*EventPayout) Descriptor() ([]byte, []int) { +func (m *EventCreatePayout) Reset() { *m = EventCreatePayout{} } +func (m *EventCreatePayout) String() string { return proto.CompactTextString(m) } +func (*EventCreatePayout) ProtoMessage() {} +func (*EventCreatePayout) Descriptor() ([]byte, []int) { return fileDescriptor_873efd8554329ba2, []int{2} } -func (m *EventPayout) XXX_Unmarshal(b []byte) error { +func (m *EventCreatePayout) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *EventPayout) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *EventCreatePayout) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_EventPayout.Marshal(b, m, deterministic) + return xxx_messageInfo_EventCreatePayout.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -129,22 +132,189 @@ func (m *EventPayout) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *EventPayout) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventPayout.Merge(m, src) +func (m *EventCreatePayout) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventCreatePayout.Merge(m, src) } -func (m *EventPayout) XXX_Size() int { +func (m *EventCreatePayout) XXX_Size() int { return m.Size() } -func (m *EventPayout) XXX_DiscardUnknown() { - xxx_messageInfo_EventPayout.DiscardUnknown(m) +func (m *EventCreatePayout) XXX_DiscardUnknown() { + xxx_messageInfo_EventCreatePayout.DiscardUnknown(m) } -var xxx_messageInfo_EventPayout proto.InternalMessageInfo +var xxx_messageInfo_EventCreatePayout proto.InternalMessageInfo + +type EventPayForPayout struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + NodeAddress string `protobuf:"bytes,2,opt,name=node_address,json=nodeAddress,proto3" json:"node_address,omitempty" yaml:"node_address"` + Payment string `protobuf:"bytes,3,opt,name=payment,proto3" json:"payment,omitempty" yaml:"payment"` + StakingReward string `protobuf:"bytes,4,opt,name=staking_reward,json=stakingReward,proto3" json:"staking_reward,omitempty" yaml:"staking_reward"` + ID uint64 `protobuf:"varint,5,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` +} + +func (m *EventPayForPayout) Reset() { *m = EventPayForPayout{} } +func (m *EventPayForPayout) String() string { return proto.CompactTextString(m) } +func (*EventPayForPayout) ProtoMessage() {} +func (*EventPayForPayout) Descriptor() ([]byte, []int) { + return fileDescriptor_873efd8554329ba2, []int{3} +} +func (m *EventPayForPayout) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventPayForPayout) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventPayForPayout.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventPayForPayout) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventPayForPayout.Merge(m, src) +} +func (m *EventPayForPayout) XXX_Size() int { + return m.Size() +} +func (m *EventPayForPayout) XXX_DiscardUnknown() { + xxx_messageInfo_EventPayForPayout.DiscardUnknown(m) +} + +var xxx_messageInfo_EventPayForPayout proto.InternalMessageInfo + +type EventPayForPlan struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + Payment string `protobuf:"bytes,2,opt,name=payment,proto3" json:"payment,omitempty" yaml:"payment"` + ProviderAddress string `protobuf:"bytes,3,opt,name=provider_address,json=providerAddress,proto3" json:"provider_address,omitempty" yaml:"provider_address"` + StakingReward string `protobuf:"bytes,4,opt,name=staking_reward,json=stakingReward,proto3" json:"staking_reward,omitempty" yaml:"staking_reward"` + ID uint64 `protobuf:"varint,5,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` +} + +func (m *EventPayForPlan) Reset() { *m = EventPayForPlan{} } +func (m *EventPayForPlan) String() string { return proto.CompactTextString(m) } +func (*EventPayForPlan) ProtoMessage() {} +func (*EventPayForPlan) Descriptor() ([]byte, []int) { + return fileDescriptor_873efd8554329ba2, []int{4} +} +func (m *EventPayForPlan) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventPayForPlan) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventPayForPlan.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventPayForPlan) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventPayForPlan.Merge(m, src) +} +func (m *EventPayForPlan) XXX_Size() int { + return m.Size() +} +func (m *EventPayForPlan) XXX_DiscardUnknown() { + xxx_messageInfo_EventPayForPlan.DiscardUnknown(m) +} + +var xxx_messageInfo_EventPayForPlan proto.InternalMessageInfo + +type EventPayForSession struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + NodeAddress string `protobuf:"bytes,2,opt,name=node_address,json=nodeAddress,proto3" json:"node_address,omitempty" yaml:"node_address"` + Payment string `protobuf:"bytes,3,opt,name=payment,proto3" json:"payment,omitempty" yaml:"payment"` + StakingReward string `protobuf:"bytes,4,opt,name=staking_reward,json=stakingReward,proto3" json:"staking_reward,omitempty" yaml:"staking_reward"` + SessionID uint64 `protobuf:"varint,5,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty" yaml:"session_id"` + SubscriptionID uint64 `protobuf:"varint,6,opt,name=subscription_id,json=subscriptionId,proto3" json:"subscription_id,omitempty" yaml:"subscription_id"` +} + +func (m *EventPayForSession) Reset() { *m = EventPayForSession{} } +func (m *EventPayForSession) String() string { return proto.CompactTextString(m) } +func (*EventPayForSession) ProtoMessage() {} +func (*EventPayForSession) Descriptor() ([]byte, []int) { + return fileDescriptor_873efd8554329ba2, []int{5} +} +func (m *EventPayForSession) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventPayForSession) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventPayForSession.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventPayForSession) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventPayForSession.Merge(m, src) +} +func (m *EventPayForSession) XXX_Size() int { + return m.Size() +} +func (m *EventPayForSession) XXX_DiscardUnknown() { + xxx_messageInfo_EventPayForSession.DiscardUnknown(m) +} + +var xxx_messageInfo_EventPayForSession proto.InternalMessageInfo + +type EventRefund struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty" yaml:"amount"` + ID uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` +} + +func (m *EventRefund) Reset() { *m = EventRefund{} } +func (m *EventRefund) String() string { return proto.CompactTextString(m) } +func (*EventRefund) ProtoMessage() {} +func (*EventRefund) Descriptor() ([]byte, []int) { + return fileDescriptor_873efd8554329ba2, []int{6} +} +func (m *EventRefund) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventRefund) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventRefund.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventRefund) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventRefund.Merge(m, src) +} +func (m *EventRefund) XXX_Size() int { + return m.Size() +} +func (m *EventRefund) XXX_DiscardUnknown() { + xxx_messageInfo_EventRefund.DiscardUnknown(m) +} + +var xxx_messageInfo_EventRefund proto.InternalMessageInfo func init() { proto.RegisterType((*EventUpdateStatus)(nil), "sentinel.subscription.v2.EventUpdateStatus") proto.RegisterType((*EventAllocate)(nil), "sentinel.subscription.v2.EventAllocate") - proto.RegisterType((*EventPayout)(nil), "sentinel.subscription.v2.EventPayout") + proto.RegisterType((*EventCreatePayout)(nil), "sentinel.subscription.v2.EventCreatePayout") + proto.RegisterType((*EventPayForPayout)(nil), "sentinel.subscription.v2.EventPayForPayout") + proto.RegisterType((*EventPayForPlan)(nil), "sentinel.subscription.v2.EventPayForPlan") + proto.RegisterType((*EventPayForSession)(nil), "sentinel.subscription.v2.EventPayForSession") + proto.RegisterType((*EventRefund)(nil), "sentinel.subscription.v2.EventRefund") } func init() { @@ -152,33 +322,51 @@ func init() { } var fileDescriptor_873efd8554329ba2 = []byte{ - // 407 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x92, 0x31, 0x6e, 0xd4, 0x40, - 0x14, 0x86, 0x3d, 0x06, 0x82, 0x32, 0x21, 0x91, 0xe2, 0x20, 0x61, 0x52, 0x8c, 0xa3, 0x41, 0xa0, - 0x14, 0x64, 0x46, 0x59, 0x44, 0x93, 0x2e, 0xd6, 0x52, 0xa4, 0x43, 0x46, 0x08, 0x89, 0x06, 0xd9, - 0x9e, 0xd9, 0xdd, 0x11, 0x5e, 0x8f, 0xb5, 0x33, 0xb6, 0x70, 0xc3, 0x19, 0x38, 0x00, 0x07, 0xd8, - 0xa3, 0x6c, 0xb9, 0x25, 0xa2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0f, 0x43, 0xaf, 0x6b, 0x82, 0x13, 0xcb, 0xf4, 0x0d, - 0x1c, 0x0d, 0x88, 0x37, 0x86, 0x0f, 0x92, 0x5a, 0x73, 0xe5, 0xdf, 0x33, 0x2c, 0x59, 0x35, 0x81, - 0xf3, 0xb3, 0x09, 0x5e, 0x4c, 0x85, 0x9e, 0x95, 0x09, 0x49, 0xe5, 0x9c, 0xa6, 0x52, 0xcd, 0xa5, - 0xea, 0x1f, 0x57, 0x8a, 0x7d, 0xb6, 0xfb, 0x22, 0x77, 0xb9, 0x8e, 0xac, 0x18, 0x7f, 0x07, 0xf0, - 0xc8, 0x44, 0x7d, 0x1b, 0xd7, 0xb2, 0xd4, 0xff, 0x23, 0xe8, 0x0d, 0x7c, 0x94, 0x4b, 0xc6, 0x3f, - 0x0d, 0x12, 0x9b, 0xf7, 0x49, 0xd7, 0x04, 0x67, 0x56, 0xb2, 0xdf, 0xc5, 0xd1, 0xd1, 0xb6, 0xbc, - 0xb5, 0x55, 0xf8, 0x61, 0xf5, 0x1b, 0x39, 0xcb, 0x16, 0x39, 0xab, 0x16, 0x81, 0x75, 0x8b, 0xc0, - 0xaf, 0x16, 0x81, 0x6f, 0x1b, 0xe4, 0xac, 0x37, 0xc8, 0xf9, 0xb1, 0x41, 0xce, 0xc7, 0xd7, 0x7b, - 0xdf, 0x3b, 0xfc, 0xab, 0x2b, 0x39, 0x99, 0x88, 0x54, 0xc4, 0x19, 0x9d, 0x95, 0x09, 0xfd, 0xf2, - 0xf7, 0xf1, 0x99, 0x15, 0x24, 0x07, 0xe6, 0x52, 0x5e, 0xfd, 0x09, 0x00, 0x00, 0xff, 0xff, 0x46, - 0x03, 0x2c, 0x70, 0xa2, 0x02, 0x00, 0x00, + // 702 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x55, 0xc1, 0x4e, 0xdb, 0x4c, + 0x10, 0x8e, 0x0d, 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c, 0x24, 0x48, 0x92, 0x13, 0x34, 0xe2, 0x91, 0x9c, 0x51, 0x94, 0x03, 0xb0, 0xc4, 0x38, 0x26, + 0xed, 0xeb, 0x3d, 0x5e, 0x9b, 0xc4, 0xce, 0xaa, 0x0a, 0x29, 0x7a, 0xa1, 0xbf, 0x38, 0xdd, 0x1e, + 0xce, 0xd0, 0x6c, 0xf8, 0xd1, 0xd4, 0x49, 0x9e, 0xa0, 0xd1, 0x31, 0x0f, 0xef, 0x3c, 0xc9, 0x6d, + 0xb0, 0x30, 0x40, 0xa3, 0x3e, 0x61, 0x52, 0x77, 0xa6, 0x70, 0x92, 0x76, 0x40, 0x3f, 0x83, 0x58, + 0xcf, 0x40, 0x4d, 0x48, 0x74, 0x41, 0x59, 0xaf, 0x1d, 0x92, 0xd7, 0x28, 0x54, 0x3d, 0xa8, 0x34, + 0xd6, 0x27, 0xb1, 0xf3, 0x7f, 0xfe, 0x83, 0x14, 0xfc, 0xd0, 0xaf, 0x6a, 0x83, 0x9f, 0xee, 0xb5, + 0x28, 0xff, 0xdc, 0x2c, 0xca, 0x27, 0x13, 0x2c, 0x17, 0x45, 0x09, 0x10, 0x9b, 0x51, 0x92, 0x42, + 0x59, 0xe6, 0xed, 0x65, 0x1d, 0x83, 0x7f, 0x07, 0x21, 0x1f, 0x52, 0x4c, 0xc2, 0x5c, 0x44, 0xa5, + 0xc6, 0xfd, 0x49, 0xec, 0xac, 0xe9, 0xb0, 0x5f, 0x10, 0xd0, 0x5f, 0xce, 0x4c, 0x99, 0x98, 0x77, + 0x24, 0xcf, 0xdb, 0x39, 0x60, 0x15, 0xe4, 0x69, 0x11, 0x21, 0x28, 0x67, 0x7f, 0xf1, 0xa5, 0x39, + 0x04, 0x40, 0xa8, 0x22, 0xdb, 0xb9, 0x3a, 0x30, 0x89, 0x9d, 0x8a, 0x2e, 0x3d, 0x15, 0x69, 0x45, + 0x53, 0xe5, 0x40, 0xe8, 0x57, 0xf4, 0xa6, 0x89, 0xad, 0x53, 0xb0, 0x5c, 0x1c, 0x26, 0x53, 0x9e, + 0x72, 0xca, 0xb3, 0x9d, 0xc4, 0x4e, 0xad, 0x55, 0x70, 0xa5, 0x64, 0xf7, 0x34, 0xd9, 0xf5, 0x10, + 0xe8, 0xd7, 0x8a, 0x96, 0x26, 0x86, 0xef, 0x0c, 0xb0, 0x98, 0xb6, 0xc2, 0x27, 0x67, 0x11, 0xc3, + 0x33, 0xf6, 0xe0, 0x09, 0x28, 0xa3, 0x3e, 0x8f, 0xf2, 0x4b, 0x5a, 0x98, 0x33, 0xca, 0x0e, 0x7d, + 0x0d, 0xf8, 0xad, 0xc7, 0xa4, 0xf1, 0xf2, 0xf2, 0x87, 0x5d, 0xfa, 0x92, 0xd8, 0xa5, 0xcb, 0xc4, + 0x36, 0xae, 0x12, 0xdb, 0xf8, 0x9e, 0xd8, 0xc6, 0x87, 0xb1, 0x5d, 0xba, 0x1a, 0xdb, 0xa5, 0xaf, + 0x63, 0xbb, 0xf4, 0x6a, 0xbf, 0xf0, 0xde, 0x66, 0xe3, 0x6e, 0x87, 0x9f, 0x9d, 0xd1, 0x2e, 0x45, + 0x81, 0x77, 0x1e, 0x75, 0xbc, 0x37, 0xd7, 0x67, 0x73, 0xfa, 0x04, 0x77, 0xca, 0xe9, 0x20, 0x7d, + 0xfa, 0x33, 0x00, 0x00, 0xff, 0xff, 0xa8, 0xee, 0xb4, 0x14, 0xc1, 0x07, 0x00, 0x00, } func (m *EventUpdateStatus) Marshal() (dAtA []byte, err error) { @@ -201,14 +389,26 @@ func (m *EventUpdateStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Status != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.Status)) + if m.PlanID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.PlanID)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x20 } if m.ID != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.ID)) i-- + dAtA[i] = 0x18 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if m.Status != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Status)) + i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil @@ -234,32 +434,42 @@ func (m *EventAllocate) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x20 + } { - size := m.Bytes.Size() + size := m.UtilisedBytes.Size() i -= size - if _, err := m.Bytes.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.UtilisedBytes.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintEvents(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a + { + size := m.GrantedBytes.Size() + i -= size + if _, err := m.GrantedBytes.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) i-- - dAtA[i] = 0x12 - } - if m.ID != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.ID)) - i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *EventPayout) Marshal() (dAtA []byte, err error) { +func (m *EventCreatePayout) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -269,109 +479,1078 @@ func (m *EventPayout) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *EventPayout) MarshalTo(dAtA []byte) (int, error) { +func (m *EventCreatePayout) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EventPayout) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *EventCreatePayout) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if m.ID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x18 + } if len(m.NodeAddress) > 0 { i -= len(m.NodeAddress) copy(dAtA[i:], m.NodeAddress) i = encodeVarintEvents(dAtA, i, uint64(len(m.NodeAddress))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) i-- - dAtA[i] = 0x12 - } - if m.ID != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.ID)) - i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { - offset -= sovEvents(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *EventPayForPayout) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *EventUpdateStatus) Size() (n int) { - if m == nil { - return 0 - } + +func (m *EventPayForPayout) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventPayForPayout) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l if m.ID != 0 { - n += 1 + sovEvents(uint64(m.ID)) + i = encodeVarintEvents(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x28 } - if m.Status != 0 { - n += 1 + sovEvents(uint64(m.Status)) + if len(m.StakingReward) > 0 { + i -= len(m.StakingReward) + copy(dAtA[i:], m.StakingReward) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingReward))) + i-- + dAtA[i] = 0x22 } - return n + if len(m.Payment) > 0 { + i -= len(m.Payment) + copy(dAtA[i:], m.Payment) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Payment))) + i-- + dAtA[i] = 0x1a + } + if len(m.NodeAddress) > 0 { + i -= len(m.NodeAddress) + copy(dAtA[i:], m.NodeAddress) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NodeAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *EventAllocate) Size() (n int) { - if m == nil { - return 0 +func (m *EventPayForPlan) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *EventPayForPlan) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventPayForPlan) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l if m.ID != 0 { - n += 1 + sovEvents(uint64(m.ID)) + i = encodeVarintEvents(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x28 } - l = len(m.Address) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) + if len(m.StakingReward) > 0 { + i -= len(m.StakingReward) + copy(dAtA[i:], m.StakingReward) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingReward))) + i-- + dAtA[i] = 0x22 } - l = m.Bytes.Size() - n += 1 + l + sovEvents(uint64(l)) - return n + if len(m.ProviderAddress) > 0 { + i -= len(m.ProviderAddress) + copy(dAtA[i:], m.ProviderAddress) + i = encodeVarintEvents(dAtA, i, uint64(len(m.ProviderAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.Payment) > 0 { + i -= len(m.Payment) + copy(dAtA[i:], m.Payment) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Payment))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *EventPayout) Size() (n int) { - if m == nil { - return 0 +func (m *EventPayForSession) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *EventPayForSession) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventPayForSession) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.ID != 0 { - n += 1 + sovEvents(uint64(m.ID)) + if m.SubscriptionID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.SubscriptionID)) + i-- + dAtA[i] = 0x30 } - l = len(m.Address) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) + if m.SessionID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.SessionID)) + i-- + dAtA[i] = 0x28 } - l = len(m.NodeAddress) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) + if len(m.StakingReward) > 0 { + i -= len(m.StakingReward) + copy(dAtA[i:], m.StakingReward) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingReward))) + i-- + dAtA[i] = 0x22 } - return n -} - -func sovEvents(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozEvents(x uint64) (n int) { - return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + if len(m.Payment) > 0 { + i -= len(m.Payment) + copy(dAtA[i:], m.Payment) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Payment))) + i-- + dAtA[i] = 0x1a + } + if len(m.NodeAddress) > 0 { + i -= len(m.NodeAddress) + copy(dAtA[i:], m.NodeAddress) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NodeAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventRefund) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EventRefund) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventRefund) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ID != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x18 + } + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { + offset -= sovEvents(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EventUpdateStatus) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != 0 { + n += 1 + sovEvents(uint64(m.Status)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.ID != 0 { + n += 1 + sovEvents(uint64(m.ID)) + } + if m.PlanID != 0 { + n += 1 + sovEvents(uint64(m.PlanID)) + } + return n +} + +func (m *EventAllocate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = m.GrantedBytes.Size() + n += 1 + l + sovEvents(uint64(l)) + l = m.UtilisedBytes.Size() + n += 1 + l + sovEvents(uint64(l)) + if m.ID != 0 { + n += 1 + sovEvents(uint64(m.ID)) + } + return n +} + +func (m *EventCreatePayout) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NodeAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.ID != 0 { + n += 1 + sovEvents(uint64(m.ID)) + } + return n +} + +func (m *EventPayForPayout) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NodeAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Payment) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.StakingReward) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.ID != 0 { + n += 1 + sovEvents(uint64(m.ID)) + } + return n +} + +func (m *EventPayForPlan) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Payment) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.ProviderAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.StakingReward) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.ID != 0 { + n += 1 + sovEvents(uint64(m.ID)) + } + return n +} + +func (m *EventPayForSession) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NodeAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Payment) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.StakingReward) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.SessionID != 0 { + n += 1 + sovEvents(uint64(m.SessionID)) + } + if m.SubscriptionID != 0 { + n += 1 + sovEvents(uint64(m.SubscriptionID)) + } + return n +} + +func (m *EventRefund) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.ID != 0 { + n += 1 + sovEvents(uint64(m.ID)) + } + return n +} + +func sovEvents(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvents(x uint64) (n int) { + return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventUpdateStatus: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventUpdateStatus: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= types.Status(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PlanID", wireType) + } + m.PlanID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PlanID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventAllocate) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventAllocate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventAllocate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GrantedBytes", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.GrantedBytes.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UtilisedBytes", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.UtilisedBytes.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventCreatePayout) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventCreatePayout: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventCreatePayout: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NodeAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NodeAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventPayForPayout) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventPayForPayout: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventPayForPayout: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NodeAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NodeAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Payment", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Payment = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingReward", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingReward = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } -func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { +func (m *EventPayForPlan) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -394,17 +1573,17 @@ func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventUpdateStatus: wiretype end group for non-group") + return fmt.Errorf("proto: EventPayForPlan: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventUpdateStatus: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventPayForPlan: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - m.ID = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -414,16 +1593,125 @@ func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ID |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Payment", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Payment = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProviderAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingReward", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingReward = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) } - m.Status = 0 + m.ID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -433,7 +1721,7 @@ func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Status |= types.Status(b&0x7F) << shift + m.ID |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -459,7 +1747,7 @@ func (m *EventUpdateStatus) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventAllocate) Unmarshal(dAtA []byte) error { +func (m *EventPayForSession) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -482,17 +1770,17 @@ func (m *EventAllocate) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventAllocate: wiretype end group for non-group") + return fmt.Errorf("proto: EventPayForSession: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventAllocate: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventPayForSession: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - m.ID = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -502,14 +1790,27 @@ func (m *EventAllocate) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ID |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NodeAddress", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -537,11 +1838,11 @@ func (m *EventAllocate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.NodeAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Bytes", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Payment", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -569,10 +1870,78 @@ func (m *EventAllocate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Bytes.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Payment = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingReward", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingReward = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SessionID", wireType) + } + m.SessionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SessionID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubscriptionID", wireType) + } + m.SubscriptionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubscriptionID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) @@ -594,7 +1963,7 @@ func (m *EventAllocate) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventPayout) Unmarshal(dAtA []byte) error { +func (m *EventRefund) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -617,32 +1986,13 @@ func (m *EventPayout) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventPayout: wiretype end group for non-group") + return fmt.Errorf("proto: EventRefund: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventPayout: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventRefund: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - m.ID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ID |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } @@ -674,9 +2024,9 @@ func (m *EventPayout) Unmarshal(dAtA []byte) error { } m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NodeAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -704,8 +2054,27 @@ func (m *EventPayout) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.NodeAddress = string(dAtA[iNdEx:postIndex]) + m.Amount = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:])