Commit f07ce479 authored by suyanlong's avatar suyanlong

Fixed index to nonce

parent 84cfcec4
Pipeline #7931 canceled with stages
......@@ -85,7 +85,7 @@ func (a *appChain) ExecuteIBTP(ibtp *pb.IBTP) (*pb.IBTP, error) {
return nil, fmt.Errorf("nil ibtp structure")
}
a.logger.WithFields(logrus.Fields{
"index": ibtp.Index,
"index": ibtp.Nonce,
"type": ibtp.Type,
"from": ibtp.From,
"id": ibtp.ID(),
......@@ -106,7 +106,7 @@ func (a *appChain) applyInterchainIBTP(ibtp *pb.IBTP) (*pb.IBTP, error) {
entry := a.logger.WithFields(logrus.Fields{
"from": ibtp.From,
"type": ibtp.Type,
"index": ibtp.Index,
"index": ibtp.Nonce,
})
// todo: deal with plugin returned error
......@@ -180,7 +180,7 @@ func (a *appChain) execCallback(ibtp *pb.IBTP) error {
// executor should not change the content of ibtp
ibtp.From, ibtp.To = ibtp.To, ibtp.From
a.logger.WithFields(logrus.Fields{
"index": ibtp.Index,
"index": ibtp.Nonce,
"type": ibtp.Type,
"status": resp.Status,
"msg": resp.Message,
......@@ -210,7 +210,7 @@ func (a *appChain) execRollback(ibtp *pb.IBTP, isSrcChain bool) error {
}
a.logger.WithFields(logrus.Fields{
"index": ibtp.Index,
"index": ibtp.Nonce,
"type": ibtp.Type,
"status": resp.Status,
"msg": resp.Message,
......@@ -254,6 +254,7 @@ func (a *appChain) ListenIBTP() <-chan *pb.IBTP {
}
// QueryIBTP queries interchain tx recorded in appchain given ibtp id
//func (a *appChain) QueryIBTP(to string,id string) (*pb.IBTP, error) {
func (a *appChain) QueryIBTP(id string) (*pb.IBTP, error) {
// TODO(xcc): Encapsulate as a function
args := strings.Split(id, "-")
......@@ -317,7 +318,7 @@ func (a *appChain) QueryOuterMeta() map[string]uint64 {
func (a *appChain) handleIBTP(ibtp *pb.IBTP) {
if err := a.encryption(ibtp); err != nil {
a.logger.WithFields(logrus.Fields{
"index": ibtp.Index,
"index": ibtp.Nonce,
"to": ibtp.To,
}).Error("check encryption")
return
......
......@@ -13,6 +13,9 @@ type Executor interface {
// Rollback rollbacks ibtp on appchain
Rollback(ibtp *pb.IBTP, isSrcChain bool)
// QueryIBTPReceipt query receipt for original interchain ibtp
QueryIBTPReceipt(originalIBTP *pb.IBTP) (*pb.IBTP, error)
// QueryInterchainMeta queries latest index map of ibtps executed on appchain
// For the returned map, key is the source chain ID,
// and value is the latest index of tx executed on appchain
......@@ -22,7 +25,4 @@ type Executor interface {
// For the returned map, key is the destination chain ID,
// and value is the latest index of callback executed on appchain
QueryCallbackMeta() map[string]uint64
// QueryIBTPReceipt query receipt for original interchain ibtp
QueryIBTPReceipt(originalIBTP *pb.IBTP) (*pb.IBTP, error)
}
......@@ -7,6 +7,7 @@ type Monitor interface {
// listen on interchain ibtp from appchain
ListenIBTP() <-chan *pb.IBTP
// query historical ibtp by its id
//QueryIBTP(id string) (*pb.IBTP, error)
QueryIBTP(id string) (*pb.IBTP, error)
// QueryLatestMeta queries latest index map of ibtps threw on appchain
QueryOuterMeta() map[string]uint64
......
......@@ -8,14 +8,14 @@ import (
)
func (m *IBTP) ID() string {
return fmt.Sprintf("%s-%s-%d", m.From, m.To, m.Index)
return fmt.Sprintf("%s-%s-%d", m.From, m.To, m.Nonce)
}
func (m *IBTP) Hash() *types.Hash {
ibtp := &IBTP{
From: m.From,
To: m.To,
Index: m.Index,
Nonce: m.Nonce,
Type: m.Type,
Timestamp: m.Timestamp,
Payload: m.Payload,
......
......@@ -97,7 +97,7 @@ type IBTP struct {
// ID of receiving chain
To string `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"`
// Index of inter-chain transaction
Index uint64 `protobuf:"varint,3,opt,name=index,proto3" json:"index,omitempty"`
Nonce uint64 `protobuf:"varint,3,opt,name=nonce,proto3" json:"nonce,omitempty"`
// inter-chain transaction type
Type IBTP_Type `protobuf:"varint,4,opt,name=type,proto3,enum=pb.IBTP_Type" json:"type,omitempty"`
// Timestamp of inter-chain events
......@@ -161,9 +161,9 @@ func (m *IBTP) GetTo() string {
return ""
}
func (m *IBTP) GetIndex() uint64 {
func (m *IBTP) GetNonce() uint64 {
if m != nil {
return m.Index
return m.Nonce
}
return 0
}
......@@ -425,44 +425,44 @@ func init() {
func init() { proto.RegisterFile("ibtp.proto", fileDescriptor_7576a0a5bf0190a3) }
var fileDescriptor_7576a0a5bf0190a3 = []byte{
// 585 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0xcd, 0x6e, 0xd3, 0x30,
0x1c, 0xaf, 0xdb, 0xf4, 0xeb, 0xdf, 0x6e, 0x8b, 0x3c, 0x18, 0x66, 0x42, 0x51, 0xe8, 0x01, 0xc2,
0xa5, 0x87, 0x82, 0xb8, 0x77, 0x99, 0xc7, 0x22, 0x58, 0x36, 0x9c, 0x54, 0x70, 0xab, 0xf2, 0xb5,
0x2a, 0x62, 0x8b, 0x23, 0xc7, 0x43, 0xeb, 0x5b, 0xf0, 0x1e, 0xbc, 0x08, 0xc7, 0x1d, 0x39, 0xa2,
0xed, 0xc4, 0x85, 0x67, 0x40, 0x76, 0xda, 0x6d, 0x7c, 0xdc, 0xfc, 0xfb, 0xf2, 0x3f, 0xb1, 0x7f,
0x06, 0xc8, 0x63, 0x59, 0x8e, 0x4b, 0xc1, 0x25, 0xc7, 0xcd, 0x32, 0xde, 0x1d, 0xc4, 0x51, 0x95,
0x27, 0x35, 0x31, 0xfa, 0xd5, 0x02, 0xc3, 0xdb, 0x0b, 0x4f, 0x30, 0x06, 0xe3, 0x54, 0xf0, 0x73,
0x82, 0x6c, 0xe4, 0xf4, 0x99, 0x5e, 0xe3, 0x4d, 0x68, 0x4a, 0x4e, 0x9a, 0x9a, 0x69, 0x4a, 0x8e,
0x1f, 0x40, 0x3b, 0x2f, 0xd2, 0xec, 0x92, 0xb4, 0x6c, 0xe4, 0x18, 0xac, 0x06, 0xf8, 0x29, 0x18,
0x72, 0x59, 0x66, 0xc4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c, 0x1e, 0x3d, 0x87, 0xb6, 0x2a, 0x73, 0x85, 0x2d,
0x68, 0xab, 0x77, 0x54, 0x11, 0x64, 0xb7, 0x9c, 0xc1, 0xa4, 0xb7, 0xae, 0x39, 0xab, 0xe9, 0x3d,
0xf2, 0xed, 0xda, 0x42, 0x57, 0xd7, 0x16, 0xfa, 0x71, 0x6d, 0xa1, 0x2f, 0x37, 0x56, 0xe3, 0xea,
0xc6, 0x6a, 0x7c, 0xbf, 0xb1, 0x1a, 0x71, 0x47, 0xbf, 0xb4, 0x97, 0xbf, 0x03, 0x00, 0x00, 0xff,
0xff, 0xe6, 0x58, 0x74, 0xbc, 0x88, 0x03, 0x00, 0x00,
// 587 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0xcf, 0x6e, 0xd3, 0x3e,
0x1c, 0xaf, 0xdb, 0xb4, 0x4d, 0xbf, 0xed, 0xb6, 0xc8, 0xfb, 0xfd, 0x86, 0x99, 0x50, 0x14, 0x7a,
0x80, 0x70, 0xe9, 0xa1, 0x20, 0xee, 0x5d, 0xe6, 0xb1, 0x08, 0x96, 0x0d, 0x27, 0x15, 0xdc, 0xaa,
0x24, 0xcd, 0xaa, 0x88, 0x2d, 0x8e, 0x1c, 0x0f, 0xd1, 0xb7, 0xe0, 0x3d, 0x78, 0x11, 0x8e, 0x3b,
0x72, 0x44, 0xdb, 0x89, 0x0b, 0xcf, 0x80, 0xec, 0xb4, 0xeb, 0xf8, 0x73, 0xf3, 0xe7, 0x9f, 0xbf,
0x89, 0xfd, 0x31, 0x40, 0x9e, 0xc8, 0x72, 0x54, 0x0a, 0x2e, 0x39, 0x6e, 0x96, 0xc9, 0x7e, 0x3f,
0x89, 0xab, 0x3c, 0xad, 0x89, 0xe1, 0xcf, 0x16, 0x18, 0xfe, 0x41, 0x74, 0x86, 0x31, 0x18, 0xe7,
0x82, 0x5f, 0x12, 0xe4,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0x1a, 0x5f, 0x5c, 0x24, 0x71, 0xfa, 0x41, 0x17, 0xaa, 0xc7, 0xee, 0x30,
0xde, 0x83, 0x8e, 0xf2, 0x78, 0x09, 0xe9, 0xe8, 0xc4, 0x0a, 0xa9, 0x8c, 0xe0, 0xab, 0x4c, 0xb7,
0xce, 0xac, 0xf1, 0x3a, 0xc3, 0x12, 0x62, 0x6e, 0x32, 0x2c, 0x19, 0x3e, 0x85, 0xb6, 0x2a, 0x73,
0x85, 0x6d, 0x68, 0xab, 0x77, 0x54, 0x11, 0xe4, 0xb4, 0xdc, 0xfe, 0xd8, 0x5c, 0xd7, 0x9c, 0xd5,
0xf4, 0x01, 0xf9, 0x7a, 0x63, 0xa3, 0xeb, 0x1b, 0x1b, 0x7d, 0xbf, 0xb1, 0xd1, 0xe7, 0x5b, 0xbb,
0x71, 0x7d, 0x6b, 0x37, 0xbe, 0xdd, 0xda, 0x8d, 0xa4, 0xa3, 0x5f, 0xda, 0xf3, 0x5f, 0x01, 0x00,
0x00, 0xff, 0xff, 0x98, 0x2d, 0x3a, 0x6f, 0x88, 0x03, 0x00, 0x00,
}
func (m *IBTP) Marshal() (dAtA []byte, err error) {
......@@ -535,8 +535,8 @@ func (m *IBTP) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i--
dAtA[i] = 0x20
}
if m.Index != 0 {
i = encodeVarintIbtp(dAtA, i, uint64(m.Index))
if m.Nonce != 0 {
i = encodeVarintIbtp(dAtA, i, uint64(m.Nonce))
i--
dAtA[i] = 0x18
}
......@@ -744,8 +744,8 @@ func (m *IBTP) Size() (n int) {
if l > 0 {
n += 1 + l + sovIbtp(uint64(l))
}
if m.Index != 0 {
n += 1 + sovIbtp(uint64(m.Index))
if m.Nonce != 0 {
n += 1 + sovIbtp(uint64(m.Nonce))
}
if m.Type != 0 {
n += 1 + sovIbtp(uint64(m.Type))
......@@ -955,9 +955,9 @@ func (m *IBTP) Unmarshal(dAtA []byte) error {
iNdEx = postIndex
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType)
}
m.Index = 0
m.Nonce = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowIbtp
......@@ -967,7 +967,7 @@ func (m *IBTP) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
m.Index |= uint64(b&0x7F) << shift
m.Nonce |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
......
......@@ -27,7 +27,7 @@ message IBTP {
// ID of receiving chain
string to = 2;
// Index of inter-chain transaction
uint64 index = 3;
uint64 nonce = 3;
// inter-chain transaction type
Type type = 4;
// Timestamp of inter-chain events
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment