bitcoin-p2p-messages
Version:
implementation of the bitcoin p2p messages
30 lines (24 loc) • 530 B
JavaScript
import * as utils from '../utils'
export default class Pong {
constructor(nonce) {
if (utils.isNonce(nonce)) {
this.nonce = nonce;
} else {
throw new Error('Pong: No Nonce given');
}
}
toObject() {
return {
nonce : this.nonce
};
}
toBuffer() {
return this.nonce;
}
static fromBuffer(buffer) {
return new Pong(buffer);
}
static fromObject(payload) {
return new Pong(payload.nonce);
}
}