-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
guoshijiang
committed
Mar 27, 2024
1 parent
50cc635
commit 2da6121
Showing
9 changed files
with
423 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# encoding=utf-8 | ||
|
||
import pytz | ||
from l3staking.models import ( | ||
Node | ||
) | ||
from services.savour_rpc import l3staking_pb2_grpc, l3staking_pb2 | ||
from django.conf import settings | ||
|
||
tz = pytz.timezone(settings.TIME_ZONE) | ||
|
||
|
||
class L3StakingServer(l3staking_pb2_grpc.L3StakingServiceServicer): | ||
def updateStakingNodeIncome(self, request, context) -> l3staking_pb2.StakingNodeRep: | ||
address = str(request.address) | ||
chain_id = str(request.chain_id) | ||
strategy = str(request.strategy) | ||
eth_income = str(request.eth_income) | ||
eth_income_rate = str(request.eth_income_rate) | ||
dp_income = str(request.dp_income) | ||
dp_income_rate = str(request.dp_income_rate) | ||
eth_evil = str(request.eth_evil) | ||
eth_evil_rate = str(request.eth_evil_rate) | ||
dp_evil = str(request.dp_evil) | ||
dp_evil_rate = str(request.dp_evil_rate) | ||
tvl = str(request.tvl) | ||
Node.objects.filter( | ||
address=address, | ||
chain__chain_id=chain_id, | ||
strategy__address=strategy | ||
).update( | ||
eth_income=eth_income, | ||
eth_income_rate=eth_income_rate, | ||
dp_income=dp_income, | ||
dp_income_rate=dp_income_rate, | ||
eth_evil=eth_evil, | ||
eth_evil_rate=eth_evil_rate, | ||
dp_evil=dp_evil, | ||
dp_evil_rate=dp_evil_rate, | ||
tvl=tvl | ||
) | ||
return l3staking_pb2.StakingNodeRep( | ||
code="200", | ||
msg="submit stake node income success", | ||
) |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#encoding=utf-8 | ||
|
||
import grpc | ||
from django.core.management.base import BaseCommand | ||
from concurrent import futures | ||
from services.savour_rpc import l3staking_pb2_grpc | ||
from l3staking.l3staking_server import L3StakingServer | ||
|
||
|
||
class Command(BaseCommand): | ||
def handle(self, *args, **options): | ||
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) | ||
l3staking_pb2_grpc.add_L3StakingServiceServicer_to_server( | ||
L3StakingServer(), | ||
server | ||
) | ||
server.add_insecure_port('[::]:50252') | ||
server.start() | ||
print("l3 staking rpc server start") | ||
server.wait_for_termination() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.1.1 on 2024-03-27 13:35 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('l3staking', '0002_stakingstrategy_chain'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='stakingstrategy', | ||
name='address', | ||
field=models.CharField(default='', max_length=100, verbose_name='策略地址'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Generated by the Protocol Buffers compiler. DO NOT EDIT! | ||
# source: savour_rpc/l3staking.proto | ||
# plugin: grpclib.plugin.main | ||
import abc | ||
import typing | ||
|
||
import grpclib.const | ||
import grpclib.client | ||
if typing.TYPE_CHECKING: | ||
import grpclib.server | ||
|
||
from services.savour_rpc import l3staking_pb2 | ||
|
||
|
||
class L3StakingServiceBase(abc.ABC): | ||
|
||
@abc.abstractmethod | ||
async def updateStakingNodeIncome(self, stream: 'grpclib.server.Stream[l3staking_pb2.StakingNodeReq, l3staking_pb2.StakingNodeRep]') -> None: | ||
pass | ||
|
||
def __mapping__(self) -> typing.Dict[str, grpclib.const.Handler]: | ||
return { | ||
'/services.l3staking.L3StakingService/updateStakingNodeIncome': grpclib.const.Handler( | ||
self.updateStakingNodeIncome, | ||
grpclib.const.Cardinality.UNARY_UNARY, | ||
l3staking_pb2.StakingNodeReq, | ||
l3staking_pb2.StakingNodeRep, | ||
), | ||
} | ||
|
||
|
||
class L3StakingServiceStub: | ||
|
||
def __init__(self, channel: grpclib.client.Channel) -> None: | ||
self.updateStakingNodeIncome = grpclib.client.UnaryUnaryMethod( | ||
channel, | ||
'/services.l3staking.L3StakingService/updateStakingNodeIncome', | ||
l3staking_pb2.StakingNodeReq, | ||
l3staking_pb2.StakingNodeRep, | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.