Merge branch '0.1.x' into 0.2.x

This commit is contained in:
Luke Dashjr
2014-02-24 06:32:27 +00:00
3 changed files with 12 additions and 4 deletions

View File

@@ -130,6 +130,8 @@ err:
tmpl->skey = true; \
} while(0)
static void my_flip(void *, size_t);
static
const char *parse_txn(struct blktxn_t *txn, json_t *txnj) {
json_t *vv;
@@ -146,12 +148,14 @@ const char *parse_txn(struct blktxn_t *txn, json_t *txnj) {
if ((vv = json_object_get(txnj, "hash")) && json_is_string(vv))
{
hexdata = json_string_value(vv);
txn->hash = malloc(sizeof(*txn->hash));
if (!my_hex2bin(*txn->hash, hexdata, sizeof(*txn->hash)))
txn->hash_ = malloc(sizeof(*txn->hash_));
if (!my_hex2bin(*txn->hash_, hexdata, sizeof(*txn->hash_)))
{
free(txn->hash);
txn->hash = NULL;
free(txn->hash_);
txn->hash_ = NULL;
}
else
my_flip(*txn->hash_, sizeof(*txn->hash_));
}
// TODO: dependcount/depends, fee, required, sigops

View File

@@ -97,6 +97,7 @@ static
void blktxn_free(struct blktxn_t *bt) {
free(bt->data);
free(bt->hash);
free(bt->hash_);
free(bt->depends);
}

View File

@@ -23,6 +23,7 @@ typedef uint32_t blknonce_t;
struct blktxn_t {
unsigned char *data;
size_t datasz;
// NOTE: The byte order of hash is backward; use hash_ instead
txnhash_t *hash;
signed long dependcount;
@@ -31,6 +32,8 @@ struct blktxn_t {
uint64_t fee;
bool required;
int16_t sigops;
txnhash_t *hash_;
};
// BIP 23: Long Polling