From d5d199316c7ed1d9446681f8caedbcb1f0f813f4 Mon Sep 17 00:00:00 2001 From: Robin Lai Date: Wed, 4 Dec 2019 17:24:27 -0800 Subject: [PATCH 1/5] refactor ledger grpc client --- ledger/ledger.go | 25 ++-- ledger/sample/demo.go | 137 +++++++++++---------- protos/ledger/ledger.pb.go | 245 +++++++++++++++++++------------------ protos/ledger/ledger.proto | 2 +- protos/node/node.pb.go | 22 ++-- protos/status/status.pb.go | 40 +++--- utils/grpc/client.go | 3 + utils/grpc/ledger.go | 19 +++ 8 files changed, 256 insertions(+), 237 deletions(-) create mode 100644 utils/grpc/ledger.go diff --git a/ledger/ledger.go b/ledger/ledger.go index 10caa03..8023930 100644 --- a/ledger/ledger.go +++ b/ledger/ledger.go @@ -3,7 +3,6 @@ package ledger import ( "context" "crypto/tls" - "crypto/x509" "fmt" "time" @@ -19,21 +18,17 @@ import ( func LedgerConnection(ledgerAddr, certFile string) (*grpc.ClientConn, error) { var grpcOption grpc.DialOption - if certFile == "" { + if certFile == "wi" { grpcOption = grpc.WithInsecure() } else { - b := []byte(certFile) - cp := x509.NewCertPool() - if !cp.AppendCertsFromPEM(b) { - return nil, fmt.Errorf("credentials: failed to append certificates") - } - credential := credentials.NewTLS(&tls.Config{RootCAs: cp}) + credential := credentials.NewTLS(&tls.Config{}) grpcOption = grpc.WithTransportCredentials(credential) } - conn, err := grpc.Dial(ledgerAddr, grpcOption) + conn, err := grpc.Dial(ledgerAddr, grpcOption, grpc.WithBlock()) if err != nil { return nil, err } + fmt.Println("state:", conn.GetState()) return conn, nil } @@ -45,8 +40,8 @@ func CloseConnection(conn *grpc.ClientConn) { } } -func NewClient(conn *grpc.ClientConn) ledgerPb.ChannelsClient { - return ledgerPb.NewChannelsClient(conn) +func NewClient(conn *grpc.ClientConn) ledgerPb.ChannelsServiceClient { + return ledgerPb.NewChannelsServiceClient(conn) } func NewAccount(pubKey ic.PubKey, amount int64) (*ledgerPb.Account, error) { @@ -94,7 +89,7 @@ func NewSignedChannelState(channelState *ledgerPb.ChannelState, fromSig []byte, } } -func ImportAccount(ctx context.Context, pubKey ic.PubKey, ledgerClient ledgerPb.ChannelsClient) (*ledgerPb.Account, error) { +func ImportAccount(ctx context.Context, pubKey ic.PubKey, ledgerClient ledgerPb.ChannelsServiceClient) (*ledgerPb.Account, error) { keyBytes, err := pubKey.Raw() if err != nil { return nil, err @@ -106,7 +101,7 @@ func ImportAccount(ctx context.Context, pubKey ic.PubKey, ledgerClient ledgerPb. return res.GetAccount(), nil } -func ImportSignedAccount(ctx context.Context, privKey ic.PrivKey, pubKey ic.PubKey, ledgerClient ledgerPb.ChannelsClient) (*ledgerPb.SignedCreateAccountResult, error) { +func ImportSignedAccount(ctx context.Context, privKey ic.PrivKey, pubKey ic.PubKey, ledgerClient ledgerPb.ChannelsServiceClient) (*ledgerPb.SignedCreateAccountResult, error) { pubKeyBytes, err := pubKey.Raw() if err != nil { return nil, err @@ -121,14 +116,14 @@ func ImportSignedAccount(ctx context.Context, privKey ic.PrivKey, pubKey ic.PubK return ledgerClient.SignedCreateAccount(ctx, signedPubkey) } -func CreateChannel(ctx context.Context, ledgerClient ledgerPb.ChannelsClient, channelCommit *ledgerPb.ChannelCommit, sig []byte) (*ledgerPb.ChannelID, error) { +func CreateChannel(ctx context.Context, ledgerClient ledgerPb.ChannelsServiceClient, channelCommit *ledgerPb.ChannelCommit, sig []byte) (*ledgerPb.ChannelID, error) { return ledgerClient.CreateChannel(ctx, &ledgerPb.SignedChannelCommit{ Channel: channelCommit, Signature: sig, }) } -func CloseChannel(ctx context.Context, ledgerClient ledgerPb.ChannelsClient, signedChannelState *ledgerPb.SignedChannelState) error { +func CloseChannel(ctx context.Context, ledgerClient ledgerPb.ChannelsServiceClient, signedChannelState *ledgerPb.SignedChannelState) error { _, err := ledgerClient.CloseChannel(ctx, signedChannelState) if err != nil { return err diff --git a/ledger/sample/demo.go b/ledger/sample/demo.go index e4a63e7..24f3dea 100644 --- a/ledger/sample/demo.go +++ b/ledger/sample/demo.go @@ -5,6 +5,8 @@ import ( "github.com/tron-us/go-btfs-common/crypto" "github.com/tron-us/go-btfs-common/ledger" + ledgerpb "github.com/tron-us/go-btfs-common/protos/ledger" + "github.com/tron-us/go-btfs-common/utils/grpc" "github.com/tron-us/go-common/v2/log" "go.uber.org/zap" @@ -16,74 +18,73 @@ const ( ) func main() { - ctx := context.Background() - // build connection with ledger - clientConn, err := ledger.LedgerConnection("ledger-dev.bt.co:443", "") + err := grpc.LedgerClient("https://ledger-dev.bt.co:443").WithContext(context.Background(), + func(ctx context.Context, ledgerClient ledgerpb.ChannelsServiceClient) error { + // create payer Account + payerPrivKey, err := crypto.ToPrivKey(PayerPrivKeyString) + if err != nil { + log.Panic("can not convert to private key", zap.Error(err)) + } + payerPubKey := payerPrivKey.GetPublic() + _, err = ledger.ImportSignedAccount(ctx, payerPrivKey, payerPubKey, ledgerClient) + if err != nil { + log.Panic("can not create account on ledger", zap.Error(err)) + } + // create receiver account + recvPrivKey, err := crypto.ToPrivKey(ReceiverPrivKeyString) + if err != nil { + log.Panic("can not convert to private key", zap.Error(err)) + } + recvPubKey := recvPrivKey.GetPublic() + _, err = ledger.ImportSignedAccount(ctx, recvPrivKey, recvPubKey, ledgerClient) + if err != nil { + log.Panic("can not create account on ledger", zap.Error(err)) + } + // prepare channel commit + amount := int64(1) + channelCommit, err := ledger.NewChannelCommit(payerPubKey, recvPubKey, amount) + if err != nil { + log.Panic("can not create channel commit", zap.Error(err)) + } + // sign for the channel commit + fromSig, err := crypto.Sign(payerPrivKey, channelCommit) + if err != nil { + log.Panic("fail to sign channel commit", zap.Error(err)) + } + // create channel: payer start the channel + channelID, err := ledger.CreateChannel(ctx, ledgerClient, channelCommit, fromSig) + if err != nil { + log.Panic("fail to create channel", zap.Error(err)) + } + // channel state: transfer money from -> to + fromAcc, err := ledger.NewAccount(payerPubKey, 0) + if err != nil { + log.Panic("wrong account on channel", zap.Error(err)) + } + toAcc, err := ledger.NewAccount(recvPubKey, amount) + if err != nil { + log.Panic("wrong account on channel", zap.Error(err)) + } + channelState := ledger.NewChannelState(channelID, 1, fromAcc, toAcc) + // need permission from both account, get signature from both + fromSigState, err := crypto.Sign(payerPrivKey, channelState) + if err != nil { + log.Panic("error when signing the channel state", zap.Error(err)) + } + toSigState, err := crypto.Sign(recvPrivKey, channelState) + if err != nil { + log.Panic("error when signing the channel state", zap.Error(err)) + } + signedChannelState := ledger.NewSignedChannelState(channelState, fromSigState, toSigState) + // close channel + err = ledger.CloseChannel(ctx, ledgerClient, signedChannelState) + if err != nil { + log.Panic("fail to close channel", zap.Error(err)) + } + return nil + }) if err != nil { - log.Panic("fail to connect", zap.Error(err)) - } - defer ledger.CloseConnection(clientConn) - // new ledger client - ledgerClient := ledger.NewClient(clientConn) - // create payer Account - payerPrivKey, err := crypto.ToPrivKey(PayerPrivKeyString) - if err != nil { - log.Panic("can not convert to private key", zap.Error(err)) - } - payerPubKey := payerPrivKey.GetPublic() - _, err = ledger.ImportSignedAccount(ctx, payerPrivKey, payerPubKey, ledgerClient) - if err != nil { - log.Panic("can not create account on ledger", zap.Error(err)) - } - // create receiver account - recvPrivKey, err := crypto.ToPrivKey(ReceiverPrivKeyString) - if err != nil { - log.Panic("can not convert to private key", zap.Error(err)) - } - recvPubKey := recvPrivKey.GetPublic() - _, err = ledger.ImportSignedAccount(ctx, recvPrivKey, recvPubKey, ledgerClient) - if err != nil { - log.Panic("can not create account on ledger", zap.Error(err)) - } - // prepare channel commit - amount := int64(1) - channelCommit, err := ledger.NewChannelCommit(payerPubKey, recvPubKey, amount) - if err != nil { - log.Panic("can not create channel commit", zap.Error(err)) - } - // sign for the channel commit - fromSig, err := crypto.Sign(payerPrivKey, channelCommit) - if err != nil { - log.Panic("fail to sign channel commit", zap.Error(err)) - } - // create channel: payer start the channel - channelID, err := ledger.CreateChannel(ctx, ledgerClient, channelCommit, fromSig) - if err != nil { - log.Panic("fail to create channel", zap.Error(err)) - } - // channel state: transfer money from -> to - fromAcc, err := ledger.NewAccount(payerPubKey, 0) - if err != nil { - log.Panic("wrong account on channel", zap.Error(err)) - } - toAcc, err := ledger.NewAccount(recvPubKey, amount) - if err != nil { - log.Panic("wrong account on channel", zap.Error(err)) - } - channelState := ledger.NewChannelState(channelID, 1, fromAcc, toAcc) - // need permission from both account, get signature from both - fromSigState, err := crypto.Sign(payerPrivKey, channelState) - if err != nil { - log.Panic("error when signing the channel state", zap.Error(err)) - } - toSigState, err := crypto.Sign(recvPrivKey, channelState) - if err != nil { - log.Panic("error when signing the channel state", zap.Error(err)) - } - signedChannelState := ledger.NewSignedChannelState(channelState, fromSigState, toSigState) - // close channel - err = ledger.CloseChannel(ctx, ledgerClient, signedChannelState) - if err != nil { - log.Panic("fail to close channel", zap.Error(err)) + log.Panic(err.Error()) } } + diff --git a/protos/ledger/ledger.pb.go b/protos/ledger/ledger.pb.go index 2b43cc0..45e37d4 100644 --- a/protos/ledger/ledger.pb.go +++ b/protos/ledger/ledger.pb.go @@ -967,58 +967,59 @@ func init() { proto.RegisterFile("protos/ledger/ledger.proto", fileDescriptor_85 func init() { golang_proto.RegisterFile("protos/ledger/ledger.proto", fileDescriptor_858b35020cfe9185) } var fileDescriptor_858b35020cfe9185 = []byte{ - // 814 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x56, 0xcd, 0x6e, 0xd3, 0x4a, - 0x14, 0x96, 0x9d, 0x34, 0x6e, 0x4e, 0x7e, 0x7a, 0xef, 0xa4, 0xf7, 0xde, 0xd4, 0xbd, 0x37, 0xb7, - 0x75, 0x55, 0x51, 0x8a, 0x48, 0xaa, 0x22, 0x24, 0x76, 0xfd, 0x09, 0x52, 0xa9, 0x40, 0x55, 0x48, - 0x60, 0xc3, 0x26, 0x72, 0xec, 0x49, 0x6a, 0xe1, 0x78, 0x82, 0x3d, 0x56, 0xe9, 0x4b, 0xb0, 0x61, - 0xc3, 0x82, 0xf7, 0x60, 0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 0xbf, 0xa1, 0x60, 0x8e, 0x49, - 0xe8, 0xd1, 0x7a, 0x6e, 0x43, 0xd9, 0xc9, 0x75, 0xc5, 0x0a, 0xad, 0xc1, 0x32, 0x67, 0xec, 0x3b, - 0x76, 0x3d, 0xcf, 0x3d, 0x1a, 0x5f, 0x9f, 0xda, 0x86, 0x0d, 0xb5, 0x48, 0x74, 0x3a, 0xc6, 0x16, - 0x68, 0x56, 0x64, 0x10, 0x51, 0xfe, 0x25, 0x0f, 0x4e, 0xe1, 0xba, 0x12, 0xf5, 0x9b, 0x24, 0x1c, - 0x42, 0xad, 0xed, 0x63, 0x93, 0xe2, 0x23, 0xcb, 0x62, 0x11, 0x75, 0x71, 0x10, 0xba, 0x14, 0xdd, - 0x07, 0xcd, 0x8c, 0x0c, 0xe2, 0x94, 0x15, 0x79, 0x8a, 0xc4, 0x49, 0xbf, 0xf1, 0x18, 0xd6, 0x44, - 0x9c, 0x19, 0x3c, 0x75, 0xd0, 0x06, 0xa6, 0x6b, 0x7a, 0x16, 0xe6, 0x3c, 0xb9, 0xae, 0x5c, 0x1a, - 0x1d, 0xd0, 0x04, 0x14, 0x3d, 0x00, 0xcd, 0xb4, 0x6d, 0x1f, 0x07, 0xc1, 0xe2, 0xc4, 0x4b, 0xc4, - 0x34, 0xa3, 0x9a, 0x66, 0x5c, 0x87, 0xa2, 0x48, 0xc1, 0xe9, 0x53, 0x54, 0x05, 0xd5, 0xb1, 0xc5, - 0x99, 0xaa, 0x63, 0x1b, 0x5f, 0x15, 0x28, 0x49, 0xaf, 0x37, 0x24, 0x68, 0x33, 0xf6, 0x4f, 0x1d, - 0x17, 0x6f, 0x67, 0x5b, 0xd0, 0x3e, 0x94, 0x87, 0x3e, 0x19, 0xf7, 0x65, 0x22, 0xd4, 0xec, 0x44, - 0x94, 0x18, 0x48, 0x4a, 0x69, 0x02, 0x50, 0x12, 0xef, 0xc8, 0x65, 0xef, 0x28, 0x52, 0x22, 0xf1, - 0xdb, 0x50, 0xb5, 0x5c, 0x12, 0xe0, 0x7e, 0x80, 0xdf, 0x85, 0x98, 0x89, 0x8a, 0xba, 0xa0, 0xc2, - 0xad, 0x3d, 0x61, 0x34, 0x3e, 0x28, 0x80, 0x52, 0xcd, 0xd0, 0xa3, 0x26, 0xc5, 0xa8, 0x39, 0xdb, - 0x0b, 0xab, 0x33, 0x4a, 0x38, 0x2c, 0x69, 0x85, 0x6d, 0xa8, 0x72, 0x45, 0xb3, 0xfd, 0x50, 0x61, - 0xd6, 0x9e, 0x34, 0xa2, 0x4d, 0x28, 0x53, 0x32, 0x05, 0xca, 0x71, 0x50, 0x89, 0x92, 0x18, 0x62, - 0x60, 0xa8, 0xb5, 0x59, 0x84, 0x71, 0x73, 0x86, 0x7e, 0x40, 0xfc, 0xbb, 0x5f, 0xa0, 0x79, 0xdd, - 0x6a, 0x96, 0xee, 0x8f, 0x0a, 0x94, 0x53, 0x8a, 0xef, 0x50, 0x36, 0x1d, 0x96, 0x67, 0x48, 0xe3, - 0x35, 0xda, 0x82, 0x3c, 0x93, 0xba, 0xa8, 0x30, 0xdc, 0x89, 0xfe, 0x07, 0x95, 0x12, 0x5e, 0x87, - 0x0c, 0x88, 0x4a, 0x89, 0x71, 0x94, 0xcc, 0x0d, 0x9e, 0x03, 0xb4, 0x07, 0x4b, 0x01, 0x0b, 0x4f, - 0x04, 0xa6, 0xcb, 0x4d, 0xf3, 0x25, 0xeb, 0x46, 0x40, 0xe3, 0x8b, 0x22, 0x6f, 0x77, 0x9c, 0x9a, - 0x8e, 0xe9, 0xf8, 0x68, 0x17, 0x34, 0xe2, 0xda, 0xfd, 0x5b, 0x47, 0x5b, 0x81, 0xb8, 0x36, 0x1b, - 0x81, 0xbb, 0xa0, 0x79, 0xf8, 0x82, 0x63, 0x17, 0x8e, 0xa0, 0x82, 0x87, 0x2f, 0xa2, 0x71, 0x59, - 0x61, 0xbc, 0xb3, 0x35, 0x2d, 0x13, 0xd7, 0x4e, 0xea, 0xbe, 0x05, 0x15, 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, 0x00, 0xff, 0xff, 0x0b, 0x41, 0x6d, 0x22, 0x3d, 0x08, 0x00, 0x00, + // 821 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x56, 0xcd, 0x6e, 0xdb, 0x38, + 0x10, 0x86, 0x64, 0xc7, 0x8a, 0xc7, 0x3f, 0xd9, 0xa5, 0xb3, 0xbb, 0x8e, 0xb2, 0xeb, 0x4d, 0x14, + 0x04, 0x9b, 0x4d, 0x51, 0x3b, 0x48, 0x51, 0xa0, 0xb7, 0xfc, 0xb8, 0x40, 0x1a, 0xb4, 0x08, 0x5c, + 0xbb, 0xbd, 0xf4, 0x62, 0xc8, 0x12, 0xed, 0x08, 0x95, 0x45, 0x57, 0xa2, 0x9a, 0xe6, 0x25, 0x7a, + 0xe9, 0xa5, 0x87, 0xbe, 0x47, 0x0f, 0xbd, 0xf4, 0x98, 0x63, 0x1f, 0xa1, 0x48, 0x1e, 0xa0, 0xaf, + 0x50, 0x90, 0x22, 0x25, 0xcb, 0x96, 0xd3, 0x9c, 0x2c, 0xce, 0x7c, 0xfc, 0x38, 0xdf, 0xcc, 0x70, + 0x68, 0xd0, 0x27, 0x3e, 0xa1, 0x24, 0x68, 0xb9, 0xd8, 0x1e, 0x61, 0x5f, 0xfc, 0x34, 0xb9, 0x11, + 0x15, 0xa2, 0x95, 0xbe, 0x37, 0x72, 0xe8, 0x79, 0x38, 0x68, 0x5a, 0x64, 0xdc, 0xa2, 0x3e, 0xf1, + 0xee, 0x87, 0x41, 0x8b, 0x23, 0x06, 0xe1, 0xb0, 0x35, 0x22, 0x23, 0xc2, 0x17, 0xfc, 0x2b, 0xda, + 0x69, 0x14, 0x20, 0x7f, 0x16, 0xba, 0xae, 0xf1, 0x0f, 0x14, 0x3b, 0xe1, 0xc0, 0x75, 0xac, 0xa7, + 0xf8, 0x12, 0xfd, 0x06, 0xb9, 0xd7, 0xf8, 0xb2,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0x72, + 0x69, 0x74, 0x40, 0x13, 0x50, 0x74, 0x0f, 0x34, 0xd3, 0xb6, 0x7d, 0x1c, 0x04, 0x8b, 0x13, 0x2f, + 0x11, 0xd3, 0x8c, 0x6a, 0x9a, 0x71, 0x1d, 0x8a, 0x22, 0x05, 0xa7, 0x8f, 0x51, 0x15, 0x54, 0xc7, + 0x16, 0x67, 0xaa, 0x8e, 0x6d, 0x7c, 0x51, 0xa0, 0x24, 0xbd, 0xde, 0x90, 0xa0, 0xcd, 0xd8, 0x3f, + 0x75, 0x5c, 0xbc, 0x9d, 0x6d, 0x41, 0xfb, 0x50, 0x1e, 0xfa, 0x64, 0xdc, 0x97, 0x89, 0x50, 0xb3, + 0x13, 0x51, 0x62, 0x20, 0x29, 0xa5, 0x09, 0x40, 0x49, 0xbc, 0x23, 0x97, 0xbd, 0xa3, 0x48, 0x89, + 0xc4, 0x6f, 0x43, 0xd5, 0x72, 0x49, 0x80, 0xfb, 0x01, 0x7e, 0x13, 0x62, 0x26, 0x2a, 0xea, 0x82, + 0x0a, 0xb7, 0xf6, 0x84, 0xd1, 0x78, 0xaf, 0x00, 0x4a, 0x35, 0x43, 0x8f, 0x9a, 0x14, 0xa3, 0xe6, + 0x6c, 0x2f, 0xac, 0xce, 0x28, 0xe1, 0xb0, 0xa4, 0x15, 0xb6, 0xa1, 0xca, 0x15, 0xcd, 0xf6, 0x43, + 0x85, 0x59, 0x7b, 0xd2, 0x88, 0x36, 0xa1, 0x4c, 0xc9, 0x14, 0x28, 0xc7, 0x41, 0x25, 0x4a, 0x62, + 0x88, 0x81, 0xa1, 0xd6, 0x66, 0x11, 0xc6, 0xcd, 0x19, 0xfa, 0x01, 0xf1, 0xef, 0x7e, 0x81, 0xe6, + 0x75, 0xab, 0x59, 0xba, 0x3f, 0x28, 0x50, 0x4e, 0x29, 0xbe, 0x43, 0xd9, 0x74, 0x58, 0x9e, 0x21, + 0x8d, 0xd7, 0x68, 0x0b, 0xf2, 0x4c, 0xea, 0xa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31, 0x2e, 0x9f, 0xc7, + 0x33, 0x3f, 0x45, 0xf3, 0x57, 0x5a, 0x54, 0x42, 0xb6, 0x39, 0xa3, 0x36, 0x83, 0xf2, 0x10, 0x6a, + 0x2f, 0x27, 0x76, 0x62, 0xee, 0x84, 0x03, 0xd6, 0x10, 0xeb, 0x0b, 0x28, 0x59, 0x17, 0xea, 0x65, + 0xe9, 0x64, 0x8f, 0xf3, 0xf1, 0xc1, 0xd5, 0x75, 0x43, 0xf9, 0x76, 0xdd, 0x50, 0xbe, 0x5f, 0x37, + 0x94, 0x8f, 0x37, 0x0d, 0xe5, 0xeb, 0x4d, 0x43, 0xb9, 0xba, 0x69, 0x28, 0x50, 0x75, 0x48, 0x73, + 0x40, 0x87, 0x81, 0x80, 0x1f, 0x97, 0x9e, 0xf1, 0xdf, 0x0e, 0x7b, 0xdb, 0x3b, 0xca, 0x2b, 0xf1, + 0xbf, 0x60, 0x50, 0xe0, 0x8f, 0xfd, 0x83, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xee, 0x8b, 0x51, + 0x61, 0x44, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1029,10 +1030,10 @@ var _ grpc.ClientConn // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 -// ChannelsClient is the client API for Channels service. +// ChannelsServiceClient is the client API for ChannelsService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ChannelsClient interface { +type ChannelsServiceClient interface { // Creates a channel on the ledger and returns the ID of the ledger CreateChannel(ctx context.Context, in *SignedChannelCommit, opts ...grpc.CallOption) (*ChannelID, error) // Retrieves the state of a channel on the ledger. @@ -1050,79 +1051,79 @@ type ChannelsClient interface { UpdateAccountPubKey(ctx context.Context, in *SignedPublicKeyPair, opts ...grpc.CallOption) (*Null, error) } -type channelsClient struct { +type channelsServiceClient struct { cc *grpc.ClientConn } -func NewChannelsClient(cc *grpc.ClientConn) ChannelsClient { - return &channelsClient{cc} +func NewChannelsServiceClient(cc *grpc.ClientConn) ChannelsServiceClient { + return &channelsServiceClient{cc} } -func (c *channelsClient) CreateChannel(ctx context.Context, in *SignedChannelCommit, opts ...grpc.CallOption) (*ChannelID, error) { +func (c *channelsServiceClient) CreateChannel(ctx context.Context, in *SignedChannelCommit, opts ...grpc.CallOption) (*ChannelID, error) { out := new(ChannelID) - err := c.cc.Invoke(ctx, "/ledger.Channels/CreateChannel", in, out, opts...) + err := c.cc.Invoke(ctx, "/ledger.ChannelsService/CreateChannel", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *channelsClient) GetChannelInfo(ctx context.Context, in *ChannelID, opts ...grpc.CallOption) (*ChannelInfo, error) { +func (c *channelsServiceClient) GetChannelInfo(ctx context.Context, in *ChannelID, opts ...grpc.CallOption) (*ChannelInfo, error) { out := new(ChannelInfo) - err := c.cc.Invoke(ctx, "/ledger.Channels/GetChannelInfo", in, out, opts...) + err := c.cc.Invoke(ctx, "/ledger.ChannelsService/GetChannelInfo", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *channelsClient) CloseChannel(ctx context.Context, in *SignedChannelState, opts ...grpc.CallOption) (*ChannelClosed, error) { +func (c *channelsServiceClient) CloseChannel(ctx context.Context, in *SignedChannelState, opts ...grpc.CallOption) (*ChannelClosed, error) { out := new(ChannelClosed) - err := c.cc.Invoke(ctx, "/ledger.Channels/CloseChannel", in, out, opts...) + err := c.cc.Invoke(ctx, "/ledger.ChannelsService/CloseChannel", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *channelsClient) GetNextClosedChannel(ctx context.Context, in *ClosedChannelCursor, opts ...grpc.CallOption) (*ChannelInfo, error) { +func (c *channelsServiceClient) GetNextClosedChannel(ctx context.Context, in *ClosedChannelCursor, opts ...grpc.CallOption) (*ChannelInfo, error) { out := new(ChannelInfo) - err := c.cc.Invoke(ctx, "/ledger.Channels/GetNextClosedChannel", in, out, opts...) + err := c.cc.Invoke(ctx, "/ledger.ChannelsService/GetNextClosedChannel", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *channelsClient) CreateAccount(ctx context.Context, in *PublicKey, opts ...grpc.CallOption) (*CreateAccountResult, error) { +func (c *channelsServiceClient) CreateAccount(ctx context.Context, in *PublicKey, opts ...grpc.CallOption) (*CreateAccountResult, error) { out := new(CreateAccountResult) - err := c.cc.Invoke(ctx, "/ledger.Channels/CreateAccount", in, out, opts...) + err := c.cc.Invoke(ctx, "/ledger.ChannelsService/CreateAccount", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *channelsClient) SignedCreateAccount(ctx context.Context, in *SignedPublicKey, opts ...grpc.CallOption) (*SignedCreateAccountResult, error) { +func (c *channelsServiceClient) SignedCreateAccount(ctx context.Context, in *SignedPublicKey, opts ...grpc.CallOption) (*SignedCreateAccountResult, error) { out := new(SignedCreateAccountResult) - err := c.cc.Invoke(ctx, "/ledger.Channels/SignedCreateAccount", in, out, opts...) + err := c.cc.Invoke(ctx, "/ledger.ChannelsService/SignedCreateAccount", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *channelsClient) UpdateAccountPubKey(ctx context.Context, in *SignedPublicKeyPair, opts ...grpc.CallOption) (*Null, error) { +func (c *channelsServiceClient) UpdateAccountPubKey(ctx context.Context, in *SignedPublicKeyPair, opts ...grpc.CallOption) (*Null, error) { out := new(Null) - err := c.cc.Invoke(ctx, "/ledger.Channels/UpdateAccountPubKey", in, out, opts...) + err := c.cc.Invoke(ctx, "/ledger.ChannelsService/UpdateAccountPubKey", in, out, opts...) if err != nil { return nil, err } return out, nil } -// ChannelsServer is the server API for Channels service. -type ChannelsServer interface { +// ChannelsServiceServer is the server API for ChannelsService service. +type ChannelsServiceServer interface { // Creates a channel on the ledger and returns the ID of the ledger CreateChannel(context.Context, *SignedChannelCommit) (*ChannelID, error) // Retrieves the state of a channel on the ledger. @@ -1140,193 +1141,193 @@ type ChannelsServer interface { UpdateAccountPubKey(context.Context, *SignedPublicKeyPair) (*Null, error) } -// UnimplementedChannelsServer can be embedded to have forward compatible implementations. -type UnimplementedChannelsServer struct { +// UnimplementedChannelsServiceServer can be embedded to have forward compatible implementations. +type UnimplementedChannelsServiceServer struct { } -func (*UnimplementedChannelsServer) CreateChannel(ctx context.Context, req *SignedChannelCommit) (*ChannelID, error) { +func (*UnimplementedChannelsServiceServer) CreateChannel(ctx context.Context, req *SignedChannelCommit) (*ChannelID, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateChannel not implemented") } -func (*UnimplementedChannelsServer) GetChannelInfo(ctx context.Context, req *ChannelID) (*ChannelInfo, error) { +func (*UnimplementedChannelsServiceServer) GetChannelInfo(ctx context.Context, req *ChannelID) (*ChannelInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method GetChannelInfo not implemented") } -func (*UnimplementedChannelsServer) CloseChannel(ctx context.Context, req *SignedChannelState) (*ChannelClosed, error) { +func (*UnimplementedChannelsServiceServer) CloseChannel(ctx context.Context, req *SignedChannelState) (*ChannelClosed, error) { return nil, status.Errorf(codes.Unimplemented, "method CloseChannel not implemented") } -func (*UnimplementedChannelsServer) GetNextClosedChannel(ctx context.Context, req *ClosedChannelCursor) (*ChannelInfo, error) { +func (*UnimplementedChannelsServiceServer) GetNextClosedChannel(ctx context.Context, req *ClosedChannelCursor) (*ChannelInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method GetNextClosedChannel not implemented") } -func (*UnimplementedChannelsServer) CreateAccount(ctx context.Context, req *PublicKey) (*CreateAccountResult, error) { +func (*UnimplementedChannelsServiceServer) CreateAccount(ctx context.Context, req *PublicKey) (*CreateAccountResult, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateAccount not implemented") } -func (*UnimplementedChannelsServer) SignedCreateAccount(ctx context.Context, req *SignedPublicKey) (*SignedCreateAccountResult, error) { +func (*UnimplementedChannelsServiceServer) SignedCreateAccount(ctx context.Context, req *SignedPublicKey) (*SignedCreateAccountResult, error) { return nil, status.Errorf(codes.Unimplemented, "method SignedCreateAccount not implemented") } -func (*UnimplementedChannelsServer) UpdateAccountPubKey(ctx context.Context, req *SignedPublicKeyPair) (*Null, error) { +func (*UnimplementedChannelsServiceServer) UpdateAccountPubKey(ctx context.Context, req *SignedPublicKeyPair) (*Null, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateAccountPubKey not implemented") } -func RegisterChannelsServer(s *grpc.Server, srv ChannelsServer) { - s.RegisterService(&_Channels_serviceDesc, srv) +func RegisterChannelsServiceServer(s *grpc.Server, srv ChannelsServiceServer) { + s.RegisterService(&_ChannelsService_serviceDesc, srv) } -func _Channels_CreateChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ChannelsService_CreateChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SignedChannelCommit) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ChannelsServer).CreateChannel(ctx, in) + return srv.(ChannelsServiceServer).CreateChannel(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ledger.Channels/CreateChannel", + FullMethod: "/ledger.ChannelsService/CreateChannel", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ChannelsServer).CreateChannel(ctx, req.(*SignedChannelCommit)) + return srv.(ChannelsServiceServer).CreateChannel(ctx, req.(*SignedChannelCommit)) } return interceptor(ctx, in, info, handler) } -func _Channels_GetChannelInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ChannelsService_GetChannelInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ChannelID) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ChannelsServer).GetChannelInfo(ctx, in) + return srv.(ChannelsServiceServer).GetChannelInfo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ledger.Channels/GetChannelInfo", + FullMethod: "/ledger.ChannelsService/GetChannelInfo", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ChannelsServer).GetChannelInfo(ctx, req.(*ChannelID)) + return srv.(ChannelsServiceServer).GetChannelInfo(ctx, req.(*ChannelID)) } return interceptor(ctx, in, info, handler) } -func _Channels_CloseChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ChannelsService_CloseChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SignedChannelState) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ChannelsServer).CloseChannel(ctx, in) + return srv.(ChannelsServiceServer).CloseChannel(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ledger.Channels/CloseChannel", + FullMethod: "/ledger.ChannelsService/CloseChannel", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ChannelsServer).CloseChannel(ctx, req.(*SignedChannelState)) + return srv.(ChannelsServiceServer).CloseChannel(ctx, req.(*SignedChannelState)) } return interceptor(ctx, in, info, handler) } -func _Channels_GetNextClosedChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ChannelsService_GetNextClosedChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ClosedChannelCursor) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ChannelsServer).GetNextClosedChannel(ctx, in) + return srv.(ChannelsServiceServer).GetNextClosedChannel(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ledger.Channels/GetNextClosedChannel", + FullMethod: "/ledger.ChannelsService/GetNextClosedChannel", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ChannelsServer).GetNextClosedChannel(ctx, req.(*ClosedChannelCursor)) + return srv.(ChannelsServiceServer).GetNextClosedChannel(ctx, req.(*ClosedChannelCursor)) } return interceptor(ctx, in, info, handler) } -func _Channels_CreateAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ChannelsService_CreateAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(PublicKey) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ChannelsServer).CreateAccount(ctx, in) + return srv.(ChannelsServiceServer).CreateAccount(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ledger.Channels/CreateAccount", + FullMethod: "/ledger.ChannelsService/CreateAccount", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ChannelsServer).CreateAccount(ctx, req.(*PublicKey)) + return srv.(ChannelsServiceServer).CreateAccount(ctx, req.(*PublicKey)) } return interceptor(ctx, in, info, handler) } -func _Channels_SignedCreateAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ChannelsService_SignedCreateAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SignedPublicKey) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ChannelsServer).SignedCreateAccount(ctx, in) + return srv.(ChannelsServiceServer).SignedCreateAccount(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ledger.Channels/SignedCreateAccount", + FullMethod: "/ledger.ChannelsService/SignedCreateAccount", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ChannelsServer).SignedCreateAccount(ctx, req.(*SignedPublicKey)) + return srv.(ChannelsServiceServer).SignedCreateAccount(ctx, req.(*SignedPublicKey)) } return interceptor(ctx, in, info, handler) } -func _Channels_UpdateAccountPubKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ChannelsService_UpdateAccountPubKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SignedPublicKeyPair) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ChannelsServer).UpdateAccountPubKey(ctx, in) + return srv.(ChannelsServiceServer).UpdateAccountPubKey(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ledger.Channels/UpdateAccountPubKey", + FullMethod: "/ledger.ChannelsService/UpdateAccountPubKey", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ChannelsServer).UpdateAccountPubKey(ctx, req.(*SignedPublicKeyPair)) + return srv.(ChannelsServiceServer).UpdateAccountPubKey(ctx, req.(*SignedPublicKeyPair)) } return interceptor(ctx, in, info, handler) } -var _Channels_serviceDesc = grpc.ServiceDesc{ - ServiceName: "ledger.Channels", - HandlerType: (*ChannelsServer)(nil), +var _ChannelsService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ledger.ChannelsService", + HandlerType: (*ChannelsServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "CreateChannel", - Handler: _Channels_CreateChannel_Handler, + Handler: _ChannelsService_CreateChannel_Handler, }, { MethodName: "GetChannelInfo", - Handler: _Channels_GetChannelInfo_Handler, + Handler: _ChannelsService_GetChannelInfo_Handler, }, { MethodName: "CloseChannel", - Handler: _Channels_CloseChannel_Handler, + Handler: _ChannelsService_CloseChannel_Handler, }, { MethodName: "GetNextClosedChannel", - Handler: _Channels_GetNextClosedChannel_Handler, + Handler: _ChannelsService_GetNextClosedChannel_Handler, }, { MethodName: "CreateAccount", - Handler: _Channels_CreateAccount_Handler, + Handler: _ChannelsService_CreateAccount_Handler, }, { MethodName: "SignedCreateAccount", - Handler: _Channels_SignedCreateAccount_Handler, + Handler: _ChannelsService_SignedCreateAccount_Handler, }, { MethodName: "UpdateAccountPubKey", - Handler: _Channels_UpdateAccountPubKey_Handler, + Handler: _ChannelsService_UpdateAccountPubKey_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/protos/ledger/ledger.proto b/protos/ledger/ledger.proto index 3c94171..3f90f4f 100755 --- a/protos/ledger/ledger.proto +++ b/protos/ledger/ledger.proto @@ -20,7 +20,7 @@ import "github.com/tron-us/protobuf/gogoproto/gogo.proto"; // Interface exported by the server. -service Channels { +service ChannelsService { // Creates a channel on the ledger and returns the ID of the ledger rpc CreateChannel(SignedChannelCommit) returns (ChannelID); // Retrieves the state of a channel on the ledger. diff --git a/protos/node/node.pb.go b/protos/node/node.pb.go index e7479b2..c2ec03c 100644 --- a/protos/node/node.pb.go +++ b/protos/node/node.pb.go @@ -31,7 +31,7 @@ var _ = time.Kitchen const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Node struct { - tableName string `pg:"node_metrics,alias:t,discard_unknown_columns"` + TableName string `protobuf:"bytes,1,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty" pg:"table_name" pg:"node_metrics,alias:t,discard_unknown_columns"` NodeId string `protobuf:"bytes,2,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty" pg:"node_id"` BtfsVersion string `protobuf:"bytes,3,opt,name=btfs_version,json=btfsVersion,proto3" json:"btfs_version,omitempty" pg:"btfs_version"` UpTime uint64 `protobuf:"varint,4,opt,name=up_time,json=upTime,proto3" json:"up_time,omitempty" pg:"up_time"` @@ -93,9 +93,9 @@ func (m *Node) XXX_DiscardUnknown() { var xxx_messageInfo_Node proto.InternalMessageInfo -func (m *Node) GettableName() string { +func (m *Node) GetTableName() string { if m != nil { - return m.tableName + return m.TableName } return "" } @@ -582,10 +582,10 @@ func (m *Node) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.tableName) > 0 { - i -= len(m.tableName) - copy(dAtA[i:], m.tableName) - i = encodeVarintNode(dAtA, i, uint64(len(m.tableName))) + if len(m.TableName) > 0 { + i -= len(m.TableName) + copy(dAtA[i:], m.TableName) + i = encodeVarintNode(dAtA, i, uint64(len(m.TableName))) i-- dAtA[i] = 0xa } @@ -658,7 +658,7 @@ func encodeVarintNode(dAtA []byte, offset int, v uint64) int { } func NewPopulatedNode(r randyNode, easy bool) *Node { this := &Node{} - this.tableName = string(randStringNode(r)) + this.TableName = string(randStringNode(r)) this.NodeId = string(randStringNode(r)) this.BtfsVersion = string(randStringNode(r)) this.UpTime = uint64(uint64(r.Uint32())) @@ -790,7 +790,7 @@ func (m *Node) Size() (n int) { } var l int _ = l - l = len(m.tableName) + l = len(m.TableName) if l > 0 { n += 1 + l + sovNode(uint64(l)) } @@ -937,7 +937,7 @@ func (m *Node) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field tableName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TableName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -965,7 +965,7 @@ func (m *Node) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.tableName = string(dAtA[iNdEx:postIndex]) + m.TableName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { diff --git a/protos/status/status.pb.go b/protos/status/status.pb.go index 94bb30a..11fb6a0 100644 --- a/protos/status/status.pb.go +++ b/protos/status/status.pb.go @@ -102,7 +102,7 @@ func (*SignedMetrics) XXX_MessageName() string { } type NodeHealth struct { - tableName string `pg:"health_monitoring,alias:t,discard_unknown_columns"` + TableName string `protobuf:"bytes,1,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty" pg:"table_name" pg:"health_monitoring,alias:t,discard_unknown_columns"` NodeId string `protobuf:"bytes,2,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty" pg:"node_id"` BtfsVersion string `protobuf:"bytes,3,opt,name=btfs_version,json=btfsVersion,proto3" json:"btfs_version,omitempty" pg:"btfs_version"` FailurePoint string `protobuf:"bytes,4,opt,name=failure_point,json=failurePoint,proto3" json:"failure_point,omitempty" pg:"failure_point"` @@ -145,9 +145,9 @@ func (m *NodeHealth) XXX_DiscardUnknown() { var xxx_messageInfo_NodeHealth proto.InternalMessageInfo -func (m *NodeHealth) GettableName() string { +func (m *NodeHealth) GetTableName() string { if m != nil { - return m.tableName + return m.TableName } return "" } @@ -185,7 +185,7 @@ func (*NodeHealth) XXX_MessageName() string { } type NodeError struct { - tableName string `pg:"test_error,alias:t,discard_unknown_columns"` + TableName string `protobuf:"bytes,1,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty" pg:"table_name" pg:"test_error,alias:t,discard_unknown_columns"` HVal string `protobuf:"bytes,2,opt,name=h_val,json=hVal,proto3" json:"h_val,omitempty" pg:"h_val"` PeerId string `protobuf:"bytes,3,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty" pg:"peer_id"` ErrorStatus string `protobuf:"bytes,4,opt,name=error_status,json=errorStatus,proto3" json:"error_status,omitempty" pg:"error_status"` @@ -228,9 +228,9 @@ func (m *NodeError) XXX_DiscardUnknown() { var xxx_messageInfo_NodeError proto.InternalMessageInfo -func (m *NodeError) GettableName() string { +func (m *NodeError) GetTableName() string { if m != nil { - return m.tableName + return m.TableName } return "" } @@ -833,10 +833,10 @@ func (m *NodeHealth) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.tableName) > 0 { - i -= len(m.tableName) - copy(dAtA[i:], m.tableName) - i = encodeVarintStatus(dAtA, i, uint64(len(m.tableName))) + if len(m.TableName) > 0 { + i -= len(m.TableName) + copy(dAtA[i:], m.TableName) + i = encodeVarintStatus(dAtA, i, uint64(len(m.TableName))) i-- dAtA[i] = 0xa } @@ -896,10 +896,10 @@ func (m *NodeError) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.tableName) > 0 { - i -= len(m.tableName) - copy(dAtA[i:], m.tableName) - i = encodeVarintStatus(dAtA, i, uint64(len(m.tableName))) + if len(m.TableName) > 0 { + i -= len(m.TableName) + copy(dAtA[i:], m.TableName) + i = encodeVarintStatus(dAtA, i, uint64(len(m.TableName))) i-- dAtA[i] = 0xa } @@ -1028,7 +1028,7 @@ func (m *NodeHealth) Size() (n int) { } var l int _ = l - l = len(m.tableName) + l = len(m.TableName) if l > 0 { n += 1 + l + sovStatus(uint64(l)) } @@ -1058,7 +1058,7 @@ func (m *NodeError) Size() (n int) { } var l int _ = l - l = len(m.tableName) + l = len(m.TableName) if l > 0 { n += 1 + l + sovStatus(uint64(l)) } @@ -1317,7 +1317,7 @@ func (m *NodeHealth) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field tableName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TableName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1345,7 +1345,7 @@ func (m *NodeHealth) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.tableName = string(dAtA[iNdEx:postIndex]) + m.TableName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -1532,7 +1532,7 @@ func (m *NodeError) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field tableName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TableName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1560,7 +1560,7 @@ func (m *NodeError) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.tableName = string(dAtA[iNdEx:postIndex]) + m.TableName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { diff --git a/utils/grpc/client.go b/utils/grpc/client.go index 05f070a..6fc9822 100644 --- a/utils/grpc/client.go +++ b/utils/grpc/client.go @@ -14,6 +14,7 @@ import ( escrowpb "github.com/tron-us/go-btfs-common/protos/escrow" guardpb "github.com/tron-us/go-btfs-common/protos/guard" hubpb "github.com/tron-us/go-btfs-common/protos/hub" + ledgerpb "github.com/tron-us/go-btfs-common/protos/ledger" sharedpb "github.com/tron-us/go-btfs-common/protos/shared" statuspb "github.com/tron-us/go-btfs-common/protos/status" @@ -61,6 +62,8 @@ func (g *ClientBuilder) doWithContext(ctx context.Context, f interface{}) error return v(ctx, sharedpb.NewRuntimeServiceClient(conn)) case func(ctx context.Context, client grpc_health_v1.HealthClient) error: return v(ctx, grpc_health_v1.NewHealthClient(conn)) + case func(ctx context.Context, client ledgerpb.ChannelsServiceClient) error: + return v(ctx, ledgerpb.NewChannelsServiceClient(conn)) default: return fmt.Errorf("illegal function: %T", f) } diff --git a/utils/grpc/ledger.go b/utils/grpc/ledger.go new file mode 100644 index 0000000..18158d0 --- /dev/null +++ b/utils/grpc/ledger.go @@ -0,0 +1,19 @@ +package grpc + +import ( + "context" + ledgerpb "github.com/tron-us/go-btfs-common/protos/ledger" +) + +func LedgerClient(addr string) *LedgerClientBuilder { + return &LedgerClientBuilder{builder(addr)} +} + +type LedgerClientBuilder struct { + ClientBuilder +} + +func (g *LedgerClientBuilder) WithContext(ctx context.Context, f func(ctx context.Context, + client ledgerpb.ChannelsServiceClient) error) error { + return g.doWithContext(ctx, f) +} From 641605c5eb13b7febb25401d461845d10aeedf72 Mon Sep 17 00:00:00 2001 From: Robin Lai Date: Wed, 4 Dec 2019 17:41:05 -0800 Subject: [PATCH 2/5] refactoring --- ledger/ledger.go | 44 ++----- ledger/sample/demo.go | 3 +- protos/ledger/ledger.pb.go | 245 ++++++++++++++++++------------------- protos/ledger/ledger.proto | 2 +- protos/node/node.pb.go | 22 ++-- protos/status/status.pb.go | 40 +++--- utils/grpc/client.go | 4 +- utils/grpc/ledger.go | 2 +- 8 files changed, 165 insertions(+), 197 deletions(-) diff --git a/ledger/ledger.go b/ledger/ledger.go index 8023930..01063ad 100644 --- a/ledger/ledger.go +++ b/ledger/ledger.go @@ -2,46 +2,16 @@ package ledger import ( "context" - "crypto/tls" - "fmt" "time" - ledgerPb "github.com/tron-us/go-btfs-common/protos/ledger" - "github.com/tron-us/go-common/v2/log" - ic "github.com/libp2p/go-libp2p-core/crypto" + ledgerPb "github.com/tron-us/go-btfs-common/protos/ledger" "github.com/tron-us/protobuf/proto" - "go.uber.org/zap" "google.golang.org/grpc" - "google.golang.org/grpc/credentials" ) -func LedgerConnection(ledgerAddr, certFile string) (*grpc.ClientConn, error) { - var grpcOption grpc.DialOption - if certFile == "wi" { - grpcOption = grpc.WithInsecure() - } else { - credential := credentials.NewTLS(&tls.Config{}) - grpcOption = grpc.WithTransportCredentials(credential) - } - conn, err := grpc.Dial(ledgerAddr, grpcOption, grpc.WithBlock()) - if err != nil { - return nil, err - } - fmt.Println("state:", conn.GetState()) - return conn, nil -} - -func CloseConnection(conn *grpc.ClientConn) { - if conn != nil { - if err := conn.Close(); err != nil { - log.Error("Failed to close connection: ", zap.Error(err)) - } - } -} - -func NewClient(conn *grpc.ClientConn) ledgerPb.ChannelsServiceClient { - return ledgerPb.NewChannelsServiceClient(conn) +func NewClient(conn *grpc.ClientConn) ledgerPb.ChannelsClient { + return ledgerPb.NewChannelsClient(conn) } func NewAccount(pubKey ic.PubKey, amount int64) (*ledgerPb.Account, error) { @@ -89,7 +59,7 @@ func NewSignedChannelState(channelState *ledgerPb.ChannelState, fromSig []byte, } } -func ImportAccount(ctx context.Context, pubKey ic.PubKey, ledgerClient ledgerPb.ChannelsServiceClient) (*ledgerPb.Account, error) { +func ImportAccount(ctx context.Context, pubKey ic.PubKey, ledgerClient ledgerPb.ChannelsClient) (*ledgerPb.Account, error) { keyBytes, err := pubKey.Raw() if err != nil { return nil, err @@ -101,7 +71,7 @@ func ImportAccount(ctx context.Context, pubKey ic.PubKey, ledgerClient ledgerPb. return res.GetAccount(), nil } -func ImportSignedAccount(ctx context.Context, privKey ic.PrivKey, pubKey ic.PubKey, ledgerClient ledgerPb.ChannelsServiceClient) (*ledgerPb.SignedCreateAccountResult, error) { +func ImportSignedAccount(ctx context.Context, privKey ic.PrivKey, pubKey ic.PubKey, ledgerClient ledgerPb.ChannelsClient) (*ledgerPb.SignedCreateAccountResult, error) { pubKeyBytes, err := pubKey.Raw() if err != nil { return nil, err @@ -116,14 +86,14 @@ func ImportSignedAccount(ctx context.Context, privKey ic.PrivKey, pubKey ic.PubK return ledgerClient.SignedCreateAccount(ctx, signedPubkey) } -func CreateChannel(ctx context.Context, ledgerClient ledgerPb.ChannelsServiceClient, channelCommit *ledgerPb.ChannelCommit, sig []byte) (*ledgerPb.ChannelID, error) { +func CreateChannel(ctx context.Context, ledgerClient ledgerPb.ChannelsClient, channelCommit *ledgerPb.ChannelCommit, sig []byte) (*ledgerPb.ChannelID, error) { return ledgerClient.CreateChannel(ctx, &ledgerPb.SignedChannelCommit{ Channel: channelCommit, Signature: sig, }) } -func CloseChannel(ctx context.Context, ledgerClient ledgerPb.ChannelsServiceClient, signedChannelState *ledgerPb.SignedChannelState) error { +func CloseChannel(ctx context.Context, ledgerClient ledgerPb.ChannelsClient, signedChannelState *ledgerPb.SignedChannelState) error { _, err := ledgerClient.CloseChannel(ctx, signedChannelState) if err != nil { return err diff --git a/ledger/sample/demo.go b/ledger/sample/demo.go index 24f3dea..4b6691c 100644 --- a/ledger/sample/demo.go +++ b/ledger/sample/demo.go @@ -19,7 +19,7 @@ const ( func main() { err := grpc.LedgerClient("https://ledger-dev.bt.co:443").WithContext(context.Background(), - func(ctx context.Context, ledgerClient ledgerpb.ChannelsServiceClient) error { + func(ctx context.Context, ledgerClient ledgerpb.ChannelsClient) error { // create payer Account payerPrivKey, err := crypto.ToPrivKey(PayerPrivKeyString) if err != nil { @@ -87,4 +87,3 @@ func main() { log.Panic(err.Error()) } } - diff --git a/protos/ledger/ledger.pb.go b/protos/ledger/ledger.pb.go index 45e37d4..2b43cc0 100644 --- a/protos/ledger/ledger.pb.go +++ b/protos/ledger/ledger.pb.go @@ -967,59 +967,58 @@ func init() { proto.RegisterFile("protos/ledger/ledger.proto", fileDescriptor_85 func init() { golang_proto.RegisterFile("protos/ledger/ledger.proto", fileDescriptor_858b35020cfe9185) } var fileDescriptor_858b35020cfe9185 = []byte{ - // 821 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x56, 0xcd, 0x6e, 0xdb, 0x38, - 0x10, 0x86, 0x64, 0xc7, 0x8a, 0xc7, 0x3f, 0xd9, 0xa5, 0xb3, 0xbb, 0x8e, 0xb2, 0xeb, 0x4d, 0x14, - 0x04, 0x9b, 0x4d, 0x51, 0x3b, 0x48, 0x51, 0xa0, 0xb7, 0xfc, 0xb8, 0x40, 0x1a, 0xb4, 0x08, 0x5c, - 0xbb, 0xbd, 0xf4, 0x62, 0xc8, 0x12, 0xed, 0x08, 0x95, 0x45, 0x57, 0xa2, 0x9a, 0xe6, 0x25, 0x7a, - 0xe9, 0xa5, 0x87, 0xbe, 0x47, 0x0f, 0xbd, 0xf4, 0x98, 0x63, 0x1f, 0xa1, 0x48, 0x1e, 0xa0, 0xaf, - 0x50, 0x90, 0x22, 0x25, 0xcb, 0x96, 0xd3, 0x9c, 0x2c, 0xce, 0x7c, 0xfc, 0x38, 0xdf, 0xcc, 0x70, - 0x68, 0xd0, 0x27, 0x3e, 0xa1, 0x24, 0x68, 0xb9, 0xd8, 0x1e, 0x61, 0x5f, 0xfc, 0x34, 0xb9, 0x11, - 0x15, 0xa2, 0x95, 0xbe, 0x37, 0x72, 0xe8, 0x79, 0x38, 0x68, 0x5a, 0x64, 0xdc, 0xa2, 0x3e, 0xf1, - 0xee, 0x87, 0x41, 0x8b, 0x23, 0x06, 0xe1, 0xb0, 0x35, 0x22, 0x23, 0xc2, 0x17, 0xfc, 0x2b, 0xda, - 0x69, 0x14, 0x20, 0x7f, 0x16, 0x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 0xfd, 0xc6, 0x43, 0x58, - 0x13, 0x71, 0x66, 0xf0, 0xd4, 0x41, 0x1b, 0x98, 0xae, 0xe9, 0x59, 0x98, 0xf3, 0xe4, 0xba, 0x72, - 0x69, 0x74, 0x40, 0x13, 0x50, 0x74, 0x0f, 0x34, 0xd3, 0xb6, 0x7d, 0x1c, 0x04, 0x8b, 0x13, 0x2f, - 0x11, 0xd3, 0x8c, 0x6a, 0x9a, 0x71, 0x1d, 0x8a, 0x22, 0x05, 0xa7, 0x8f, 0x51, 0x15, 0x54, 0xc7, - 0x16, 0x67, 0xaa, 0x8e, 0x6d, 0x7c, 0x51, 0xa0, 0x24, 0xbd, 0xde, 0x90, 0xa0, 0xcd, 0xd8, 0x3f, - 0x75, 0x5c, 0xbc, 0x9d, 0x6d, 0x41, 0xfb, 0x50, 0x1e, 0xfa, 0x64, 0xdc, 0x97, 0x89, 0x50, 0xb3, - 0x13, 0x51, 0x62, 0x20, 0x29, 0xa5, 0x09, 0x40, 0x49, 0xbc, 0x23, 0x97, 0xbd, 0xa3, 0x48, 0x89, - 0xc4, 0x6f, 0x43, 0xd5, 0x72, 0x49, 0x80, 0xfb, 0x01, 0x7e, 0x13, 0x62, 0x26, 0x2a, 0xea, 0x82, - 0x0a, 0xb7, 0xf6, 0x84, 0xd1, 0x78, 0xaf, 0x00, 0x4a, 0x35, 0x43, 0x8f, 0x9a, 0x14, 0xa3, 0xe6, - 0x6c, 0x2f, 0xac, 0xce, 0x28, 0xe1, 0xb0, 0xa4, 0x15, 0xb6, 0xa1, 0xca, 0x15, 0xcd, 0xf6, 0x43, - 0x85, 0x59, 0x7b, 0xd2, 0x88, 0x36, 0xa1, 0x4c, 0xc9, 0x14, 0x28, 0xc7, 0x41, 0x25, 0x4a, 0x62, - 0x88, 0x81, 0xa1, 0xd6, 0x66, 0x11, 0xc6, 0xcd, 0x19, 0xfa, 0x01, 0xf1, 0xef, 0x7e, 0x81, 0xe6, - 0x75, 0xab, 0x59, 0xba, 0x3f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x5a, 0x3a, 0x11, 0x91, 0xd1, 0xe9, - 0xd9, 0xc1, 0xc4, 0x79, 0x90, 0xd7, 0x7b, 0xbe, 0x22, 0x7a, 0xc2, 0x9a, 0x31, 0x2e, 0x9f, 0xc7, - 0x33, 0x3f, 0x45, 0xf3, 0x57, 0x5a, 0x54, 0x42, 0xb6, 0x39, 0xa3, 0x36, 0x83, 0xf2, 0x10, 0x6a, - 0x2f, 0x27, 0x76, 0x62, 0xee, 0x84, 0x03, 0xd6, 0x10, 0xeb, 0x0b, 0x28, 0x59, 0x17, 0xea, 0x65, - 0xe9, 0x64, 0x8f, 0xf3, 0xf1, 0xc1, 0xd5, 0x75, 0x43, 0xf9, 0x76, 0xdd, 0x50, 0xbe, 0x5f, 0x37, - 0x94, 0x8f, 0x37, 0x0d, 0xe5, 0xeb, 0x4d, 0x43, 0xb9, 0xba, 0x69, 0x28, 0x50, 0x75, 0x48, 0x73, - 0x40, 0x87, 0x81, 0x80, 0x1f, 0x97, 0x9e, 0xf1, 0xdf, 0x0e, 0x7b, 0xdb, 0x3b, 0xca, 0x2b, 0xf1, - 0xbf, 0x60, 0x50, 0xe0, 0x8f, 0xfd, 0x83, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xee, 0x8b, 0x51, - 0x61, 0x44, 0x08, 0x00, 0x00, + // 814 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x56, 0xcd, 0x6e, 0xd3, 0x4a, + 0x14, 0x96, 0x9d, 0x34, 0x6e, 0x4e, 0x7e, 0x7a, 0xef, 0xa4, 0xf7, 0xde, 0xd4, 0xbd, 0x37, 0xb7, + 0x75, 0x55, 0x51, 0x8a, 0x48, 0xaa, 0x22, 0x24, 0x76, 0xfd, 0x09, 0x52, 0xa9, 0x40, 0x55, 0x48, + 0x60, 0xc3, 0x26, 0x72, 0xec, 0x49, 0x6a, 0xe1, 0x78, 0x82, 0x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x96, 0x33, 0x71, 0xb0, 0x47, 0x39, 0x71, 0x26, 0x38, 0xc1, 0xa0, 0xbf, 0xa1, 0x60, 0x8e, 0x49, + 0xe8, 0xd1, 0x7a, 0x6e, 0x43, 0xd9, 0xc9, 0x75, 0xc5, 0x0a, 0xad, 0xc1, 0x32, 0x67, 0xec, 0x3b, + 0x76, 0x3d, 0xcf, 0x3d, 0x1a, 0x5f, 0x9f, 0xda, 0x86, 0x0d, 0xb5, 0x48, 0x74, 0x3a, 0xc6, 0x16, + 0x68, 0x56, 0x64, 0x10, 0x51, 0xfe, 0x25, 0x0f, 0x4e, 0xe1, 0xba, 0x12, 0xf5, 0x9b, 0x24, 0x1c, + 0x42, 0xad, 0xed, 0x63, 0x93, 0xe2, 0x23, 0xcb, 0x62, 0x11, 0x75, 0x71, 0x10, 0xba, 0x14, 0xdd, + 0x07, 0xcd, 0x8c, 0x0c, 0xe2, 0x94, 0x15, 0x79, 0x8a, 0xc4, 0x49, 0xbf, 0xf1, 0x18, 0xd6, 0x44, + 0x9c, 0x19, 0x3c, 0x75, 0xd0, 0x06, 0xa6, 0x6b, 0x7a, 0x16, 0xe6, 0x3c, 0xb9, 0xae, 0x5c, 0x1a, + 0x1d, 0xd0, 0x04, 0x14, 0x3d, 0x00, 0xcd, 0xb4, 0x6d, 0x1f, 0x07, 0xc1, 0xe2, 0xc4, 0x4b, 0xc4, + 0x34, 0xa3, 0x9a, 0x66, 0x5c, 0x87, 0xa2, 0x48, 0xc1, 0xe9, 0x53, 0x54, 0x05, 0xd5, 0xb1, 0xc5, + 0x99, 0xaa, 0x63, 0x1b, 0x5f, 0x15, 0x28, 0x49, 0xaf, 0x37, 0x24, 0x68, 0x33, 0xf6, 0x4f, 0x1d, + 0x17, 0x6f, 0x67, 0x5b, 0xd0, 0x3e, 0x94, 0x87, 0x3e, 0x19, 0xf7, 0x65, 0x22, 0xd4, 0xec, 0x44, + 0x94, 0x18, 0x48, 0x4a, 0x69, 0x02, 0x50, 0x12, 0xef, 0xc8, 0x65, 0xef, 0x28, 0x52, 0x22, 0xf1, + 0xdb, 0x50, 0xb5, 0x5c, 0x12, 0xe0, 0x7e, 0x80, 0xdf, 0x85, 0x98, 0x89, 0x8a, 0xba, 0xa0, 0xc2, + 0xad, 0x3d, 0x61, 0x34, 0x3e, 0x28, 0x80, 0x52, 0xcd, 0xd0, 0xa3, 0x26, 0xc5, 0xa8, 0x39, 0xdb, + 0x0b, 0xab, 0x33, 0x4a, 0x38, 0x2c, 0x69, 0x85, 0x6d, 0xa8, 0x72, 0x45, 0xb3, 0xfd, 0x50, 0x61, + 0xd6, 0x9e, 0x34, 0xa2, 0x4d, 0x28, 0x53, 0x32, 0x05, 0xca, 0x71, 0x50, 0x89, 0x92, 0x18, 0x62, + 0x60, 0xa8, 0xb5, 0x59, 0x84, 0x71, 0x73, 0x86, 0x7e, 0x40, 0xfc, 0xbb, 0x5f, 0xa0, 0x79, 0xdd, + 0x6a, 0x96, 0xee, 0x8f, 0x0a, 0x94, 0x53, 0x8a, 0xef, 0x50, 0x36, 0x1d, 0x96, 0x67, 0x48, 0xe3, + 0x35, 0xda, 0x82, 0x3c, 0x93, 0xba, 0xa8, 0x30, 0xdc, 0x89, 0xfe, 0x07, 0x95, 0x12, 0x5e, 0x87, + 0x0c, 0x88, 0x4a, 0x89, 0x71, 0x94, 0xcc, 0x0d, 0x9e, 0x03, 0xb4, 0x07, 0x4b, 0x01, 0x0b, 0x4f, + 0x04, 0xa6, 0xcb, 0x4d, 0xf3, 0x25, 0xeb, 0x46, 0x40, 0xe3, 0x8b, 0x22, 0x6f, 0x77, 0x9c, 0x9a, + 0x8e, 0xe9, 0xf8, 0x68, 0x17, 0x34, 0xe2, 0xda, 0xfd, 0x5b, 0x47, 0x5b, 0x81, 0xb8, 0x36, 0x1b, + 0x81, 0xbb, 0xa0, 0x79, 0xf8, 0x82, 0x63, 0x17, 0x8e, 0xa0, 0x82, 0x87, 0x2f, 0xa2, 0x71, 0x59, + 0x61, 0xbc,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, 0x87, 0x60, 0x50, 0xe0, 0xaf, 0xfc, 0xa3, + 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0b, 0x41, 0x6d, 0x22, 0x3d, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1030,10 +1029,10 @@ var _ grpc.ClientConn // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 -// ChannelsServiceClient is the client API for ChannelsService service. +// ChannelsClient is the client API for Channels service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ChannelsServiceClient interface { +type ChannelsClient interface { // Creates a channel on the ledger and returns the ID of the ledger CreateChannel(ctx context.Context, in *SignedChannelCommit, opts ...grpc.CallOption) (*ChannelID, error) // Retrieves the state of a channel on the ledger. @@ -1051,79 +1050,79 @@ type ChannelsServiceClient interface { UpdateAccountPubKey(ctx context.Context, in *SignedPublicKeyPair, opts ...grpc.CallOption) (*Null, error) } -type channelsServiceClient struct { +type channelsClient struct { cc *grpc.ClientConn } -func NewChannelsServiceClient(cc *grpc.ClientConn) ChannelsServiceClient { - return &channelsServiceClient{cc} +func NewChannelsClient(cc *grpc.ClientConn) ChannelsClient { + return &channelsClient{cc} } -func (c *channelsServiceClient) CreateChannel(ctx context.Context, in *SignedChannelCommit, opts ...grpc.CallOption) (*ChannelID, error) { +func (c *channelsClient) CreateChannel(ctx context.Context, in *SignedChannelCommit, opts ...grpc.CallOption) (*ChannelID, error) { out := new(ChannelID) - err := c.cc.Invoke(ctx, "/ledger.ChannelsService/CreateChannel", in, out, opts...) + err := c.cc.Invoke(ctx, "/ledger.Channels/CreateChannel", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *channelsServiceClient) GetChannelInfo(ctx context.Context, in *ChannelID, opts ...grpc.CallOption) (*ChannelInfo, error) { +func (c *channelsClient) GetChannelInfo(ctx context.Context, in *ChannelID, opts ...grpc.CallOption) (*ChannelInfo, error) { out := new(ChannelInfo) - err := c.cc.Invoke(ctx, "/ledger.ChannelsService/GetChannelInfo", in, out, opts...) + err := c.cc.Invoke(ctx, "/ledger.Channels/GetChannelInfo", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *channelsServiceClient) CloseChannel(ctx context.Context, in *SignedChannelState, opts ...grpc.CallOption) (*ChannelClosed, error) { +func (c *channelsClient) CloseChannel(ctx context.Context, in *SignedChannelState, opts ...grpc.CallOption) (*ChannelClosed, error) { out := new(ChannelClosed) - err := c.cc.Invoke(ctx, "/ledger.ChannelsService/CloseChannel", in, out, opts...) + err := c.cc.Invoke(ctx, "/ledger.Channels/CloseChannel", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *channelsServiceClient) GetNextClosedChannel(ctx context.Context, in *ClosedChannelCursor, opts ...grpc.CallOption) (*ChannelInfo, error) { +func (c *channelsClient) GetNextClosedChannel(ctx context.Context, in *ClosedChannelCursor, opts ...grpc.CallOption) (*ChannelInfo, error) { out := new(ChannelInfo) - err := c.cc.Invoke(ctx, "/ledger.ChannelsService/GetNextClosedChannel", in, out, opts...) + err := c.cc.Invoke(ctx, "/ledger.Channels/GetNextClosedChannel", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *channelsServiceClient) CreateAccount(ctx context.Context, in *PublicKey, opts ...grpc.CallOption) (*CreateAccountResult, error) { +func (c *channelsClient) CreateAccount(ctx context.Context, in *PublicKey, opts ...grpc.CallOption) (*CreateAccountResult, error) { out := new(CreateAccountResult) - err := c.cc.Invoke(ctx, "/ledger.ChannelsService/CreateAccount", in, out, opts...) + err := c.cc.Invoke(ctx, "/ledger.Channels/CreateAccount", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *channelsServiceClient) SignedCreateAccount(ctx context.Context, in *SignedPublicKey, opts ...grpc.CallOption) (*SignedCreateAccountResult, error) { +func (c *channelsClient) SignedCreateAccount(ctx context.Context, in *SignedPublicKey, opts ...grpc.CallOption) (*SignedCreateAccountResult, error) { out := new(SignedCreateAccountResult) - err := c.cc.Invoke(ctx, "/ledger.ChannelsService/SignedCreateAccount", in, out, opts...) + err := c.cc.Invoke(ctx, "/ledger.Channels/SignedCreateAccount", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *channelsServiceClient) UpdateAccountPubKey(ctx context.Context, in *SignedPublicKeyPair, opts ...grpc.CallOption) (*Null, error) { +func (c *channelsClient) UpdateAccountPubKey(ctx context.Context, in *SignedPublicKeyPair, opts ...grpc.CallOption) (*Null, error) { out := new(Null) - err := c.cc.Invoke(ctx, "/ledger.ChannelsService/UpdateAccountPubKey", in, out, opts...) + err := c.cc.Invoke(ctx, "/ledger.Channels/UpdateAccountPubKey", in, out, opts...) if err != nil { return nil, err } return out, nil } -// ChannelsServiceServer is the server API for ChannelsService service. -type ChannelsServiceServer interface { +// ChannelsServer is the server API for Channels service. +type ChannelsServer interface { // Creates a channel on the ledger and returns the ID of the ledger CreateChannel(context.Context, *SignedChannelCommit) (*ChannelID, error) // Retrieves the state of a channel on the ledger. @@ -1141,193 +1140,193 @@ type ChannelsServiceServer interface { UpdateAccountPubKey(context.Context, *SignedPublicKeyPair) (*Null, error) } -// UnimplementedChannelsServiceServer can be embedded to have forward compatible implementations. -type UnimplementedChannelsServiceServer struct { +// UnimplementedChannelsServer can be embedded to have forward compatible implementations. +type UnimplementedChannelsServer struct { } -func (*UnimplementedChannelsServiceServer) CreateChannel(ctx context.Context, req *SignedChannelCommit) (*ChannelID, error) { +func (*UnimplementedChannelsServer) CreateChannel(ctx context.Context, req *SignedChannelCommit) (*ChannelID, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateChannel not implemented") } -func (*UnimplementedChannelsServiceServer) GetChannelInfo(ctx context.Context, req *ChannelID) (*ChannelInfo, error) { +func (*UnimplementedChannelsServer) GetChannelInfo(ctx context.Context, req *ChannelID) (*ChannelInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method GetChannelInfo not implemented") } -func (*UnimplementedChannelsServiceServer) CloseChannel(ctx context.Context, req *SignedChannelState) (*ChannelClosed, error) { +func (*UnimplementedChannelsServer) CloseChannel(ctx context.Context, req *SignedChannelState) (*ChannelClosed, error) { return nil, status.Errorf(codes.Unimplemented, "method CloseChannel not implemented") } -func (*UnimplementedChannelsServiceServer) GetNextClosedChannel(ctx context.Context, req *ClosedChannelCursor) (*ChannelInfo, error) { +func (*UnimplementedChannelsServer) GetNextClosedChannel(ctx context.Context, req *ClosedChannelCursor) (*ChannelInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method GetNextClosedChannel not implemented") } -func (*UnimplementedChannelsServiceServer) CreateAccount(ctx context.Context, req *PublicKey) (*CreateAccountResult, error) { +func (*UnimplementedChannelsServer) CreateAccount(ctx context.Context, req *PublicKey) (*CreateAccountResult, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateAccount not implemented") } -func (*UnimplementedChannelsServiceServer) SignedCreateAccount(ctx context.Context, req *SignedPublicKey) (*SignedCreateAccountResult, error) { +func (*UnimplementedChannelsServer) SignedCreateAccount(ctx context.Context, req *SignedPublicKey) (*SignedCreateAccountResult, error) { return nil, status.Errorf(codes.Unimplemented, "method SignedCreateAccount not implemented") } -func (*UnimplementedChannelsServiceServer) UpdateAccountPubKey(ctx context.Context, req *SignedPublicKeyPair) (*Null, error) { +func (*UnimplementedChannelsServer) UpdateAccountPubKey(ctx context.Context, req *SignedPublicKeyPair) (*Null, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateAccountPubKey not implemented") } -func RegisterChannelsServiceServer(s *grpc.Server, srv ChannelsServiceServer) { - s.RegisterService(&_ChannelsService_serviceDesc, srv) +func RegisterChannelsServer(s *grpc.Server, srv ChannelsServer) { + s.RegisterService(&_Channels_serviceDesc, srv) } -func _ChannelsService_CreateChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Channels_CreateChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SignedChannelCommit) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ChannelsServiceServer).CreateChannel(ctx, in) + return srv.(ChannelsServer).CreateChannel(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ledger.ChannelsService/CreateChannel", + FullMethod: "/ledger.Channels/CreateChannel", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ChannelsServiceServer).CreateChannel(ctx, req.(*SignedChannelCommit)) + return srv.(ChannelsServer).CreateChannel(ctx, req.(*SignedChannelCommit)) } return interceptor(ctx, in, info, handler) } -func _ChannelsService_GetChannelInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Channels_GetChannelInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ChannelID) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ChannelsServiceServer).GetChannelInfo(ctx, in) + return srv.(ChannelsServer).GetChannelInfo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ledger.ChannelsService/GetChannelInfo", + FullMethod: "/ledger.Channels/GetChannelInfo", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ChannelsServiceServer).GetChannelInfo(ctx, req.(*ChannelID)) + return srv.(ChannelsServer).GetChannelInfo(ctx, req.(*ChannelID)) } return interceptor(ctx, in, info, handler) } -func _ChannelsService_CloseChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Channels_CloseChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SignedChannelState) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ChannelsServiceServer).CloseChannel(ctx, in) + return srv.(ChannelsServer).CloseChannel(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ledger.ChannelsService/CloseChannel", + FullMethod: "/ledger.Channels/CloseChannel", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ChannelsServiceServer).CloseChannel(ctx, req.(*SignedChannelState)) + return srv.(ChannelsServer).CloseChannel(ctx, req.(*SignedChannelState)) } return interceptor(ctx, in, info, handler) } -func _ChannelsService_GetNextClosedChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Channels_GetNextClosedChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ClosedChannelCursor) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ChannelsServiceServer).GetNextClosedChannel(ctx, in) + return srv.(ChannelsServer).GetNextClosedChannel(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ledger.ChannelsService/GetNextClosedChannel", + FullMethod: "/ledger.Channels/GetNextClosedChannel", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ChannelsServiceServer).GetNextClosedChannel(ctx, req.(*ClosedChannelCursor)) + return srv.(ChannelsServer).GetNextClosedChannel(ctx, req.(*ClosedChannelCursor)) } return interceptor(ctx, in, info, handler) } -func _ChannelsService_CreateAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Channels_CreateAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(PublicKey) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ChannelsServiceServer).CreateAccount(ctx, in) + return srv.(ChannelsServer).CreateAccount(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ledger.ChannelsService/CreateAccount", + FullMethod: "/ledger.Channels/CreateAccount", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ChannelsServiceServer).CreateAccount(ctx, req.(*PublicKey)) + return srv.(ChannelsServer).CreateAccount(ctx, req.(*PublicKey)) } return interceptor(ctx, in, info, handler) } -func _ChannelsService_SignedCreateAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Channels_SignedCreateAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SignedPublicKey) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ChannelsServiceServer).SignedCreateAccount(ctx, in) + return srv.(ChannelsServer).SignedCreateAccount(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ledger.ChannelsService/SignedCreateAccount", + FullMethod: "/ledger.Channels/SignedCreateAccount", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ChannelsServiceServer).SignedCreateAccount(ctx, req.(*SignedPublicKey)) + return srv.(ChannelsServer).SignedCreateAccount(ctx, req.(*SignedPublicKey)) } return interceptor(ctx, in, info, handler) } -func _ChannelsService_UpdateAccountPubKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Channels_UpdateAccountPubKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SignedPublicKeyPair) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ChannelsServiceServer).UpdateAccountPubKey(ctx, in) + return srv.(ChannelsServer).UpdateAccountPubKey(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ledger.ChannelsService/UpdateAccountPubKey", + FullMethod: "/ledger.Channels/UpdateAccountPubKey", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ChannelsServiceServer).UpdateAccountPubKey(ctx, req.(*SignedPublicKeyPair)) + return srv.(ChannelsServer).UpdateAccountPubKey(ctx, req.(*SignedPublicKeyPair)) } return interceptor(ctx, in, info, handler) } -var _ChannelsService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "ledger.ChannelsService", - HandlerType: (*ChannelsServiceServer)(nil), +var _Channels_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ledger.Channels", + HandlerType: (*ChannelsServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "CreateChannel", - Handler: _ChannelsService_CreateChannel_Handler, + Handler: _Channels_CreateChannel_Handler, }, { MethodName: "GetChannelInfo", - Handler: _ChannelsService_GetChannelInfo_Handler, + Handler: _Channels_GetChannelInfo_Handler, }, { MethodName: "CloseChannel", - Handler: _ChannelsService_CloseChannel_Handler, + Handler: _Channels_CloseChannel_Handler, }, { MethodName: "GetNextClosedChannel", - Handler: _ChannelsService_GetNextClosedChannel_Handler, + Handler: _Channels_GetNextClosedChannel_Handler, }, { MethodName: "CreateAccount", - Handler: _ChannelsService_CreateAccount_Handler, + Handler: _Channels_CreateAccount_Handler, }, { MethodName: "SignedCreateAccount", - Handler: _ChannelsService_SignedCreateAccount_Handler, + Handler: _Channels_SignedCreateAccount_Handler, }, { MethodName: "UpdateAccountPubKey", - Handler: _ChannelsService_UpdateAccountPubKey_Handler, + Handler: _Channels_UpdateAccountPubKey_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/protos/ledger/ledger.proto b/protos/ledger/ledger.proto index 3f90f4f..3c94171 100755 --- a/protos/ledger/ledger.proto +++ b/protos/ledger/ledger.proto @@ -20,7 +20,7 @@ import "github.com/tron-us/protobuf/gogoproto/gogo.proto"; // Interface exported by the server. -service ChannelsService { +service Channels { // Creates a channel on the ledger and returns the ID of the ledger rpc CreateChannel(SignedChannelCommit) returns (ChannelID); // Retrieves the state of a channel on the ledger. diff --git a/protos/node/node.pb.go b/protos/node/node.pb.go index c2ec03c..e7479b2 100644 --- a/protos/node/node.pb.go +++ b/protos/node/node.pb.go @@ -31,7 +31,7 @@ var _ = time.Kitchen const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Node struct { - TableName string `protobuf:"bytes,1,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty" pg:"table_name" pg:"node_metrics,alias:t,discard_unknown_columns"` + tableName string `pg:"node_metrics,alias:t,discard_unknown_columns"` NodeId string `protobuf:"bytes,2,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty" pg:"node_id"` BtfsVersion string `protobuf:"bytes,3,opt,name=btfs_version,json=btfsVersion,proto3" json:"btfs_version,omitempty" pg:"btfs_version"` UpTime uint64 `protobuf:"varint,4,opt,name=up_time,json=upTime,proto3" json:"up_time,omitempty" pg:"up_time"` @@ -93,9 +93,9 @@ func (m *Node) XXX_DiscardUnknown() { var xxx_messageInfo_Node proto.InternalMessageInfo -func (m *Node) GetTableName() string { +func (m *Node) GettableName() string { if m != nil { - return m.TableName + return m.tableName } return "" } @@ -582,10 +582,10 @@ func (m *Node) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.TableName) > 0 { - i -= len(m.TableName) - copy(dAtA[i:], m.TableName) - i = encodeVarintNode(dAtA, i, uint64(len(m.TableName))) + if len(m.tableName) > 0 { + i -= len(m.tableName) + copy(dAtA[i:], m.tableName) + i = encodeVarintNode(dAtA, i, uint64(len(m.tableName))) i-- dAtA[i] = 0xa } @@ -658,7 +658,7 @@ func encodeVarintNode(dAtA []byte, offset int, v uint64) int { } func NewPopulatedNode(r randyNode, easy bool) *Node { this := &Node{} - this.TableName = string(randStringNode(r)) + this.tableName = string(randStringNode(r)) this.NodeId = string(randStringNode(r)) this.BtfsVersion = string(randStringNode(r)) this.UpTime = uint64(uint64(r.Uint32())) @@ -790,7 +790,7 @@ func (m *Node) Size() (n int) { } var l int _ = l - l = len(m.TableName) + l = len(m.tableName) if l > 0 { n += 1 + l + sovNode(uint64(l)) } @@ -937,7 +937,7 @@ func (m *Node) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TableName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field tableName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -965,7 +965,7 @@ func (m *Node) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TableName = string(dAtA[iNdEx:postIndex]) + m.tableName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { diff --git a/protos/status/status.pb.go b/protos/status/status.pb.go index 11fb6a0..94bb30a 100644 --- a/protos/status/status.pb.go +++ b/protos/status/status.pb.go @@ -102,7 +102,7 @@ func (*SignedMetrics) XXX_MessageName() string { } type NodeHealth struct { - TableName string `protobuf:"bytes,1,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty" pg:"table_name" pg:"health_monitoring,alias:t,discard_unknown_columns"` + tableName string `pg:"health_monitoring,alias:t,discard_unknown_columns"` NodeId string `protobuf:"bytes,2,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty" pg:"node_id"` BtfsVersion string `protobuf:"bytes,3,opt,name=btfs_version,json=btfsVersion,proto3" json:"btfs_version,omitempty" pg:"btfs_version"` FailurePoint string `protobuf:"bytes,4,opt,name=failure_point,json=failurePoint,proto3" json:"failure_point,omitempty" pg:"failure_point"` @@ -145,9 +145,9 @@ func (m *NodeHealth) XXX_DiscardUnknown() { var xxx_messageInfo_NodeHealth proto.InternalMessageInfo -func (m *NodeHealth) GetTableName() string { +func (m *NodeHealth) GettableName() string { if m != nil { - return m.TableName + return m.tableName } return "" } @@ -185,7 +185,7 @@ func (*NodeHealth) XXX_MessageName() string { } type NodeError struct { - TableName string `protobuf:"bytes,1,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty" pg:"table_name" pg:"test_error,alias:t,discard_unknown_columns"` + tableName string `pg:"test_error,alias:t,discard_unknown_columns"` HVal string `protobuf:"bytes,2,opt,name=h_val,json=hVal,proto3" json:"h_val,omitempty" pg:"h_val"` PeerId string `protobuf:"bytes,3,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty" pg:"peer_id"` ErrorStatus string `protobuf:"bytes,4,opt,name=error_status,json=errorStatus,proto3" json:"error_status,omitempty" pg:"error_status"` @@ -228,9 +228,9 @@ func (m *NodeError) XXX_DiscardUnknown() { var xxx_messageInfo_NodeError proto.InternalMessageInfo -func (m *NodeError) GetTableName() string { +func (m *NodeError) GettableName() string { if m != nil { - return m.TableName + return m.tableName } return "" } @@ -833,10 +833,10 @@ func (m *NodeHealth) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.TableName) > 0 { - i -= len(m.TableName) - copy(dAtA[i:], m.TableName) - i = encodeVarintStatus(dAtA, i, uint64(len(m.TableName))) + if len(m.tableName) > 0 { + i -= len(m.tableName) + copy(dAtA[i:], m.tableName) + i = encodeVarintStatus(dAtA, i, uint64(len(m.tableName))) i-- dAtA[i] = 0xa } @@ -896,10 +896,10 @@ func (m *NodeError) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.TableName) > 0 { - i -= len(m.TableName) - copy(dAtA[i:], m.TableName) - i = encodeVarintStatus(dAtA, i, uint64(len(m.TableName))) + if len(m.tableName) > 0 { + i -= len(m.tableName) + copy(dAtA[i:], m.tableName) + i = encodeVarintStatus(dAtA, i, uint64(len(m.tableName))) i-- dAtA[i] = 0xa } @@ -1028,7 +1028,7 @@ func (m *NodeHealth) Size() (n int) { } var l int _ = l - l = len(m.TableName) + l = len(m.tableName) if l > 0 { n += 1 + l + sovStatus(uint64(l)) } @@ -1058,7 +1058,7 @@ func (m *NodeError) Size() (n int) { } var l int _ = l - l = len(m.TableName) + l = len(m.tableName) if l > 0 { n += 1 + l + sovStatus(uint64(l)) } @@ -1317,7 +1317,7 @@ func (m *NodeHealth) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TableName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field tableName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1345,7 +1345,7 @@ func (m *NodeHealth) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TableName = string(dAtA[iNdEx:postIndex]) + m.tableName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -1532,7 +1532,7 @@ func (m *NodeError) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TableName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field tableName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1560,7 +1560,7 @@ func (m *NodeError) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TableName = string(dAtA[iNdEx:postIndex]) + m.tableName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { diff --git a/utils/grpc/client.go b/utils/grpc/client.go index 6fc9822..b258aff 100644 --- a/utils/grpc/client.go +++ b/utils/grpc/client.go @@ -62,8 +62,8 @@ func (g *ClientBuilder) doWithContext(ctx context.Context, f interface{}) error return v(ctx, sharedpb.NewRuntimeServiceClient(conn)) case func(ctx context.Context, client grpc_health_v1.HealthClient) error: return v(ctx, grpc_health_v1.NewHealthClient(conn)) - case func(ctx context.Context, client ledgerpb.ChannelsServiceClient) error: - return v(ctx, ledgerpb.NewChannelsServiceClient(conn)) + case func(ctx context.Context, client ledgerpb.ChannelsClient) error: + return v(ctx, ledgerpb.NewChannelsClient(conn)) default: return fmt.Errorf("illegal function: %T", f) } diff --git a/utils/grpc/ledger.go b/utils/grpc/ledger.go index 18158d0..44e0f58 100644 --- a/utils/grpc/ledger.go +++ b/utils/grpc/ledger.go @@ -14,6 +14,6 @@ type LedgerClientBuilder struct { } func (g *LedgerClientBuilder) WithContext(ctx context.Context, f func(ctx context.Context, - client ledgerpb.ChannelsServiceClient) error) error { + client ledgerpb.ChannelsClient) error) error { return g.doWithContext(ctx, f) } From a36707c3bcf2f2de4ba17ce719557f866e4e45f6 Mon Sep 17 00:00:00 2001 From: Robin Lai Date: Thu, 5 Dec 2019 12:18:41 -0800 Subject: [PATCH 3/5] rename import alias --- ledger/ledger.go | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/ledger/ledger.go b/ledger/ledger.go index 01063ad..548907c 100644 --- a/ledger/ledger.go +++ b/ledger/ledger.go @@ -5,27 +5,27 @@ import ( "time" ic "github.com/libp2p/go-libp2p-core/crypto" - ledgerPb "github.com/tron-us/go-btfs-common/protos/ledger" + ledgerpb "github.com/tron-us/go-btfs-common/protos/ledger" "github.com/tron-us/protobuf/proto" "google.golang.org/grpc" ) -func NewClient(conn *grpc.ClientConn) ledgerPb.ChannelsClient { - return ledgerPb.NewChannelsClient(conn) +func NewClient(conn *grpc.ClientConn) ledgerpb.ChannelsClient { + return ledgerpb.NewChannelsClient(conn) } -func NewAccount(pubKey ic.PubKey, amount int64) (*ledgerPb.Account, error) { +func NewAccount(pubKey ic.PubKey, amount int64) (*ledgerpb.Account, error) { addr, err := pubKey.Raw() if err != nil { return nil, err } - return &ledgerPb.Account{ - Address: &ledgerPb.PublicKey{Key: addr}, + return &ledgerpb.Account{ + Address: &ledgerpb.PublicKey{Key: addr}, Balance: amount, }, nil } -func NewChannelCommit(fromKey ic.PubKey, toKey ic.PubKey, amount int64) (*ledgerPb.ChannelCommit, error) { +func NewChannelCommit(fromKey ic.PubKey, toKey ic.PubKey, amount int64) (*ledgerpb.ChannelCommit, error) { fromAddr, err := fromKey.Raw() if err != nil { return nil, err @@ -34,16 +34,16 @@ func NewChannelCommit(fromKey ic.PubKey, toKey ic.PubKey, amount int64) (*ledger if err != nil { return nil, err } - return &ledgerPb.ChannelCommit{ - Payer: &ledgerPb.PublicKey{Key: fromAddr}, - Recipient: &ledgerPb.PublicKey{Key: toAddr}, + return &ledgerpb.ChannelCommit{ + Payer: &ledgerpb.PublicKey{Key: fromAddr}, + Recipient: &ledgerpb.PublicKey{Key: toAddr}, Amount: amount, PayerId: time.Now().UnixNano(), }, err } -func NewChannelState(id *ledgerPb.ChannelID, sequence int64, fromAccount *ledgerPb.Account, toAccount *ledgerPb.Account) *ledgerPb.ChannelState { - return &ledgerPb.ChannelState{ +func NewChannelState(id *ledgerpb.ChannelID, sequence int64, fromAccount *ledgerpb.Account, toAccount *ledgerpb.Account) *ledgerPb.ChannelState { + return &ledgerpb.ChannelState{ Id: id, Sequence: sequence, From: fromAccount, @@ -51,49 +51,49 @@ func NewChannelState(id *ledgerPb.ChannelID, sequence int64, fromAccount *ledger } } -func NewSignedChannelState(channelState *ledgerPb.ChannelState, fromSig []byte, toSig []byte) *ledgerPb.SignedChannelState { - return &ledgerPb.SignedChannelState{ +func NewSignedChannelState(channelState *ledgerpb.ChannelState, fromSig []byte, toSig []byte) *ledgerpb.SignedChannelState { + return &ledgerpb.SignedChannelState{ Channel: channelState, FromSignature: fromSig, ToSignature: toSig, } } -func ImportAccount(ctx context.Context, pubKey ic.PubKey, ledgerClient ledgerPb.ChannelsClient) (*ledgerPb.Account, error) { +func ImportAccount(ctx context.Context, pubKey ic.PubKey, ledgerClient ledgerpb.ChannelsClient) (*ledgerpb.Account, error) { keyBytes, err := pubKey.Raw() if err != nil { return nil, err } - res, err := ledgerClient.CreateAccount(ctx, &ledgerPb.PublicKey{Key: keyBytes}) + res, err := ledgerClient.CreateAccount(ctx, &ledgerpb.PublicKey{Key: keyBytes}) if err != nil { return nil, err } return res.GetAccount(), nil } -func ImportSignedAccount(ctx context.Context, privKey ic.PrivKey, pubKey ic.PubKey, ledgerClient ledgerPb.ChannelsClient) (*ledgerPb.SignedCreateAccountResult, error) { +func ImportSignedAccount(ctx context.Context, privKey ic.PrivKey, pubKey ic.PubKey, ledgerClient ledgerpb.ChannelsClient) (*ledgerPb.SignedCreateAccountResult, error) { pubKeyBytes, err := pubKey.Raw() if err != nil { return nil, err } - singedPubKey := &ledgerPb.PublicKey{Key: pubKeyBytes} + singedPubKey := &ledgerpb.PublicKey{Key: pubKeyBytes} sigBytes, err := proto.Marshal(singedPubKey) signature, err := privKey.Sign(sigBytes) if err != nil { return nil, err } - signedPubkey := &ledgerPb.SignedPublicKey{Key: singedPubKey, Signature: signature} + signedPubkey := &ledgerpb.SignedPublicKey{Key: singedPubKey, Signature: signature} return ledgerClient.SignedCreateAccount(ctx, signedPubkey) } -func CreateChannel(ctx context.Context, ledgerClient ledgerPb.ChannelsClient, channelCommit *ledgerPb.ChannelCommit, sig []byte) (*ledgerPb.ChannelID, error) { - return ledgerClient.CreateChannel(ctx, &ledgerPb.SignedChannelCommit{ +func CreateChannel(ctx context.Context, ledgerClient ledgerpb.ChannelsClient, channelCommit *ledgerpb.ChannelCommit, sig []byte) (*ledgerpb.ChannelID, error) { + return ledgerClient.CreateChannel(ctx, &ledgerpb.SignedChannelCommit{ Channel: channelCommit, Signature: sig, }) } -func CloseChannel(ctx context.Context, ledgerClient ledgerPb.ChannelsClient, signedChannelState *ledgerPb.SignedChannelState) error { +func CloseChannel(ctx context.Context, ledgerClient ledgerpb.ChannelsClient, signedChannelState *ledgerpb.SignedChannelState) error { _, err := ledgerClient.CloseChannel(ctx, signedChannelState) if err != nil { return err From 19d14bd88ee456affb63334c5e3430f59d44306b Mon Sep 17 00:00:00 2001 From: Robin Lai Date: Thu, 5 Dec 2019 12:58:33 -0800 Subject: [PATCH 4/5] fix typo --- ledger/ledger.go | 4 ++-- protos/node/node.pb.go | 22 ++++++++++----------- protos/status/status.pb.go | 40 +++++++++++++++++++------------------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/ledger/ledger.go b/ledger/ledger.go index 548907c..4decf8c 100644 --- a/ledger/ledger.go +++ b/ledger/ledger.go @@ -42,7 +42,7 @@ func NewChannelCommit(fromKey ic.PubKey, toKey ic.PubKey, amount int64) (*ledger }, err } -func NewChannelState(id *ledgerpb.ChannelID, sequence int64, fromAccount *ledgerpb.Account, toAccount *ledgerpb.Account) *ledgerPb.ChannelState { +func NewChannelState(id *ledgerpb.ChannelID, sequence int64, fromAccount *ledgerpb.Account, toAccount *ledgerpb.Account) *ledgerpb.ChannelState { return &ledgerpb.ChannelState{ Id: id, Sequence: sequence, @@ -71,7 +71,7 @@ func ImportAccount(ctx context.Context, pubKey ic.PubKey, ledgerClient ledgerpb. return res.GetAccount(), nil } -func ImportSignedAccount(ctx context.Context, privKey ic.PrivKey, pubKey ic.PubKey, ledgerClient ledgerpb.ChannelsClient) (*ledgerPb.SignedCreateAccountResult, error) { +func ImportSignedAccount(ctx context.Context, privKey ic.PrivKey, pubKey ic.PubKey, ledgerClient ledgerpb.ChannelsClient) (*ledgerpb.SignedCreateAccountResult, error) { pubKeyBytes, err := pubKey.Raw() if err != nil { return nil, err diff --git a/protos/node/node.pb.go b/protos/node/node.pb.go index e7479b2..c2ec03c 100644 --- a/protos/node/node.pb.go +++ b/protos/node/node.pb.go @@ -31,7 +31,7 @@ var _ = time.Kitchen const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Node struct { - tableName string `pg:"node_metrics,alias:t,discard_unknown_columns"` + TableName string `protobuf:"bytes,1,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty" pg:"table_name" pg:"node_metrics,alias:t,discard_unknown_columns"` NodeId string `protobuf:"bytes,2,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty" pg:"node_id"` BtfsVersion string `protobuf:"bytes,3,opt,name=btfs_version,json=btfsVersion,proto3" json:"btfs_version,omitempty" pg:"btfs_version"` UpTime uint64 `protobuf:"varint,4,opt,name=up_time,json=upTime,proto3" json:"up_time,omitempty" pg:"up_time"` @@ -93,9 +93,9 @@ func (m *Node) XXX_DiscardUnknown() { var xxx_messageInfo_Node proto.InternalMessageInfo -func (m *Node) GettableName() string { +func (m *Node) GetTableName() string { if m != nil { - return m.tableName + return m.TableName } return "" } @@ -582,10 +582,10 @@ func (m *Node) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.tableName) > 0 { - i -= len(m.tableName) - copy(dAtA[i:], m.tableName) - i = encodeVarintNode(dAtA, i, uint64(len(m.tableName))) + if len(m.TableName) > 0 { + i -= len(m.TableName) + copy(dAtA[i:], m.TableName) + i = encodeVarintNode(dAtA, i, uint64(len(m.TableName))) i-- dAtA[i] = 0xa } @@ -658,7 +658,7 @@ func encodeVarintNode(dAtA []byte, offset int, v uint64) int { } func NewPopulatedNode(r randyNode, easy bool) *Node { this := &Node{} - this.tableName = string(randStringNode(r)) + this.TableName = string(randStringNode(r)) this.NodeId = string(randStringNode(r)) this.BtfsVersion = string(randStringNode(r)) this.UpTime = uint64(uint64(r.Uint32())) @@ -790,7 +790,7 @@ func (m *Node) Size() (n int) { } var l int _ = l - l = len(m.tableName) + l = len(m.TableName) if l > 0 { n += 1 + l + sovNode(uint64(l)) } @@ -937,7 +937,7 @@ func (m *Node) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field tableName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TableName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -965,7 +965,7 @@ func (m *Node) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.tableName = string(dAtA[iNdEx:postIndex]) + m.TableName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { diff --git a/protos/status/status.pb.go b/protos/status/status.pb.go index 94bb30a..11fb6a0 100644 --- a/protos/status/status.pb.go +++ b/protos/status/status.pb.go @@ -102,7 +102,7 @@ func (*SignedMetrics) XXX_MessageName() string { } type NodeHealth struct { - tableName string `pg:"health_monitoring,alias:t,discard_unknown_columns"` + TableName string `protobuf:"bytes,1,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty" pg:"table_name" pg:"health_monitoring,alias:t,discard_unknown_columns"` NodeId string `protobuf:"bytes,2,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty" pg:"node_id"` BtfsVersion string `protobuf:"bytes,3,opt,name=btfs_version,json=btfsVersion,proto3" json:"btfs_version,omitempty" pg:"btfs_version"` FailurePoint string `protobuf:"bytes,4,opt,name=failure_point,json=failurePoint,proto3" json:"failure_point,omitempty" pg:"failure_point"` @@ -145,9 +145,9 @@ func (m *NodeHealth) XXX_DiscardUnknown() { var xxx_messageInfo_NodeHealth proto.InternalMessageInfo -func (m *NodeHealth) GettableName() string { +func (m *NodeHealth) GetTableName() string { if m != nil { - return m.tableName + return m.TableName } return "" } @@ -185,7 +185,7 @@ func (*NodeHealth) XXX_MessageName() string { } type NodeError struct { - tableName string `pg:"test_error,alias:t,discard_unknown_columns"` + TableName string `protobuf:"bytes,1,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty" pg:"table_name" pg:"test_error,alias:t,discard_unknown_columns"` HVal string `protobuf:"bytes,2,opt,name=h_val,json=hVal,proto3" json:"h_val,omitempty" pg:"h_val"` PeerId string `protobuf:"bytes,3,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty" pg:"peer_id"` ErrorStatus string `protobuf:"bytes,4,opt,name=error_status,json=errorStatus,proto3" json:"error_status,omitempty" pg:"error_status"` @@ -228,9 +228,9 @@ func (m *NodeError) XXX_DiscardUnknown() { var xxx_messageInfo_NodeError proto.InternalMessageInfo -func (m *NodeError) GettableName() string { +func (m *NodeError) GetTableName() string { if m != nil { - return m.tableName + return m.TableName } return "" } @@ -833,10 +833,10 @@ func (m *NodeHealth) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.tableName) > 0 { - i -= len(m.tableName) - copy(dAtA[i:], m.tableName) - i = encodeVarintStatus(dAtA, i, uint64(len(m.tableName))) + if len(m.TableName) > 0 { + i -= len(m.TableName) + copy(dAtA[i:], m.TableName) + i = encodeVarintStatus(dAtA, i, uint64(len(m.TableName))) i-- dAtA[i] = 0xa } @@ -896,10 +896,10 @@ func (m *NodeError) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.tableName) > 0 { - i -= len(m.tableName) - copy(dAtA[i:], m.tableName) - i = encodeVarintStatus(dAtA, i, uint64(len(m.tableName))) + if len(m.TableName) > 0 { + i -= len(m.TableName) + copy(dAtA[i:], m.TableName) + i = encodeVarintStatus(dAtA, i, uint64(len(m.TableName))) i-- dAtA[i] = 0xa } @@ -1028,7 +1028,7 @@ func (m *NodeHealth) Size() (n int) { } var l int _ = l - l = len(m.tableName) + l = len(m.TableName) if l > 0 { n += 1 + l + sovStatus(uint64(l)) } @@ -1058,7 +1058,7 @@ func (m *NodeError) Size() (n int) { } var l int _ = l - l = len(m.tableName) + l = len(m.TableName) if l > 0 { n += 1 + l + sovStatus(uint64(l)) } @@ -1317,7 +1317,7 @@ func (m *NodeHealth) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field tableName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TableName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1345,7 +1345,7 @@ func (m *NodeHealth) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.tableName = string(dAtA[iNdEx:postIndex]) + m.TableName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -1532,7 +1532,7 @@ func (m *NodeError) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field tableName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TableName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1560,7 +1560,7 @@ func (m *NodeError) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.tableName = string(dAtA[iNdEx:postIndex]) + m.TableName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { From 9aae1426ebdde2d60e46a8e792818cfe12e3f2f8 Mon Sep 17 00:00:00 2001 From: Robin Lai Date: Thu, 5 Dec 2019 13:27:06 -0800 Subject: [PATCH 5/5] regen protos --- protos/node/node.pb.go | 22 ++++++++++----------- protos/status/status.pb.go | 40 +++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/protos/node/node.pb.go b/protos/node/node.pb.go index c2ec03c..e7479b2 100644 --- a/protos/node/node.pb.go +++ b/protos/node/node.pb.go @@ -31,7 +31,7 @@ var _ = time.Kitchen const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Node struct { - TableName string `protobuf:"bytes,1,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty" pg:"table_name" pg:"node_metrics,alias:t,discard_unknown_columns"` + tableName string `pg:"node_metrics,alias:t,discard_unknown_columns"` NodeId string `protobuf:"bytes,2,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty" pg:"node_id"` BtfsVersion string `protobuf:"bytes,3,opt,name=btfs_version,json=btfsVersion,proto3" json:"btfs_version,omitempty" pg:"btfs_version"` UpTime uint64 `protobuf:"varint,4,opt,name=up_time,json=upTime,proto3" json:"up_time,omitempty" pg:"up_time"` @@ -93,9 +93,9 @@ func (m *Node) XXX_DiscardUnknown() { var xxx_messageInfo_Node proto.InternalMessageInfo -func (m *Node) GetTableName() string { +func (m *Node) GettableName() string { if m != nil { - return m.TableName + return m.tableName } return "" } @@ -582,10 +582,10 @@ func (m *Node) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.TableName) > 0 { - i -= len(m.TableName) - copy(dAtA[i:], m.TableName) - i = encodeVarintNode(dAtA, i, uint64(len(m.TableName))) + if len(m.tableName) > 0 { + i -= len(m.tableName) + copy(dAtA[i:], m.tableName) + i = encodeVarintNode(dAtA, i, uint64(len(m.tableName))) i-- dAtA[i] = 0xa } @@ -658,7 +658,7 @@ func encodeVarintNode(dAtA []byte, offset int, v uint64) int { } func NewPopulatedNode(r randyNode, easy bool) *Node { this := &Node{} - this.TableName = string(randStringNode(r)) + this.tableName = string(randStringNode(r)) this.NodeId = string(randStringNode(r)) this.BtfsVersion = string(randStringNode(r)) this.UpTime = uint64(uint64(r.Uint32())) @@ -790,7 +790,7 @@ func (m *Node) Size() (n int) { } var l int _ = l - l = len(m.TableName) + l = len(m.tableName) if l > 0 { n += 1 + l + sovNode(uint64(l)) } @@ -937,7 +937,7 @@ func (m *Node) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TableName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field tableName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -965,7 +965,7 @@ func (m *Node) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TableName = string(dAtA[iNdEx:postIndex]) + m.tableName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { diff --git a/protos/status/status.pb.go b/protos/status/status.pb.go index 11fb6a0..94bb30a 100644 --- a/protos/status/status.pb.go +++ b/protos/status/status.pb.go @@ -102,7 +102,7 @@ func (*SignedMetrics) XXX_MessageName() string { } type NodeHealth struct { - TableName string `protobuf:"bytes,1,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty" pg:"table_name" pg:"health_monitoring,alias:t,discard_unknown_columns"` + tableName string `pg:"health_monitoring,alias:t,discard_unknown_columns"` NodeId string `protobuf:"bytes,2,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty" pg:"node_id"` BtfsVersion string `protobuf:"bytes,3,opt,name=btfs_version,json=btfsVersion,proto3" json:"btfs_version,omitempty" pg:"btfs_version"` FailurePoint string `protobuf:"bytes,4,opt,name=failure_point,json=failurePoint,proto3" json:"failure_point,omitempty" pg:"failure_point"` @@ -145,9 +145,9 @@ func (m *NodeHealth) XXX_DiscardUnknown() { var xxx_messageInfo_NodeHealth proto.InternalMessageInfo -func (m *NodeHealth) GetTableName() string { +func (m *NodeHealth) GettableName() string { if m != nil { - return m.TableName + return m.tableName } return "" } @@ -185,7 +185,7 @@ func (*NodeHealth) XXX_MessageName() string { } type NodeError struct { - TableName string `protobuf:"bytes,1,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty" pg:"table_name" pg:"test_error,alias:t,discard_unknown_columns"` + tableName string `pg:"test_error,alias:t,discard_unknown_columns"` HVal string `protobuf:"bytes,2,opt,name=h_val,json=hVal,proto3" json:"h_val,omitempty" pg:"h_val"` PeerId string `protobuf:"bytes,3,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty" pg:"peer_id"` ErrorStatus string `protobuf:"bytes,4,opt,name=error_status,json=errorStatus,proto3" json:"error_status,omitempty" pg:"error_status"` @@ -228,9 +228,9 @@ func (m *NodeError) XXX_DiscardUnknown() { var xxx_messageInfo_NodeError proto.InternalMessageInfo -func (m *NodeError) GetTableName() string { +func (m *NodeError) GettableName() string { if m != nil { - return m.TableName + return m.tableName } return "" } @@ -833,10 +833,10 @@ func (m *NodeHealth) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.TableName) > 0 { - i -= len(m.TableName) - copy(dAtA[i:], m.TableName) - i = encodeVarintStatus(dAtA, i, uint64(len(m.TableName))) + if len(m.tableName) > 0 { + i -= len(m.tableName) + copy(dAtA[i:], m.tableName) + i = encodeVarintStatus(dAtA, i, uint64(len(m.tableName))) i-- dAtA[i] = 0xa } @@ -896,10 +896,10 @@ func (m *NodeError) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.TableName) > 0 { - i -= len(m.TableName) - copy(dAtA[i:], m.TableName) - i = encodeVarintStatus(dAtA, i, uint64(len(m.TableName))) + if len(m.tableName) > 0 { + i -= len(m.tableName) + copy(dAtA[i:], m.tableName) + i = encodeVarintStatus(dAtA, i, uint64(len(m.tableName))) i-- dAtA[i] = 0xa } @@ -1028,7 +1028,7 @@ func (m *NodeHealth) Size() (n int) { } var l int _ = l - l = len(m.TableName) + l = len(m.tableName) if l > 0 { n += 1 + l + sovStatus(uint64(l)) } @@ -1058,7 +1058,7 @@ func (m *NodeError) Size() (n int) { } var l int _ = l - l = len(m.TableName) + l = len(m.tableName) if l > 0 { n += 1 + l + sovStatus(uint64(l)) } @@ -1317,7 +1317,7 @@ func (m *NodeHealth) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TableName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field tableName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1345,7 +1345,7 @@ func (m *NodeHealth) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TableName = string(dAtA[iNdEx:postIndex]) + m.tableName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -1532,7 +1532,7 @@ func (m *NodeError) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TableName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field tableName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1560,7 +1560,7 @@ func (m *NodeError) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TableName = string(dAtA[iNdEx:postIndex]) + m.tableName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 {