/** * Return the default serializer for this network. This is a shared serializer. * @return the default serializer for this network. */ public final MessageSerializer getDefaultSerializer() { // Construct a default serializer if we don't have one if (null == this.defaultSerializer) { // Don't grab a lock unless we absolutely need it synchronized(this) { // Now we have a lock, double check there's still no serializer // and create one if so. if (null == this.defaultSerializer) { // As the serializers are intended to be immutable, creating // two due to a race condition should not be a problem, however // to be safe we ensure only one exists for each network. this.defaultSerializer = getSerializer(false); } } } return defaultSerializer; }
/** * Return the default serializer for this network. This is a shared serializer. * @return */ public final MessageSerializer getDefaultSerializer() { // Construct a default serializer if we don't have one if (null == this.defaultSerializer) { // Don't grab a lock unless we absolutely need it synchronized(this) { // Now we have a lock, double check there's still no serializer // and create one if so. if (null == this.defaultSerializer) { // As the serializers are intended to be immutable, creating // two due to a race condition should not be a problem, however // to be safe we ensure only one exists for each network. this.defaultSerializer = getSerializer(false); } } } return defaultSerializer; }
/** * Return the default serializer for this network. This is a shared serializer. * @return */ public final MessageSerializer getDefaultSerializer() { // Construct a default serializer if we don't have one if (null == this.defaultSerializer) { // Don't grab a lock unless we absolutely need it synchronized(this) { // Now we have a lock, double check there's still no serializer // and create one if so. if (null == this.defaultSerializer) { // As the serializers are intended to be immutable, creating // two due to a race condition should not be a problem, however // to be safe we ensure only one exists for each network. this.defaultSerializer = getSerializer(false); } } } return defaultSerializer; }
/** * Return the default serializer for this network. This is a shared serializer. * @return */ public final MessageSerializer getDefaultSerializer() { // Construct a default serializer if we don't have one if (null == this.defaultSerializer) { // Don't grab a lock unless we absolutely need it synchronized(this) { // Now we have a lock, double check there's still no serializer // and create one if so. if (null == this.defaultSerializer) { // As the serializers are intended to be immutable, creating // two due to a race condition should not be a problem, however // to be safe we ensure only one exists for each network. this.defaultSerializer = getSerializer(false); } } } return defaultSerializer; }
@Override protected void parse() throws ProtocolException { long numHeaders = readVarInt(); if (numHeaders > MAX_HEADERS) throw new ProtocolException("Too many headers: got " + numHeaders + " which is larger than " + MAX_HEADERS); blockHeaders = new ArrayList<>(); final BitcoinSerializer serializer = this.params.getSerializer(true); for (int i = 0; i < numHeaders; ++i) { final Block newBlockHeader = serializer.makeBlock(payload, cursor, UNKNOWN_LENGTH); if (newBlockHeader.hasTransactions()) { throw new ProtocolException("Block header does not end with a null byte"); } cursor += newBlockHeader.optimalEncodingMessageSize; blockHeaders.add(newBlockHeader); } if (length == UNKNOWN_LENGTH) { length = cursor - offset; } if (log.isDebugEnabled()) { for (int i = 0; i < numHeaders; ++i) { log.debug(this.blockHeaders.get(i).toString()); } } }
@Override protected void parse() throws ProtocolException { long numHeaders = readVarInt(); if (numHeaders > MAX_HEADERS) throw new ProtocolException("Too many headers: got " + numHeaders + " which is larger than " + MAX_HEADERS); blockHeaders = new ArrayList<Block>(); final BitcoinSerializer serializer = this.params.getSerializer(true); for (int i = 0; i < numHeaders; ++i) { final Block newBlockHeader = serializer.makeBlock(payload, cursor, UNKNOWN_LENGTH); if (newBlockHeader.hasTransactions()) { throw new ProtocolException("Block header does not end with a null byte"); } cursor += newBlockHeader.optimalEncodingMessageSize; blockHeaders.add(newBlockHeader); } if (length == UNKNOWN_LENGTH) { length = cursor - offset; } if (log.isDebugEnabled()) { for (int i = 0; i < numHeaders; ++i) { log.debug(this.blockHeaders.get(i).toString()); } } }
@Override protected void parse() throws ProtocolException { long numHeaders = readVarInt(); if (numHeaders > MAX_HEADERS) throw new ProtocolException("Too many headers: got " + numHeaders + " which is larger than " + MAX_HEADERS); blockHeaders = new ArrayList<>(); final BitcoinSerializer serializer = this.params.getSerializer(true); for (int i = 0; i < numHeaders; ++i) { final Block newBlockHeader = serializer.makeBlock(payload, cursor, UNKNOWN_LENGTH); if (newBlockHeader.hasTransactions()) { throw new ProtocolException("Block header does not end with a null byte"); } cursor += newBlockHeader.optimalEncodingMessageSize; blockHeaders.add(newBlockHeader); } if (length == UNKNOWN_LENGTH) { length = cursor - offset; } if (log.isDebugEnabled()) { for (int i = 0; i < numHeaders; ++i) { log.debug(this.blockHeaders.get(i).toString()); } } }
@Override protected void parse() throws ProtocolException { long numHeaders = readVarInt(); if (numHeaders > MAX_HEADERS) throw new ProtocolException("Too many headers: got " + numHeaders + " which is larger than " + MAX_HEADERS); blockHeaders = new ArrayList<Block>(); final BitcoinSerializer serializer = this.params.getSerializer(true); for (int i = 0; i < numHeaders; ++i) { final Block newBlockHeader = serializer.makeBlock(payload, cursor, UNKNOWN_LENGTH); if (newBlockHeader.hasTransactions()) { throw new ProtocolException("Block header does not end with a null byte"); } cursor += newBlockHeader.optimalEncodingMessageSize; blockHeaders.add(newBlockHeader); } if (length == UNKNOWN_LENGTH) { length = cursor - offset; } if (log.isDebugEnabled()) { for (int i = 0; i < numHeaders; ++i) { log.debug(this.blockHeaders.get(i).toString()); } } }
MessageSerializer bsRef = params.getSerializer(false); ByteArrayOutputStream bos = new ByteArrayOutputStream(); BitcoinSerializer bs = params.getSerializer(retain); Transaction t1; Transaction tRef;
public void testBlock(byte[] blockBytes, boolean isChild, boolean retain) throws Exception { MessageSerializer bsRef = PARAMS.getSerializer(false); ByteArrayOutputStream bos = new ByteArrayOutputStream(); BitcoinSerializer bs = PARAMS.getSerializer(retain); Block b1; Block bRef;
b64 = params.getSerializer(true).makeBlock(stream.toByteArray(), stream.size());