Skip to content

Commit fb674ce

Browse files
riptlripatel-fd
authored andcommitted
funk: simplify rec_key_hash1
1 parent 4ab02a0 commit fb674ce

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

src/discof/restore/fd_snapin_tile_funk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fd_snapin_process_account_batch_funk( fd_snapin_tile_t * ctx,
124124
for( ulong i=0UL; i<FD_SSPARSE_ACC_BATCH_MAX; i++ ) {
125125
uchar const * frame = result->account_batch.batch[ i ];
126126
uchar const * pubkey = frame+0x10UL;
127-
ulong memo = fd_funk_rec_key_hash1( pubkey, 0UL, rec_map->map->seed );
127+
ulong memo = fd_funk_rec_key_hash1( pubkey, rec_map->map->seed );
128128
chain_idx[ i ] = (uint)( memo&chain_mask );
129129
}
130130

src/flamenco/gossip/crds/fd_crds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ lookup_hash( fd_crds_key_t const * key,
235235
default:
236236
break;
237237
}
238-
return fd_funk_rec_key_hash1( key->pubkey, hash_fn, seed );
238+
return fd_funk_rec_key_hash1( key->pubkey, seed^hash_fn );
239239
}
240240

241241
static inline int

src/flamenco/runtime/fd_blockhashes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ typedef struct fd_blockhash_info fd_blockhash_info_t;
4242
#define MAP_IDX_T ushort
4343
#define MAP_NEXT next
4444
#define MAP_KEY_EQ(k0,k1) fd_hash_eq( (k0), (k1) )
45-
#define MAP_KEY_HASH(k,s) fd_funk_rec_key_hash1( (k->uc), 0, (s) )
45+
#define MAP_KEY_HASH(k,s) fd_funk_rec_key_hash1( (k->uc), (s) )
4646
#include "../../util/tmpl/fd_map_chain.c"
4747

4848
/* fd_blockhashes_t is the class representing a blockhash queue.

src/flamenco/stakes/fd_stake_delegations.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define MAP_ELE_T fd_stake_delegation_t
1414
#define MAP_KEY stake_account
1515
#define MAP_KEY_EQ(k0,k1) (fd_pubkey_eq( k0, k1 ))
16-
#define MAP_KEY_HASH(key,seed) (fd_funk_rec_key_hash1( (uchar *)key, 0, seed ))
16+
#define MAP_KEY_HASH(key,seed) (fd_funk_rec_key_hash1( key->uc, seed ))
1717
#define MAP_NEXT next_
1818
#include "../../util/tmpl/fd_map_chain.c"
1919

src/funk/fd_funk_base.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,14 @@ fd_xxh3_mul128_fold64( ulong lhs, ulong rhs ) {
166166

167167
static inline ulong
168168
fd_xxh3_mix16b( ulong i0, ulong i1,
169-
ulong s0, ulong s1,
170-
ulong seed ) {
169+
ulong s0, ulong s1,
170+
ulong seed ) {
171171
return fd_xxh3_mul128_fold64( i0 ^ (s0 + seed), i1 ^ (s1 - seed) );
172172
}
173173

174174
FD_FN_PURE static inline ulong
175175
fd_funk_rec_key_hash1( uchar const key[ 32 ],
176-
ulong rec_type,
177176
ulong seed ) {
178-
seed ^= rec_type;
179177
ulong k0 = FD_LOAD( ulong, key+ 0 );
180178
ulong k1 = FD_LOAD( ulong, key+ 8 );
181179
ulong k2 = FD_LOAD( ulong, key+16 );
@@ -192,7 +190,7 @@ fd_funk_rec_key_hash1( uchar const key[ 32 ],
192190
FD_FN_PURE static inline ulong
193191
fd_funk_rec_key_hash( fd_funk_rec_key_t const * k,
194192
ulong seed ) {
195-
return fd_funk_rec_key_hash1( k->uc, 0UL, seed );
193+
return fd_funk_rec_key_hash1( k->uc, seed );
196194
}
197195

198196
#else
@@ -204,9 +202,7 @@ fd_funk_rec_key_hash( fd_funk_rec_key_t const * k,
204202

205203
FD_FN_PURE static inline ulong
206204
fd_funk_rec_key_hash1( uchar const key[ 32 ],
207-
ulong rec_type,
208205
ulong seed ) {
209-
seed ^= rec_type;
210206
/* tons of ILP */
211207
return (fd_ulong_hash( seed ^ (1UL<<0) ^ FD_LOAD( ulong, key+ 0 ) ) ^
212208
fd_ulong_hash( seed ^ (1UL<<1) ^ FD_LOAD( ulong, key+ 8 ) ) ) ^
@@ -217,7 +213,7 @@ fd_funk_rec_key_hash1( uchar const key[ 32 ],
217213
FD_FN_PURE static inline ulong
218214
fd_funk_rec_key_hash( fd_funk_rec_key_t const * k,
219215
ulong seed ) {
220-
return fd_funk_rec_key_hash1( k->uc, 0UL, seed );
216+
return fd_funk_rec_key_hash1( k->uc, seed );
221217
}
222218

223219
#endif /* FD_HAS_INT128 */

0 commit comments

Comments
 (0)