Browse Source

Return consensusBranchId

master
Aditya Kulkarni 5 years ago
parent
commit
fbb75e8f20
  1. 4
      cmd/server/main.go
  2. 13
      common/common.go
  3. 3
      frontend/service.go
  4. 89
      walletrpc/service.pb.go
  5. 1
      walletrpc/service.proto

4
cmd/server/main.go

@ -161,14 +161,14 @@ func main() {
}
// Get the sapling activation height from the RPC
saplingHeight, chainName, err := common.GetSaplingInfo(rpcClient)
saplingHeight, chainName, branchID, err := common.GetSaplingInfo(rpcClient)
if err != nil {
log.WithFields(logrus.Fields{
"error": err,
}).Warn("Unable to get sapling activation height")
}
log.WithField("saplingHeight", saplingHeight).Info("Got sapling height ", saplingHeight, " chain ", chainName)
log.Info("Got sapling height ", saplingHeight, " chain ", chainName, " branchID ", branchID)
// Compact transaction service initialization
service, err := frontend.NewSQLiteStreamer(rpcClient, log)

13
common/common.go

@ -13,7 +13,7 @@ import (
"github.com/pkg/errors"
)
func GetSaplingInfo(rpcClient *rpcclient.Client) (int, string, error) {
func GetSaplingInfo(rpcClient *rpcclient.Client) (int, string, string, error) {
result, rpcErr := rpcClient.RawRequest("getblockchaininfo", make([]json.RawMessage, 0))
var err error
@ -25,15 +25,15 @@ func GetSaplingInfo(rpcClient *rpcclient.Client) (int, string, error) {
errCode, err = strconv.ParseInt(errParts[0], 10, 32)
//Check to see if we are requesting a height the zcashd doesn't have yet
if err == nil && errCode == -8 {
return -1, "", nil
return -1, "", "", nil
}
return -1, "", errors.Wrap(rpcErr, "error requesting block")
return -1, "", "", errors.Wrap(rpcErr, "error requesting block")
}
var f interface{}
err = json.Unmarshal(result, &f)
if err != nil {
return -1, "", errors.Wrap(err, "error reading JSON response")
return -1, "", "", errors.Wrap(err, "error reading JSON response")
}
chainName := f.(map[string]interface{})["chain"].(string)
@ -42,7 +42,10 @@ func GetSaplingInfo(rpcClient *rpcclient.Client) (int, string, error) {
saplingJSON := upgradeJSON.(map[string]interface{})["76b809bb"] // Sapling ID
saplingHeight := saplingJSON.(map[string]interface{})["activationheight"].(float64)
return int(saplingHeight), chainName, nil
consensus := f.(map[string]interface{})["consensus"]
branchID := consensus.(map[string]interface{})["nextblock"].(string)
return int(saplingHeight), chainName, branchID, nil
}
func getBlockFromRPC(rpcClient *rpcclient.Client, height int) (*walletrpc.CompactBlock, error) {

3
frontend/service.go

@ -243,7 +243,7 @@ func (s *SqlStreamer) GetTransaction(ctx context.Context, txf *walletrpc.TxFilte
// GetLightdInfo gets the LightWalletD (this server) info
func (s *SqlStreamer) GetLightdInfo(ctx context.Context, in *walletrpc.Empty) (*walletrpc.LightdInfo, error) {
saplingHeight, chainName, err := common.GetSaplingInfo(s.client)
saplingHeight, chainName, consensusBranchId, err := common.GetSaplingInfo(s.client)
if err != nil {
s.log.WithFields(logrus.Fields{
@ -260,6 +260,7 @@ func (s *SqlStreamer) GetLightdInfo(ctx context.Context, in *walletrpc.Empty) (*
TaddrSupport: true,
ChainName: chainName,
SaplingActivationHeight: uint64(saplingHeight),
ConsensusBranchId: consensusBranchId,
}, nil
}

89
walletrpc/service.pb.go

@ -345,6 +345,7 @@ type LightdInfo struct {
TaddrSupport bool `protobuf:"varint,3,opt,name=taddrSupport,proto3" json:"taddrSupport,omitempty"`
ChainName string `protobuf:"bytes,4,opt,name=chainName,proto3" json:"chainName,omitempty"`
SaplingActivationHeight uint64 `protobuf:"varint,5,opt,name=saplingActivationHeight,proto3" json:"saplingActivationHeight,omitempty"`
ConsensusBranchId string `protobuf:"bytes,6,opt,name=consensusBranchId,proto3" json:"consensusBranchId,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -410,6 +411,13 @@ func (m *LightdInfo) GetSaplingActivationHeight() uint64 {
return 0
}
func (m *LightdInfo) GetConsensusBranchId() string {
if m != nil {
return m.ConsensusBranchId
}
return ""
}
type TransparentAddress struct {
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
@ -512,46 +520,47 @@ func init() {
func init() { proto.RegisterFile("service.proto", fileDescriptor_a0b84a42fa06f626) }
var fileDescriptor_a0b84a42fa06f626 = []byte{
// 609 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x41, 0x6f, 0x13, 0x3d,
0x10, 0xcd, 0xb6, 0xd9, 0xb6, 0x99, 0xa6, 0xad, 0x3e, 0xeb, 0x2b, 0x44, 0x51, 0x81, 0x62, 0x84,
0xd4, 0xd3, 0xaa, 0x2a, 0x45, 0x70, 0xe0, 0xd2, 0x06, 0x08, 0x95, 0x0a, 0x02, 0x27, 0xa7, 0x72,
0xa8, 0xdc, 0xf5, 0x34, 0xbb, 0x34, 0xb1, 0x57, 0xb6, 0x49, 0x03, 0x3f, 0x86, 0x1f, 0xc2, 0xaf,
0x43, 0xf6, 0x6e, 0x9a, 0x8d, 0x60, 0x9b, 0xdc, 0x76, 0xec, 0x37, 0xef, 0xcd, 0x8c, 0xe7, 0x2d,
0x6c, 0x19, 0xd4, 0xe3, 0x34, 0xc6, 0x28, 0xd3, 0xca, 0x2a, 0xb2, 0x1b, 0x73, 0x93, 0x44, 0x3f,
0xa3, 0x5b, 0x3e, 0x1c, 0xa2, 0x8d, 0x8c, 0xb8, 0x89, 0x74, 0x16, 0xb7, 0x77, 0x63, 0x35, 0xca,
0x78, 0x6c, 0x2f, 0xaf, 0x95, 0x1e, 0x71, 0x6b, 0x72, 0x34, 0x7d, 0x09, 0xeb, 0xa7, 0x43, 0x15,
0xdf, 0x9c, 0xbd, 0x25, 0x0f, 0x60, 0x2d, 0xc1, 0x74, 0x90, 0xd8, 0x56, 0xb0, 0x1f, 0x1c, 0xd4,
0x59, 0x11, 0x11, 0x02, 0xf5, 0x84, 0x9b, 0xa4, 0xb5, 0xb2, 0x1f, 0x1c, 0x34, 0x99, 0xff, 0xa6,
0x16, 0xc0, 0xa7, 0x31, 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38, 0x03, 0x95, 0xc9, 0x97, 0xcb, 0xad, 0x2c, 0xbf, 0xec, 0x47, 0x5a, 0x23,
0x1a, 0x76, 0xba, 0x38, 0x5d, 0xa2, 0xfe, 0x24, 0x15, 0x86, 0x1c, 0x57, 0x55, 0x7f, 0xdf, 0xd2,
0x2d, 0xdd, 0xd2, 0x61, 0x40, 0x98, 0x7f, 0x8d, 0x92, 0x5f, 0xf7, 0x2a, 0x72, 0xbd, 0xb9, 0xdb,
0x55, 0x6f, 0x35, 0x23, 0xa0, 0xb5, 0xd3, 0xcd, 0x8b, 0x46, 0x7e, 0xad, 0xb3, 0xf8, 0x6a, 0xcd,
0xff, 0xd4, 0x5f, 0xfc, 0x09, 0x00, 0x00, 0xff, 0xff, 0x53, 0xcd, 0xf6, 0x94, 0x13, 0x06, 0x00,
0x00,
// 630 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x55, 0x5d, 0x4f, 0x13, 0x41,
0x14, 0xa5, 0xd0, 0xed, 0xc7, 0x6d, 0x81, 0x30, 0x11, 0x6d, 0x1a, 0x54, 0x1c, 0x63, 0xe2, 0x83,
0xd9, 0x10, 0xc4, 0xe8, 0x83, 0x2f, 0xb4, 0x7e, 0x35, 0x41, 0xa3, 0xd3, 0x3e, 0xe1, 0x03, 0x19,
0x76, 0x87, 0xee, 0x4a, 0xbb, 0xb3, 0x99, 0x19, 0x4a, 0xf5, 0xc7, 0xf8, 0xfb, 0xfc, 0x19, 0xce,
0xc7, 0x96, 0x6e, 0x03, 0x4b, 0xfb, 0xb6, 0x77, 0xe6, 0xde, 0x73, 0xce, 0x3d, 0x73, 0x6f, 0x0b,
0x9b, 0x92, 0x89, 0x49, 0x1c, 0x30, 0x3f, 0x15, 0x5c, 0x71, 0xb4, 0x1b, 0x50, 0x19, 0xf9, 0x7f,
0xfc, 0x6b, 0x3a, 0x1a, 0x31, 0xe5, 0xcb, 0x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 0x4c, 0x1b, 0x24, 0xd0, 0x00, 0xb6,
0x3e, 0x33, 0x75, 0x42, 0x15, 0x93, 0xca, 0xd6, 0xa0, 0xfd, 0x02, 0xc4, 0x9b, 0x17, 0x6e, 0x2f,
0x99, 0x67, 0xbc, 0x86, 0x7e, 0x40, 0x4d, 0xa3, 0x3a, 0xbc, 0x25, 0xd9, 0xed, 0xe7, 0x45, 0x7c,
0x4e, 0xab, 0x4d, 0xd3, 0x90, 0x3f, 0x61, 0x73, 0x06, 0xe9, 0x16, 0x7b, 0x79, 0xe7, 0x2b, 0x42,
0x1f, 0x94, 0xd0, 0xa9, 0x75, 0x21, 0xbf, 0x50, 0x4f, 0x0b, 0x4a, 0x67, 0x3b, 0xde, 0x7e, 0x51,
0x90, 0xb0, 0xb8, 0x98, 0x5a, 0xf8, 0x19, 0x6c, 0x9b, 0x75, 0xcb, 0x83, 0xaf, 0x56, 0x5b, 0x28,
0x3f, 0xbf, 0xbd, 0x9a, 0x40, 0xc0, 0xb6, 0x16, 0x9f, 0x0d, 0xd1, 0x60, 0x1a, 0x87, 0x12, 0x1d,
0x15, 0xa9, 0xbf, 0x6f, 0xe8, 0x56, 0x6e, 0x49, 0x1b, 0x46, 0xec, 0x6b, 0xe4, 0xb6, 0x7b, 0xaf,
0xa0, 0xd6, 0xfe, 0x14, 0xb4, 0x8b, 0xde, 0x6a, 0x0e, 0x80, 0xd7, 0x3a, 0x8d, 0xd3, 0xba, 0xbb,
0xd6, 0x37, 0xe7, 0x15, 0xfb, 0x17, 0xf0, 0xfa, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x84, 0x2f,
0xbf, 0xf7, 0x41, 0x06, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.

1
walletrpc/service.proto

@ -50,6 +50,7 @@ message LightdInfo {
bool taddrSupport = 3;
string chainName = 4;
uint64 saplingActivationHeight = 5;
string consensusBranchId = 6; // This should really be u32 or []byte, but string for readability
}
message TransparentAddress {

Loading…
Cancel
Save