Java Code Examples for org.bitcoinj.core.Utils#uint32ToByteArrayBE()
The following examples show how to use
org.bitcoinj.core.Utils#uint32ToByteArrayBE() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProtobufConnection.java From bcm-android with GNU General Public License v3.0 | 5 votes |
/** * <p>Writes the given message to the other side of the connection, prefixing it with the proper 4-byte prefix.</p> * <p> * <p>Provides a write-order guarantee.</p> * * @throws IllegalStateException If the encoded message is larger than the maximum message size. */ public void write(MessageType msg) throws IllegalStateException { byte[] messageBytes = msg.toByteArray(); checkState(messageBytes.length <= maxMessageSize); byte[] messageLength = new byte[4]; Utils.uint32ToByteArrayBE(messageBytes.length, messageLength, 0); try { MessageWriteTarget target = writeTarget.get(); target.writeBytes(messageLength); target.writeBytes(messageBytes); } catch (IOException e) { closeConnection(); } }
Example 2
Source File: ProtobufConnection.java From green_android with GNU General Public License v3.0 | 5 votes |
/** * <p>Writes the given message to the other side of the connection, prefixing it with the proper 4-byte prefix.</p> * * <p>Provides a write-order guarantee.</p> * * @throws IllegalStateException If the encoded message is larger than the maximum message size. */ public void write(MessageType msg) throws IllegalStateException { byte[] messageBytes = msg.toByteArray(); checkState(messageBytes.length <= maxMessageSize); byte[] messageLength = new byte[4]; Utils.uint32ToByteArrayBE(messageBytes.length, messageLength, 0); try { MessageWriteTarget target = writeTarget.get(); target.writeBytes(messageLength); target.writeBytes(messageBytes); } catch (IOException e) { closeConnection(); } }
Example 3
Source File: ProtobufConnection.java From GreenBits with GNU General Public License v3.0 | 5 votes |
/** * <p>Writes the given message to the other side of the connection, prefixing it with the proper 4-byte prefix.</p> * * <p>Provides a write-order guarantee.</p> * * @throws IllegalStateException If the encoded message is larger than the maximum message size. */ public void write(MessageType msg) throws IllegalStateException { byte[] messageBytes = msg.toByteArray(); checkState(messageBytes.length <= maxMessageSize); byte[] messageLength = new byte[4]; Utils.uint32ToByteArrayBE(messageBytes.length, messageLength, 0); try { MessageWriteTarget target = writeTarget.get(); target.writeBytes(messageLength); target.writeBytes(messageBytes); } catch (IOException e) { closeConnection(); } }