Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

include attestation in witness and receipt reports #1279

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
{erlang_stats, ".*", {git, "https://github.com/helium/erlang-stats.git", {branch, "master"}}},
{e2qc, ".*", {git, "https://github.com/helium/e2qc", {branch, "master"}}},
{vincenty, ".*", {git, "https://github.com/helium/vincenty", {branch, "master"}}},
{helium_proto, {git, "https://github.com/helium/proto.git", {branch, "master"}}},
{helium_proto, {git, "https://github.com/helium/proto.git", {branch, "andymck/poc-grpc-report-attestation"}}},
{lorawan, {git, "https://github.com/helium/erlang-lorawan.git", {branch, "master"}}},
{merkerl, ".*", {git, "https://github.com/helium/merkerl.git", {branch, "master"}}},
{xxhash, {git, "https://github.com/pierreis/erlang-xxhash", {branch, "master"}}},
Expand Down
2 changes: 1 addition & 1 deletion rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
{<<"hackney">>,{pkg,<<"hackney">>,<<"1.18.0">>},0},
{<<"helium_proto">>,
{git,"https://github.com/helium/proto.git",
{ref,"d1694d5ddb3801f70461921a33407b04d9df66f3"}},
{ref,"45792698b66690062e4f130912edb772eb4edd45"}},
0},
{<<"hpack">>,{pkg,<<"hpack_erl">>,<<"0.2.3">>},2},
{<<"idna">>,{pkg,<<"idna">>,<<"6.1.1">>},1},
Expand Down
28 changes: 26 additions & 2 deletions src/transactions/v1/blockchain_poc_receipt_v1.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
-include("blockchain_caps.hrl").
-include("blockchain_vars.hrl").
-include("blockchain_utils.hrl").
-include_lib("helium_proto/include/blockchain_poc_core_v1_pb.hrl").
-include_lib("helium_proto/include/blockchain_txn_poc_receipts_v1_pb.hrl").

-export([
new/5, new/7, new/9,
new/5, new/7, new/9, new/10,
gateway/1,
timestamp/1,
signal/1,
Expand Down Expand Up @@ -98,7 +99,30 @@ new(Address, Timestamp, Signal, Data, Origin, SNR, Frequency, Channel, DataRate)
datarate=DataRate,
signature = <<>>
}.

-spec new(Address :: libp2p_crypto:pubkey_bin(),
Timestamp :: non_neg_integer(),
Signal :: integer(),
Data :: binary(),
Origin :: origin(),
SNR :: float(),
Frequency :: float(),
Channel :: non_neg_integer(),
DataRate :: binary(),
Attestation :: #attestation_pb{}) -> poc_receipt().
new(Address, Timestamp, Signal, Data, Origin, SNR, Frequency, Channel, DataRate, Attestation) ->
#blockchain_poc_receipt_v1_pb{
gateway=Address,
timestamp=Timestamp,
signal=Signal,
data=Data,
origin=Origin,
snr=SNR,
frequency=Frequency,
channel=Channel,
datarate=DataRate,
signature = <<>>,
attestation = Attestation
}.
-spec gateway(Receipt :: poc_receipt()) -> libp2p_crypto:pubkey_bin().
gateway(Receipt) ->
Receipt#blockchain_poc_receipt_v1_pb.gateway.
Expand Down
26 changes: 25 additions & 1 deletion src/transactions/v1/blockchain_poc_witness_v1.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
-include("blockchain_caps.hrl").
-include("blockchain_json.hrl").
-include("blockchain_utils.hrl").
-include_lib("helium_proto/include/blockchain_poc_core_v1_pb.hrl").
-include_lib("helium_proto/include/blockchain_txn_poc_receipts_v1_pb.hrl").

-export([
new/4, new/6, new/8,
new/4, new/6, new/8, new/9,
gateway/1,
timestamp/1,
signal/1,
Expand Down Expand Up @@ -88,6 +89,29 @@ new(Gateway, Timestamp, Signal, PacketHash, SNR, Frequency, Channel, DataRate) -
signature = <<>>
}.

-spec new(Gateway :: libp2p_crypto:pubkey_bin(),
Timestamp :: non_neg_integer(),
Signal :: integer(),
PacketHash :: binary(),
SNR :: float(),
Frequency :: float(),
Channel :: non_neg_integer(),
DataRate :: binary(),
Attestation :: #attestation_pb{}) -> poc_witness().
new(Gateway, Timestamp, Signal, PacketHash, SNR, Frequency, Channel, DataRate, Attestation) ->
#blockchain_poc_witness_v1_pb{
gateway=Gateway,
timestamp=Timestamp,
signal=Signal,
packet_hash=PacketHash,
snr=SNR,
frequency=Frequency,
channel=Channel,
datarate=DataRate,
signature = <<>>,
attestation = Attestation
}.

-spec gateway(Witness :: poc_witness()) -> libp2p_crypto:pubkey_bin().
gateway(Witness) ->
Witness#blockchain_poc_witness_v1_pb.gateway.
Expand Down