Skip to content

Commit

Permalink
Update with new URL format
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielKrawisz committed Mar 30, 2023
1 parent 7c62148 commit aac9d67
Show file tree
Hide file tree
Showing 41 changed files with 1,834 additions and 1,775 deletions.
4 changes: 2 additions & 2 deletions include/gigamonkey/address.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ namespace Gigamonkey::Bitcoin {
pubkey (const secp256k1::pubkey &p) : secp256k1::pubkey {p} {}

explicit pubkey (string_view s) : secp256k1::pubkey {} {
ptr<bytes> hex = encoding::hex::read(s);
if (hex != nullptr) {
maybe<bytes> hex = encoding::hex::read(s);
if (bool (hex)) {
this->resize (hex->size ());
std::copy (hex->begin (), hex->end (), this->begin ());
};
Expand Down
101 changes: 51 additions & 50 deletions include/gigamonkey/boost/boost.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,21 @@ namespace Gigamonkey {

static output_script bounty (
int32_little category,
const uint256& content,
const uint256 &content,
work::compact target,
const bytes& tag,
const bytes &tag,
uint32_little user_nonce,
const bytes& data,
const bytes &data,
bool use_general_purpose_bits = true);

static output_script contract (
int32_little category,
const uint256& content,
const uint256 &content,
work::compact target,
const bytes& tag,
const bytes &tag,
uint32_little user_nonce,
const bytes& data,
const digest160& miner_pubkey_hash,
const bytes &data,
const digest160 &miner_pubkey_hash,
bool use_general_purpose_bits = true);

bool valid () const;
Expand Down Expand Up @@ -122,32 +122,32 @@ namespace Gigamonkey {
private:
output_script (
int32_little category,
const uint256& content,
const uint256 &content,
work::compact target,
const bytes& tag,
const bytes &tag,
uint32_little user_nonce,
const bytes& data,
const bytes &data,
bool use_general_purpose_bits = true);

output_script (
int32_little category,
const uint256& content,
const uint256 &content,
work::compact target,
const bytes& tag,
const bytes &tag,
uint32_little user_nonce,
const bytes& data,
const bytes &data,
const digest160& miner_pubkey_hash,
bool use_general_purpose_bits = true);

output_script (
Boost::type type,
int32_little category,
const uint256& content,
const uint256 &content,
work::compact target,
const bytes& tag,
const bytes &tag,
uint32_little user_nonce,
const bytes& data,
const digest160& miner_pubkey_hash,
const bytes &data,
const digest160 &miner_pubkey_hash,
bool use_general_purpose_bits = true);

};
Expand All @@ -161,47 +161,47 @@ namespace Gigamonkey {
Bitcoin::timestamp Timestamp;
bytes ExtraNonce2;
Stratum::session_id ExtraNonce1;
std::optional<int32_little> GeneralPurposeBits;
maybe<int32_little> GeneralPurposeBits;
digest160 MinerPubkeyHash;

private:
// bounty type, no ASICBoost
input_script (
const Bitcoin::signature& signature,
const Bitcoin::pubkey& pubkey,
const Bitcoin::signature &signature,
const Bitcoin::pubkey &pubkey,
uint32_little nonce,
Bitcoin::timestamp timestamp,
const bytes& extra_nonce_2,
const bytes &extra_nonce_2,
Stratum::session_id extra_nonce_1,
const digest160& miner_pubkey_hash);
const digest160 &miner_pubkey_hash);

// contract type, no ASICBoost
input_script (
const Bitcoin::signature& signature,
const Bitcoin::pubkey& pubkey,
const Bitcoin::signature &signature,
const Bitcoin::pubkey &pubkey,
uint32_little nonce,
Bitcoin::timestamp timestamp,
const bytes& extra_nonce_2,
const bytes &extra_nonce_2,
Stratum::session_id extra_nonce_1);

// bounty type compatible with ASICBoost
input_script (
const Bitcoin::signature& signature,
const Bitcoin::pubkey& pubkey,
const Bitcoin::signature &signature,
const Bitcoin::pubkey &pubkey,
uint32_little nonce,
Bitcoin::timestamp timestamp,
const bytes& extra_nonce_2,
const bytes &extra_nonce_2,
Stratum::session_id extra_nonce_1,
int32_little general_purpose_bits,
const digest160& miner_pubkey_hash);
const digest160 &miner_pubkey_hash);

// contract type compatible with ASICBoost;
input_script (
const Bitcoin::signature& signature,
const Bitcoin::pubkey& pubkey,
const Bitcoin::signature &signature,
const Bitcoin::pubkey &pubkey,
uint32_little nonce,
Bitcoin::timestamp timestamp,
const bytes& extra_nonce_2,
const bytes &extra_nonce_2,
Stratum::session_id extra_nonce_1,
int32_little general_purpose_bits);

Expand All @@ -218,41 +218,41 @@ namespace Gigamonkey {

// construct a Boost bounty input script.
static input_script bounty (
const Bitcoin::signature& signature,
const Bitcoin::pubkey& pubkey,
const Bitcoin::signature &signature,
const Bitcoin::pubkey &pubkey,
uint32_little nonce,
Bitcoin::timestamp timestamp,
const bytes& extra_nonce_2,
const bytes &extra_nonce_2,
Stratum::session_id extra_nonce_1,
const digest160& miner_pubkey_hash);
const digest160 &miner_pubkey_hash);

// construct a Boost contract input script.
static input_script contract (
const Bitcoin::signature& signature,
const Bitcoin::pubkey& pubkey,
const Bitcoin::signature &signature,
const Bitcoin::pubkey &pubkey,
uint32_little nonce,
Bitcoin::timestamp timestamp,
const bytes& extra_nonce_2,
const bytes &extra_nonce_2,
Stratum::session_id extra_nonce_1);

// construct a Boost bounty input script.
static input_script bounty (
const Bitcoin::signature& signature,
const Bitcoin::pubkey& pubkey,
const Bitcoin::signature &signature,
const Bitcoin::pubkey &pubkey,
uint32_little nonce,
Bitcoin::timestamp timestamp,
const bytes& extra_nonce_2,
const bytes &extra_nonce_2,
Stratum::session_id extra_nonce_1,
int32_little category_bits,
const digest160& miner_pubkey_hash);
const digest160 &miner_pubkey_hash);

// construct a Boost contract input script.
static input_script contract (
const Bitcoin::signature& signature,
const Bitcoin::pubkey& pubkey,
const Bitcoin::signature &signature,
const Bitcoin::pubkey &pubkey,
uint32_little nonce,
Bitcoin::timestamp timestamp,
const bytes& extra_nonce_2,
const bytes &extra_nonce_2,
Stratum::session_id extra_nonce_1,
int32_little category_bits);

Expand All @@ -269,9 +269,9 @@ namespace Gigamonkey {
static digest160 miner_pubkey_hash (script x);

input_script (
const Bitcoin::signature& signature,
const Bitcoin::pubkey& pubkey,
const work::solution&, Boost::type,
const Bitcoin::signature &signature,
const Bitcoin::pubkey &pubkey,
const work::solution &, Boost::type,
bool category_mask);

static uint64 expected_size (Boost::type t, bool use_general_purpose_bits, bool compressed_pubkey = true);
Expand Down Expand Up @@ -475,7 +475,8 @@ namespace Gigamonkey {
work::compact target,
const bytes &tag,
uint32_little user_nonce,
const bytes &data, bool masked_category) {
const bytes &data,
bool masked_category) {
if (tag.size() > 20) return output_script {};
return output_script{category, content, target, tag, user_nonce, data, masked_category};
}
Expand Down
21 changes: 10 additions & 11 deletions include/gigamonkey/hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ namespace Gigamonkey {

transform Hash;

hash_writer () : Hash{} {}
hash_writer () : Hash {} {}

digest<size> finalize () {
digest<size> d;
Expand All @@ -254,7 +254,7 @@ namespace Gigamonkey {
return d;
}

void write(const byte* b, size_t x) override {
void write (const byte* b, size_t x) override {
Hash.Update (b, x);
}

Expand Down Expand Up @@ -301,7 +301,7 @@ namespace Gigamonkey {
using SHA3_512_writer = SHA3_writer<64>;

digest160 inline SHA1 (bytes_view b) {
return SHA1_writer{} (b);
return SHA1_writer {} (b);
}

digest224 inline SHA2_224 (bytes_view b) {
Expand All @@ -325,19 +325,19 @@ namespace Gigamonkey {
}

digest256 inline SHA3_256 (bytes_view b) {
return SHA3_256_writer{} (b);
return SHA3_256_writer {} (b);
}

digest384 inline SHA3_384 (bytes_view b) {
return SHA3_384_writer{} (b);
return SHA3_384_writer {} (b);
}

digest512 inline SHA3_512 (bytes_view b) {
return SHA3_512_writer{} (b);
return SHA3_512_writer {} (b);
}

digest128 inline RIPEMD_128 (bytes_view b) {
return RIPEMD_128_writer{} (b);
return RIPEMD_128_writer {} (b);
}

digest160 inline RIPEMD_160 (bytes_view b) {
Expand Down Expand Up @@ -385,10 +385,9 @@ namespace Gigamonkey {

template <size_t size>
digest<size>::digest (string_view s) {
ptr<bytes> b = data::encoding::hex::read (s);
if (b != nullptr) {
std::copy (b->begin (), b->end (), begin ());
} else *this = digest {uint<size> {string (s)}};
maybe<bytes> b = data::encoding::hex::read (s);
if (bool (b)) std::copy (b->begin (), b->end (), begin ());
else *this = digest {uint<size> {string (s)}};
}

template <size_t size>
Expand Down
Loading

0 comments on commit aac9d67

Please sign in to comment.