|
|
@ -22,6 +22,8 @@ import ( |
|
|
|
"git.hush.is/duke/lightwalletd/parser" |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type lwdStreamer struct { |
|
|
|
cache *common.BlockCache |
|
|
|
chainName string |
|
|
@ -29,6 +31,11 @@ type lwdStreamer struct { |
|
|
|
walletrpc.UnimplementedCompactTxStreamerServer |
|
|
|
} |
|
|
|
|
|
|
|
// NewLwdStreamer constructs a gRPC context.
|
|
|
|
func NewLwdStreamer(cache *common.BlockCache, chainName string, enablePing bool) (walletrpc.CompactTxStreamerServer, error) { |
|
|
|
return &lwdStreamer{cache: cache, chainName: chainName, pingEnable: enablePing}, nil |
|
|
|
} |
|
|
|
|
|
|
|
var ( |
|
|
|
ErrUnspecified = errors.New("request for unspecified identifier") |
|
|
|
) |
|
|
@ -52,15 +59,16 @@ func (s *SqlStreamer) GetCache() *common.BlockCache { |
|
|
|
return s.cache |
|
|
|
} |
|
|
|
|
|
|
|
func (s *SqlStreamer) GetLatestBlock(ctx context.Context, placeholder *walletrpc.ChainSpec) (*walletrpc.BlockID, error) { |
|
|
|
latestBlock := s.cache.GetLatestBlock() |
|
|
|
// GetLatestBlock returns the height of the best chain according to hushd
|
|
|
|
func (s *lwdStreamer) GetLatestBlock(ctx context.Context, placeholder *walletrpc.ChainSpec) (*walletrpc.BlockID, error) { |
|
|
|
latestBlock := s.cache.GetLatestHeight() |
|
|
|
latestHash := s.cache.GetLatestHash() |
|
|
|
|
|
|
|
if latestBlock == -1 { |
|
|
|
return nil, errors.New("Cache is empty. Server is probably not yet ready.") |
|
|
|
return nil, errors.New("Cache is empty. Server is probably not yet ready") |
|
|
|
} |
|
|
|
|
|
|
|
// TODO: also return block hashes here
|
|
|
|
return &walletrpc.BlockID{Height: uint64(latestBlock)}, nil |
|
|
|
return &walletrpc.BlockID{Height: uint64(latestBlock), Hash: latestHash}, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (s *SqlStreamer) GetAddressTxids(addressBlockFilter *walletrpc.TransparentAddressBlockFilter, resp walletrpc.CompactTxStreamer_GetAddressTxidsServer) error { |
|
|
|