Skip to content

Commit fe2b359

Browse files
committed
Reverse commit a9f00af
modified: src/mods/txoa.c modified: src/mods/txoa.h
1 parent 9a1e074 commit fe2b359

File tree

2 files changed

+6
-72
lines changed

2 files changed

+6
-72
lines changed

src/mods/txoa.c

Lines changed: 4 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void txoa_close(void)
6363
dbref = NULL;
6464
}
6565

66-
int txoa_get(char *address, uint64_t *amount, unsigned char *tx_hash, uint32_t index)
66+
int txoa_get(char *address, unsigned char *tx_hash, uint32_t index)
6767
{
6868
int r;
6969
size_t len;
@@ -79,11 +79,7 @@ int txoa_get(char *address, uint64_t *amount, unsigned char *tx_hash, uint32_t i
7979
r = database_get(&tmp, &len, dbref, key, TXOA_KEY_LEN);
8080
ERROR_CHECK_NEG(r, "Could not get address from txoa database.");
8181

82-
if (len > sizeof(uint64_t))
83-
{
84-
memcpy(address, tmp, len - sizeof(uint64_t));
85-
deserialize_uint64(amount, tmp + (len - sizeof(uint64_t)), SERIALIZE_ENDIAN_LIT);
86-
}
82+
memcpy(address, tmp, len);
8783

8884
free(tmp);
8985

@@ -163,25 +159,20 @@ int txoa_get_last_block(int *block_num)
163159
return 1;
164160
}
165161

166-
int txoa_batch_put(unsigned char *tx_hash, uint32_t index, char *address, uint64_t amount)
162+
int txoa_batch_put(unsigned char *tx_hash, uint32_t index, char *address)
167163
{
168164
int r;
169165
unsigned char key[TXOA_KEY_LEN];
170-
unsigned char value[BUFSIZ];
171166

172167
assert(tx_hash);
173168
assert(address);
174169

175170
memset(key, 0, TXOA_KEY_LEN);
176-
memset(value, 0, BUFSIZ);
177171

178172
serialize_uchar(key, tx_hash, TRANSACTION_ID_LEN);
179173
serialize_uint32(key + TRANSACTION_ID_LEN, index, SERIALIZE_ENDIAN_LIT);
180174

181-
memcpy(value, address, strlen(address));
182-
serialize_uint64(value + strlen(address), amount, SERIALIZE_ENDIAN_LIT);
183-
184-
r = database_batch_put(dbref, key, TXOA_KEY_LEN, value, strlen(address) + sizeof(uint64_t));
175+
r = database_batch_put(dbref, key, TXOA_KEY_LEN, (unsigned char *)address, strlen(address));
185176
ERROR_CHECK_NEG(r, "Could not add entry to txoa database.");
186177

187178
return 1;
@@ -236,59 +227,5 @@ int txoa_get_record_count(size_t *count)
236227

237228
*count = c;
238229

239-
return 1;
240-
}
241-
242-
int txoa_seek_start(void)
243-
{
244-
int r;
245-
246-
assert(dbref);
247-
248-
database_iter_reset(dbref);
249-
250-
r = database_iter_seek_start(dbref);
251-
ERROR_CHECK_NEG(r, "Unable to seek to first record in txoa database.");
252-
253-
return 1;
254-
}
255-
256-
int txoa_get_next(unsigned char *tx_hash, uint32_t *index, char *address, uint64_t *amount)
257-
{
258-
int r;
259-
size_t serialized_key_len = 0;
260-
size_t serialized_value_len = 0;
261-
unsigned char *serialized_key = NULL;
262-
unsigned char *serialized_value = NULL;
263-
264-
assert(tx_hash);
265-
assert(address);
266-
267-
r = database_iter_get(&serialized_key, &serialized_key_len, &serialized_value, &serialized_value_len, dbref);
268-
ERROR_CHECK_NEG(r, "Could not get data from database.");
269-
270-
if (strncmp((char *)serialized_key, TXAO_LAST_BLOCK_KEY, strlen(TXAO_LAST_BLOCK_KEY)) == 0)
271-
{
272-
memcpy(tx_hash, serialized_key, serialized_key_len);
273-
}
274-
else
275-
{
276-
deserialize_uchar(tx_hash, serialized_key, TRANSACTION_ID_LEN, SERIALIZE_ENDIAN_LIT);
277-
deserialize_uint32(index, serialized_key + TRANSACTION_ID_LEN, SERIALIZE_ENDIAN_LIT);
278-
memcpy(address, serialized_value, serialized_value_len - sizeof(uint64_t));
279-
deserialize_uint64(amount, serialized_value + (serialized_value_len - sizeof(uint64_t)), SERIALIZE_ENDIAN_LIT);
280-
}
281-
282-
free(serialized_key);
283-
free(serialized_value);
284-
285-
r = database_iter_next(dbref);
286-
ERROR_CHECK_NEG(r, "Could not set chainstate iter to next record.")
287-
if (r == 0)
288-
{
289-
// End of database
290-
return 0;
291-
}
292-
293230
return 1;
294231
}

src/mods/txoa.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,15 @@
1313

1414
int txoa_open(char *, bool);
1515
void txoa_close(void);
16-
int txoa_get(char *, uint64_t *, unsigned char *, uint32_t);
16+
int txoa_get(char *, unsigned char *, uint32_t);
1717
int txoa_put(unsigned char *, uint32_t, char *);
1818
int txoa_delete(unsigned char *, uint32_t);
1919
int txoa_set_last_block(int);
2020
int txoa_get_last_block(int *);
2121
int txoa_get_record_count(size_t *);
2222

23-
int txoa_batch_put(unsigned char *, uint32_t, char *, uint64_t);
23+
int txoa_batch_put(unsigned char *, uint32_t, char *);
2424
int txoa_batch_delete(unsigned char *, uint32_t);
2525
int txoa_batch_write(void);
2626

27-
int txoa_seek_start(void);
28-
int txoa_get_next(unsigned char *, uint32_t *, char *, uint64_t *);
29-
3027
#endif

0 commit comments

Comments
 (0)