FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
hypercube/src/request_processor.rs at main · vigeti/hypercube · GitHub
vigeti
/
hypercube
Public
forked from
hypercube-lab/hypercube
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
hypercube
/
src
/
request_processor.rs
Copy path
More file actions
More file actions
Latest commit
History
History
History
66 lines (58 loc) · 2.23 KB
Breadcrumbs
hypercube
/
src
/
request_processor.rs
Copy path
File metadata and controls
66 lines (58 loc) · 2.23 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use
transaction_processor
::
TransactionProcessor
;
use
request
::
{
Request
,
Response
}
;
use
std
::
net
::
SocketAddr
;
use
std
::
sync
::
Arc
;
pub
struct
RequestProcessor
{
transaction_processor
:
Arc
<
TransactionProcessor
>
,
}
impl
RequestProcessor
{
pub
fn
new
(
transaction_processor
:
Arc
<
TransactionProcessor
>
)
->
Self
{
RequestProcessor
{
transaction_processor
}
}
fn
process_request
(
&
self
,
msg
:
Request
,
rsp_addr
:
SocketAddr
,
)
->
Option
<
(
Response
,
SocketAddr
)
>
{
match
msg
{
Request
::
GetAccount
{
key
}
=>
{
let
account =
self
.
transaction_processor
.
get_account
(
&
key
)
;
let
rsp =
(
Response
::
Account
{
key
,
account
}
,
rsp_addr
)
;
info
!
(
"Response::Account {:?}"
,
rsp
)
;
Some
(
rsp
)
}
Request
::
GetLastId
=>
{
let
id =
self
.
transaction_processor
.
last_id
(
)
;
let
rsp =
(
Response
::
LastId
{
id
}
,
rsp_addr
)
;
info
!
(
"Response::LastId {:?}"
,
rsp
)
;
Some
(
rsp
)
}
Request
::
GetTransactionCount
=>
{
let
transaction_count =
self
.
transaction_processor
.
transaction_count
(
)
as
u64
;
let
rsp =
(
Response
::
TransactionCount
{
transaction_count
}
,
rsp_addr
)
;
info
!
(
"Response::TransactionCount {:?}"
,
rsp
)
;
Some
(
rsp
)
}
Request
::
GetSignature
{
signature
}
=>
{
let
signature_status =
self
.
transaction_processor
.
has_signature
(
&
signature
)
;
let
rsp =
(
Response
::
SignatureStatus
{
signature_status
}
,
rsp_addr
)
;
info
!
(
"Response::Signature {:?}"
,
rsp
)
;
Some
(
rsp
)
}
Request
::
GetFinality
=>
{
let
time =
self
.
transaction_processor
.
finality
(
)
;
let
rsp =
(
Response
::
Finality
{
time
}
,
rsp_addr
)
;
info
!
(
"Response::Finality {:?}"
,
rsp
)
;
Some
(
rsp
)
}
}
}
pub
fn
process_requests
(
&
self
,
reqs
:
Vec
<
(
Request
,
SocketAddr
)
>
,
)
->
Vec
<
(
Response
,
SocketAddr
)
>
{
reqs
.
into_iter
(
)
.
filter_map
(
|
(
req
,
rsp_addr
)
|
self
.
process_request
(
req
,
rsp_addr
)
)
.
collect
(
)
}
}
Back
|
FazBrowse Home
|
New Git URL