static void outputv(ErlDrvData handle, ErlIOVec *ev) { ErlDrvPort port = (ErlDrvPort) handle; SysIOVec *bin; int i, n, index = 0; unsigned long hash; unsigned long seed; //first piece of the iovec is the seed // printf("ev->size %d\n", ev->size); // printf("ev-vsize %d\n", ev->vsize); //apparently we start counting at 1 round here? bin = &ev->iov[1]; // printf("bin->orig_size %d\n", bin->iov_len); // printf("bin->iov_base %s\n", bin->iov_base); ei_decode_version(bin->iov_base, &index, NULL); ei_decode_ulong(bin->iov_base, &index, &seed); hash = (unsigned int) seed; if (index < bin->iov_len) { hash = MurmurHash2(&bin->iov_base[index], bin->iov_len - index, hash); } // printf("hash %d\n", hash); for (i=2; i<ev->vsize; i++) { bin = &ev->iov[i]; // printf("bin->orig_size %d\n", bin->iov_len); hash = MurmurHash2(bin->iov_base, bin->iov_len, hash); // printf("hashed %d\n", i); } send_hash(port, hash); }
void rai::system::generate_receive (rai::node & node_a) { std::shared_ptr<rai::block> send_block; { rai::transaction transaction (node_a.store.environment, nullptr, false); rai::uint256_union random_block; random_pool.GenerateBlock (random_block.bytes.data (), sizeof (random_block.bytes)); auto i (node_a.store.pending_begin (transaction, rai::pending_key (random_block, 0))); if (i != node_a.store.pending_end ()) { rai::pending_key send_hash (i->first); rai::pending_info info (i->second); send_block = node_a.store.block_get (transaction, send_hash.hash); } } if (send_block != nullptr) { auto receive_error (wallet (0)->receive_sync (send_block, rai::genesis_account, std::numeric_limits<rai::uint128_t>::max ())); (void)receive_error; } }