Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
sidecar
Commits
3ac49d2d
Commit
3ac49d2d
authored
Jan 20, 2022
by
harrylee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add result type
parent
58cc8183
Pipeline
#8459
failed with stages
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
0 deletions
+71
-0
ibtp.go
model/pb/ibtp.go
+67
-0
ibtp.pb.go
model/pb/ibtp.pb.go
+0
-0
ibtp.proto
model/pb/ibtp.proto
+4
-0
No files found.
model/pb/ibtp.go
View file @
3ac49d2d
...
@@ -3,6 +3,8 @@ package pb
...
@@ -3,6 +3,8 @@ package pb
import
(
import
(
"crypto/sha256"
"crypto/sha256"
"fmt"
"fmt"
"strconv"
"strings"
"github.com/meshplus/bitxhub-kit/types"
"github.com/meshplus/bitxhub-kit/types"
)
)
...
@@ -40,3 +42,68 @@ func (m *IBTP) Category() IBTP_Category {
...
@@ -40,3 +42,68 @@ func (m *IBTP) Category() IBTP_Category {
}
}
return
IBTP_UNKNOWN
return
IBTP_UNKNOWN
}
}
func
(
m
*
IBTP
)
ServicePair
()
string
{
return
fmt
.
Sprintf
(
"%s-%s"
,
m
.
From
,
m
.
To
)
}
// ParseFrom should be called after CheckServiceID is called
func
(
m
*
IBTP
)
ParseFrom
()
(
string
,
string
,
string
)
{
bxhID
,
chainID
,
serviceID
,
_
:=
ParseFullServiceID
(
m
.
From
)
return
bxhID
,
chainID
,
serviceID
}
// ParseTo should be called after CheckServiceID is called
func
(
m
*
IBTP
)
ParseTo
()
(
string
,
string
,
string
)
{
bxhID
,
chainID
,
serviceID
,
_
:=
ParseFullServiceID
(
m
.
To
)
return
bxhID
,
chainID
,
serviceID
}
func
(
m
*
IBTP
)
CheckServiceID
()
error
{
_
,
_
,
_
,
err
:=
ParseFullServiceID
(
m
.
From
)
if
err
!=
nil
{
return
err
}
_
,
_
,
_
,
err
=
ParseFullServiceID
(
m
.
To
)
return
err
}
func
ParseFullServiceID
(
id
string
)
(
string
,
string
,
string
,
error
)
{
splits
:=
strings
.
Split
(
id
,
":"
)
if
len
(
splits
)
!=
3
{
return
""
,
""
,
""
,
fmt
.
Errorf
(
"invalid full service ID: %s"
,
id
)
}
return
splits
[
0
],
splits
[
1
],
splits
[
2
],
nil
}
func
ParseServicePair
(
servicePair
string
)
(
string
,
string
,
error
)
{
splits
:=
strings
.
Split
(
servicePair
,
"-"
)
if
len
(
splits
)
!=
2
{
return
""
,
""
,
fmt
.
Errorf
(
"invalid service pair: %s"
,
servicePair
)
}
return
splits
[
0
],
splits
[
1
],
nil
}
func
ParseIBTPID
(
id
string
)
(
string
,
string
,
uint64
,
error
)
{
splits
:=
strings
.
Split
(
id
,
"-"
)
if
len
(
splits
)
!=
3
{
return
""
,
""
,
0
,
fmt
.
Errorf
(
"invalid IBTP ID: %s"
,
id
)
}
index
,
err
:=
strconv
.
Atoi
(
splits
[
2
])
if
err
!=
nil
{
return
""
,
""
,
0
,
fmt
.
Errorf
(
"invalid IBTP ID: %s"
,
id
)
}
return
splits
[
0
],
splits
[
1
],
uint64
(
index
),
nil
}
func
GenServicePair
(
from
,
to
string
)
string
{
return
fmt
.
Sprintf
(
"%s-%s"
,
from
,
to
)
}
model/pb/ibtp.pb.go
View file @
3ac49d2d
This diff is collapsed.
Click to expand it.
model/pb/ibtp.proto
View file @
3ac49d2d
...
@@ -61,3 +61,7 @@ message content {
...
@@ -61,3 +61,7 @@ message content {
message
IBTPs
{
message
IBTPs
{
repeated
IBTP
ibtps
=
1
;
repeated
IBTP
ibtps
=
1
;
}
}
message
result
{
repeated
bytes
data
=
1
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment