Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,28 +795,31 @@ int get_hash(NODE *np, word32 ip, void *bnum, void *blockhash)
put64(tx->blocknum, tx->cblock);
} else put64(tx->blocknum, bnum);

/* perform OP_HASH request and receive -- close socket */
/* perform OP_HASH request and receive */
pdebug("%s sending OP_HASH...", np->id);
ecode = send_op(np, OP_HASH);
if (ecode != VEOK) return ecode;
if (ecode != VEOK) goto CLEANUP;
ecode = recv_tx(np, STD_TIMEOUT);
if (ecode != VEOK) return ecode;
if (ecode != VEOK) goto CLEANUP;

/* cleanup -- check response */
sock_close(np->sd);
np->sd = INVALID_SOCKET;
/* check response */
if (get16(tx->opcode) != OP_HASH) {
pdebug("%s unexpected opcode...", np->id);
return VERROR;
} else if (get16(tx->len) != HASHLEN) {
ecode = VERROR;
goto CLEANUP;
}
if (get16(tx->len) != HASHLEN) {
pdebug("%s unexpected len...", np->id);
return VERROR;
ecode = VERROR;
goto CLEANUP;
}
/* pass blockhash on success, if not NULL */
if (blockhash) memcpy(blockhash, tx->buffer, HASHLEN);

/* success */
return VEOK;
CLEANUP:
sock_close(np->sd);
np->sd = INVALID_SOCKET;
return ecode;
} /* end get_hash() */

/**
Expand Down
Loading