Java 类org.bitcoinj.core.Peer 实例源码

项目:BitcoinBlockExplorer    文件:FragmentBlocks.java   
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
    //Log.d("BlocksDownloaded",block.getHashAsString());
    Integer height=blockChain.getChainHead().getHeight();

    synchronized (blocks) {
        blocks.put(block, height);
        if (blocks.keySet().size() >= 30) {
            blocks.remove(blocks.keySet().toArray()[blocks.keySet().size() - 1]);
        }
    }

    if(System.currentTimeMillis()-lastTimestamp>1000) {
        refreshUI();
        lastTimestamp = System.currentTimeMillis();
    }
}
项目:xwallet    文件:DownloadProgressListener.java   
public void onChainDownloadStarted(Peer peer, int blocksLeft) {
    if(blocksLeft > 0 && this.originalBlocksLeft == -1) {
        this.startDownload(blocksLeft);
    }

    if(this.originalBlocksLeft == -1) {
        this.originalBlocksLeft = blocksLeft;
    } else {
        log.info("Chain download switched to {}", peer);
    }

    if(blocksLeft == 0) {
        this.doneDownload();
        this.future.set(Long.valueOf(peer.getBestHeight()));
    }

}
项目:xwallet    文件:DownloadProgressListener.java   
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
    if(!this.caughtUp) {
        if(blocksLeft == 0) {
            this.caughtUp = true;
            this.doneDownload();
            this.future.set(Long.valueOf(peer.getBestHeight()));
        }

        if(blocksLeft >= 0 && this.originalBlocksLeft > 0) {
            double pct = 100.0D - 100.0D * ((double)blocksLeft / (double)this.originalBlocksLeft);
            if((int)pct != this.lastPercent) {

                this.lastBlockDate = new Date(block.getTimeSeconds() * 1000L);
                this.progress(pct, blocksLeft, this.lastBlockDate);
                this.lastPercent = (int)pct;
            }

        }
    }
}
项目:bitnym    文件:MixPartnerDiscovery.java   
@Override
public void onBlocksDownloaded(Peer arg0, Block arg1,
        @Nullable FilteredBlock arg2, int arg3) {
    System.out.println("received block");
    boolean receivedBcastAnnouncmnt = false;
    Map<Sha256Hash, Transaction> assocTxs = arg2.getAssociatedTransactions();
    for(Transaction tx : assocTxs.values()) {
        System.out.println("from within mixpartner discovery " + tx);           
        if(tx.getOutputs().size() > 1 &&
                BroadcastAnnouncement.isBroadcastAnnouncementScript(tx.getOutput(1).getScriptBytes()))
                //&& !wallet.isTransactionRelevant(tx)) {
            //tx.getInput(0).getScriptSig().getChunks().get(0)
                {
            if(!this.broadcasts.contains(tx) && wallet.getTransaction(tx.getHash()) == null) {
                this.broadcasts.add(tx);
                receivedBcastAnnouncmnt = true;
            }
        }
    }

    if(receivedBcastAnnouncmnt) {
        for(BroadcastAnnouncementChangeEventListener l : listeners) {
            l.onBroadcastAnnouncementChanged();
        }
    }
}
项目:okwallet    文件:DownloadProgressTracker.java   
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
    if (caughtUp)
        return;

    if (blocksLeft == 0) {
        caughtUp = true;
        doneDownload();
        future.set(peer.getBestHeight());
    }

    if (blocksLeft < 0 || originalBlocksLeft <= 0)
        return;

    double pct = 100.0 - (100.0 * (blocksLeft / (double) originalBlocksLeft));
    if ((int) pct != lastPercent) {
        progress(pct, blocksLeft, new Date(block.getTimeSeconds() * 1000));
        lastPercent = (int) pct;
    }
}
项目:okwallet    文件:PeerListFragment.java   
@Override
public void onBindViewHolder(final PeerViewHolder holder, final int position) {
    final Peer peer = getItem(position);
    final VersionMessage versionMessage = peer.getPeerVersionMessage();
    final boolean isDownloading = peer.isDownloadData();

    final InetAddress address = peer.getAddress().getAddr();
    final String hostname = hostnames.get(address);
    holder.ipView.setText(hostname != null ? hostname : address.getHostAddress());

    final long bestHeight = peer.getBestHeight();
    holder.heightView.setText(bestHeight > 0 ? bestHeight + " blocks" : null);
    holder.heightView.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

    holder.versionView.setText(versionMessage.subVer);
    holder.versionView.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

    holder.protocolView.setText("protocol: " + versionMessage.clientVersion);
    holder.protocolView.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

    final long pingTime = peer.getPingTime();
    holder.pingView
            .setText(pingTime < Long.MAX_VALUE ? getString(R.string.peer_list_row_ping_time, pingTime) : null);
    holder.pingView.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
}
项目:cryptwallet    文件:DownloadProgressTracker.java   
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
    if (caughtUp)
        return;

    if (blocksLeft == 0) {
        caughtUp = true;
        doneDownload();
        future.set(peer.getBestHeight());
    }

    if (blocksLeft < 0 || originalBlocksLeft <= 0)
        return;

    double pct = 100.0 - (100.0 * (blocksLeft / (double) originalBlocksLeft));
    if ((int) pct != lastPercent) {
        progress(pct, blocksLeft, new Date(block.getTimeSeconds() * 1000));
        lastPercent = (int) pct;
    }
}
项目:ombuds-android    文件:PeerListFragment.java   
@Override
public void onBindViewHolder(final PeerViewHolder holder, final int position)
{
    final Peer peer = getItem(position);
    final VersionMessage versionMessage = peer.getPeerVersionMessage();
    final boolean isDownloading = peer.getDownloadData();

    final InetAddress address = peer.getAddress().getAddr();
    final String hostname = hostnames.get(address);
    holder.ipView.setText(hostname != null ? hostname : address.getHostAddress());

    final long bestHeight = peer.getBestHeight();
    holder.heightView.setText(bestHeight > 0 ? bestHeight + " blocks" : null);
    holder.heightView.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

    holder.versionView.setText(versionMessage.subVer);
    holder.versionView.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

    holder.protocolView.setText("protocol: " + versionMessage.clientVersion);
    holder.protocolView.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

    final long pingTime = peer.getPingTime();
    holder.pingView.setText(pingTime < Long.MAX_VALUE ? getString(R.string.peer_list_row_ping_time, pingTime) : null);
    holder.pingView.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
}
项目:dashj    文件:WatchMempool.java   
public static void main(String[] args) throws InterruptedException {
    BriefLogFormatter.init();
    PeerGroup peerGroup = new PeerGroup(PARAMS);
    peerGroup.setMaxConnections(32);
    peerGroup.addPeerDiscovery(new DnsDiscovery(PARAMS));
    peerGroup.addOnTransactionBroadcastListener(new OnTransactionBroadcastListener() {
        @Override
        public void onTransaction(Peer peer, Transaction tx) {
            Result result = DefaultRiskAnalysis.FACTORY.create(null, tx, NO_DEPS).analyze();
            incrementCounter(TOTAL_KEY);
            log.info("tx {} result {}", tx.getHash(), result);
            incrementCounter(result.name());
            if (result == Result.NON_STANDARD)
                incrementCounter(Result.NON_STANDARD + "-" + DefaultRiskAnalysis.isStandard(tx));
        }
    });
    peerGroup.start();

    while (true) {
        Thread.sleep(STATISTICS_FREQUENCY_MS);
        printCounters();
    }
}
项目:dashj    文件:DownloadProgressTracker.java   
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
    if (caughtUp)
        return;

    if (blocksLeft == 0) {
        caughtUp = true;
        doneDownload();
        future.set(peer.getBestHeight());
    }

    if (blocksLeft < 0 || originalBlocksLeft <= 0)
        return;

    double pct = 100.0 - (100.0 * (blocksLeft / (double) originalBlocksLeft));
    if ((int) pct != lastPercent) {
        progress(pct, blocksLeft, new Date(block.getTimeSeconds() * 1000));
        lastPercent = (int) pct;
    }
}
项目:bitcoinj    文件:WatchMempool.java   
public static void main(String[] args) throws InterruptedException {
    BriefLogFormatter.init();
    PeerGroup peerGroup = new PeerGroup(PARAMS);
    peerGroup.setMaxConnections(32);
    peerGroup.addPeerDiscovery(new DnsDiscovery(PARAMS));
    peerGroup.addOnTransactionBroadcastListener(new OnTransactionBroadcastListener() {
        @Override
        public void onTransaction(Peer peer, Transaction tx) {
            Result result = DefaultRiskAnalysis.FACTORY.create(null, tx, NO_DEPS).analyze();
            incrementCounter(TOTAL_KEY);
            log.info("tx {} result {}", tx.getHash(), result);
            incrementCounter(result.name());
            if (result == Result.NON_STANDARD)
                incrementCounter(Result.NON_STANDARD + "-" + DefaultRiskAnalysis.isStandard(tx));
        }
    });
    peerGroup.start();

    while (true) {
        Thread.sleep(STATISTICS_FREQUENCY_MS);
        printCounters();
    }
}
项目:bitcoinj    文件:DownloadProgressTracker.java   
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
    if (caughtUp)
        return;

    if (blocksLeft == 0) {
        caughtUp = true;
        doneDownload();
        future.set(peer.getBestHeight());
    }

    if (blocksLeft < 0 || originalBlocksLeft <= 0)
        return;

    double pct = 100.0 - (100.0 * (blocksLeft / (double) originalBlocksLeft));
    if ((int) pct != lastPercent) {
        progress(pct, blocksLeft, new Date(block.getTimeSeconds() * 1000));
        lastPercent = (int) pct;
    }
}
项目:BitcoinBlockExplorer    文件:FragmentPeers.java   
@Override
public void onPeerConnected(final Peer peer, int peerCount) {

    if(System.currentTimeMillis()-lastTimestamp>1000) {
        refreshUI();
        lastTimestamp = System.currentTimeMillis();
    }
    lookupReverseDNS(peer);
}
项目:BitcoinBlockExplorer    文件:FragmentPeers.java   
@Override
public void onPeerDisconnected(final Peer peer, int peerCount) {

    if(System.currentTimeMillis()-lastTimestamp>1000) {
        refreshUI();
        lastTimestamp = System.currentTimeMillis();
    }

    synchronized (reverseDnsLookups) {
        reverseDnsLookups.remove(peer);
    }
}
项目:BitcoinBlockExplorer    文件:FragmentPeers.java   
public void attach(){
    reverseDnsLookups.clear();
    if(peerGroup!=null) {
        peerGroup.addConnectedEventListener(peerConnectedEventListener);
        peerGroup.addDisconnectedEventListener(peerDisconnectedEventListener);
        for (Peer peer : peerGroup.getConnectedPeers()) {
            lookupReverseDNS(peer);
        }
    }
}
项目:BitcoinBlockExplorer    文件:FragmentPeers.java   
private void lookupReverseDNS(final Peer peer) {
    new Thread(new Runnable() {
        @Override
        public void run() {
            String reverseDns = peer.getAddress().getAddr().getCanonicalHostName();
            synchronized (reverseDnsLookups) {
                reverseDnsLookups.put(peer, reverseDns);
            }
            refreshUI();
        }
    }).start();
}
项目:BitcoinBlockExplorer    文件:PeersAdapter.java   
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    // - get element from your dataset at this position
    // - replace the contents of the view with that element
    synchronized (mDataset) {
        final Peer peer = (Peer) (mDataset.keySet().toArray()[position]);
        String name = (String) (mDataset.values().toArray())[position];

        holder.mTvTitle.setText(name.toString());
        holder.mTvIp.setText(String.valueOf(peer.getAddress().getPort()));
        //holder.mTvBestHeight.setText("BestHeight: " + String.valueOf(peer.getBestHeight()));
        //holder.mTvLastPingTime.setText("LastPingTime: " + String.valueOf(peer.getLastPingTime()));
        holder.key = peer.getAddress().toString();
    }
}
项目:BitcoinBlockExplorer    文件:Bitcoin.java   
@Override
public void onChainDownloadStarted(Peer peer, int blocksLeft) {
    super.onChainDownloadStarted(peer, blocksLeft);
    Log.i("onChainDownloadStarted", peer.getAddr().toString());
    for (MyListener listener : mListeners){
        listener.stopCallback();
        listener.startCallback();
    }
}
项目:BitcoinBlockExplorer    文件:Bitcoin.java   
@Nullable
@Override
public List<Message> getData(Peer peer, GetDataMessage m) {
    //Log.i("getData", m.toString());
    //Log.i("onChainDownloadStarted", peer.toString());
    return null;
}
项目:xwallet    文件:BitcoinRecoverAction.java   
/**
 *
 * @param peer
 * @param block
 * @param filteredBlock
 * @param blocksLeft
 */
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
    super.onBlocksDownloaded(peer, block, filteredBlock, blocksLeft);

    // to avoid overhead on notification, only 100th blocks or the last ones
    if (blocksLeft % 100 == 0 || blocksLeft < 10) {
        for (CoinActionCallback<CurrencyCoin> callback : _callbacks) {
            callback.onBlocksDownloaded(_bitcoinManager.getCurrencyCoin(), this.lastPercent, blocksLeft, this.lastBlockDate);
        }
    }
}
项目:xwallet    文件:BitcoinSetupAction.java   
/**
 *
 * @param peer
 * @param block
 * @param filteredBlock
 * @param blocksLeft
 */
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
    super.onBlocksDownloaded(peer, block, filteredBlock, blocksLeft);

    // to avoid overhead on notification, only 100th blocks or the last ones
    if (blocksLeft % 100 == 0 || blocksLeft < 10) {
        for (CoinActionCallback<CurrencyCoin> callback : _callbacks) {
            callback.onBlocksDownloaded(_bitcoin, this.lastPercent, blocksLeft, this.lastBlockDate);
        }
    }
}
项目:okwallet    文件:DownloadProgressTracker.java   
@Override
public void onChainDownloadStarted(Peer peer, int blocksLeft) {
    if (blocksLeft > 0 && originalBlocksLeft == -1)
        startDownload(blocksLeft);
    // Only mark this the first time, because this method can be called more than once during a chain download
    // if we switch peers during it.
    if (originalBlocksLeft == -1)
        originalBlocksLeft = blocksLeft;
    else
        log.info("Chain download switched to {}", peer);
    if (blocksLeft == 0) {
        doneDownload();
        future.set(peer.getBestHeight());
    }
}
项目:okwallet    文件:BlockchainServiceImpl.java   
@Override
public void onBlocksDownloaded(final Peer peer, final Block block, final FilteredBlock filteredBlock,
        final int blocksLeft) {
    delayHandler.removeCallbacksAndMessages(null);

    final long now = System.currentTimeMillis();
    if (now - lastMessageTime.get() > BLOCKCHAIN_STATE_BROADCAST_THROTTLE_MS)
        delayHandler.post(runnable);
    else
        delayHandler.postDelayed(runnable, BLOCKCHAIN_STATE_BROADCAST_THROTTLE_MS);
}
项目:okwallet    文件:BlockchainServiceImpl.java   
@Override
public List<Peer> getConnectedPeers() {
    if (peerGroup != null)
        return peerGroup.getConnectedPeers();
    else
        return null;
}
项目:okwallet    文件:PeerListFragment.java   
@Override
public void onResume() {
    super.onResume();

    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            adapter.notifyDataSetChanged();

            final Loader<String> loader = loaderManager.getLoader(ID_REVERSE_DNS_LOADER);
            final boolean loaderRunning = loader != null && loader.isStarted();

            if (!loaderRunning) {
                for (int i = 0; i < adapter.getItemCount(); i++) {
                    final Peer peer = adapter.getItem(i);
                    final InetAddress address = peer.getAddress().getAddr();

                    if (!hostnames.containsKey(address)) {
                        final Bundle args = new Bundle();
                        args.putSerializable("address", address);
                        loaderManager.initLoader(ID_REVERSE_DNS_LOADER, args, reverseDnsLoaderCallbacks)
                                .forceLoad();

                        break;
                    }
                }
            }

            handler.postDelayed(this, REFRESH_MS);
        }
    }, REFRESH_MS);
}
项目:okwallet    文件:PeerListFragment.java   
@Override
public void onLoadFinished(final Loader<List<Peer>> loader, final List<Peer> peers) {
    if (peers == null || peers.isEmpty()) {
        viewGroup.setDisplayedChild(1);
        adapter.clear();
    } else {
        viewGroup.setDisplayedChild(2);
        adapter.replace(peers);
    }
}
项目:cryptwallet    文件:DownloadProgressTracker.java   
@Override
public void onChainDownloadStarted(Peer peer, int blocksLeft) {
    if (blocksLeft > 0 && originalBlocksLeft == -1)
        startDownload(blocksLeft);
    // Only mark this the first time, because this method can be called more than once during a chain download
    // if we switch peers during it.
    if (originalBlocksLeft == -1)
        originalBlocksLeft = blocksLeft;
    else
        log.info("Chain download switched to {}", peer);
    if (blocksLeft == 0) {
        doneDownload();
        future.set(peer.getBestHeight());
    }
}
项目:javatool    文件:PPkPeerEventListener.java   
@Override
public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock filteredBlock, int blocksLeft){
  logger.info("Block downloaded: "+blocksLeft);
  /*
  //this doesn't work
  Blocks blocks = Blocks.getInstance();
  try {
    blocks.importBlock(block, blocks.blockStore.get(block.getHash()).getHeight());
  } catch (BlockStoreException e) {
  }
  */
}
项目:ombuds-android    文件:BlockchainServiceImpl.java   
@Override
public void onBlocksDownloaded(final Peer peer, final Block block, final FilteredBlock filteredBlock, final int blocksLeft)
{
    delayHandler.removeCallbacksAndMessages(null);

    final long now = System.currentTimeMillis();

    if (now - lastMessageTime.get() > BLOCKCHAIN_STATE_BROADCAST_THROTTLE_MS)
        delayHandler.post(runnable);
    else
        delayHandler.postDelayed(runnable, BLOCKCHAIN_STATE_BROADCAST_THROTTLE_MS);
}
项目:ombuds-android    文件:BlockchainServiceImpl.java   
@Override
public List<Peer> getConnectedPeers()
{
    if (peerGroup != null)
        return peerGroup.getConnectedPeers();
    else
        return null;
}
项目:ombuds-android    文件:PeerListFragment.java   
@Override
public void onResume()
{
    super.onResume();

    handler.postDelayed(new Runnable()
    {
        @Override
        public void run()
        {
            adapter.notifyDataSetChanged();

            final Loader<String> loader = loaderManager.getLoader(ID_REVERSE_DNS_LOADER);
            final boolean loaderRunning = loader != null && loader.isStarted();

            if (!loaderRunning)
            {
                for (int i = 0; i < adapter.getItemCount(); i++)
                {
                    final Peer peer = adapter.getItem(i);
                    final InetAddress address = peer.getAddress().getAddr();

                    if (!hostnames.containsKey(address))
                    {
                        final Bundle args = new Bundle();
                        args.putSerializable("address", address);
                        loaderManager.initLoader(ID_REVERSE_DNS_LOADER, args, reverseDnsLoaderCallbacks).forceLoad();

                        break;
                    }
                }
            }

            handler.postDelayed(this, REFRESH_MS);
        }
    }, REFRESH_MS);
}
项目:ombuds-android    文件:PeerListFragment.java   
public void replace(final List<Peer> peers)
{
    this.peers.clear();
    this.peers.addAll(peers);

    notifyDataSetChanged();
}
项目:ombuds-android    文件:PeerListFragment.java   
@Override
public void onLoadFinished(final Loader<List<Peer>> loader, final List<Peer> peers)
{
    if (peers == null || peers.isEmpty())
    {
        viewGroup.setDisplayedChild(1);
        adapter.clear();
    }
    else
    {
        viewGroup.setDisplayedChild(2);
        adapter.replace(peers);
    }
}
项目:namecoinj    文件:PeerMonitor.java   
private void lookupReverseDNS(final Peer peer) {
    new Thread() {
        @Override
        public void run() {
            // This can take a looooong time.
            String reverseDns = peer.getAddress().getAddr().getCanonicalHostName();
            synchronized (reverseDnsLookups) {
                reverseDnsLookups.put(peer, reverseDns);
            }
            refreshUI();
        }
    }.start();
}
项目:namecoinj    文件:PeerMonitor.java   
private Object getAddressForPeer(Peer peer) {
    String s;
    synchronized (reverseDnsLookups) {
        s = reverseDnsLookups.get(peer);
    }
    if (s != null)
        return s;
    else
        return peer.getAddress().getAddr().getHostAddress();
}
项目:consensusj    文件:PeerSerializer.java   
@Override
public void serialize(Peer value, JsonGenerator jgen, SerializerProvider provider)
        throws IOException, JsonProcessingException {
    jgen.writeStartObject();
    jgen.writeStringField("socketAddress", value.getAddress().toSocketAddress().toString());
    jgen.writeNumberField("remoteVersion", value.getPeerVersionMessage().clientVersion);
    jgen.writeNumberField("bestHeight", value.getPeerVersionMessage().bestHeight);
    jgen.writeEndObject();
}
项目:consensusj    文件:RpcServerModule.java   
public RpcServerModule() {
    super("BitcoinJMappingServer", new Version(1, 0, 0, null, null, null));

    this.addDeserializer(Address.class, new AddressDeserializer(null))  // Null means use default list of netParams
            .addDeserializer(Coin.class, new CoinDeserializer())
            .addDeserializer(ECKey.class, new ECKeyDeserializer())
            .addDeserializer(Sha256Hash.class, new Sha256HashDeserializer())
            .addSerializer(Address.class, new AddressSerializer())
            .addSerializer(Coin.class, new CoinSerializer())
            .addSerializer(ECKey.class, new ECKeySerializer())
            .addSerializer(Peer.class, new PeerSerializer())
            .addSerializer(Sha256Hash.class, new Sha256HashSerializer())
            .addSerializer(Transaction.class, new TransactionSerializer());
}
项目:EternityWallAndroid    文件:MyDownloadListener.java   
@Override
public void onChainDownloadStarted(Peer peer, int blocksLeft) {
    super.onChainDownloadStarted(peer, blocksLeft);
    start= System.currentTimeMillis();

    Log.i(TAG, "onChainDownloadStarted blocksLeft=" + blocksLeft);

    if (originalBlocksLeft == -1)
        originalBlocksLeft = blocksLeft;
    /*if(blocksLeft==0)
        doneDownload();*/
}
项目:EternityWallAndroid    文件:MyDownloadListener.java   
@Override
public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock filteredBlock, int blocksLeft) {
    super.onBlocksDownloaded(peer, block, filteredBlock, blocksLeft);
    //Log.i(TAG, "onBlocksDownloaded");

    size+=block.getMessageSize();

    double pct = 100.0 - (100.0 * (blocksLeft / (double) originalBlocksLeft));
    if ((int) pct != lastPercent) {
        lastPercent = (int) pct;
        walletObservable.setPercSync(lastPercent);
        walletObservable.notifyObservers();
    }
}
项目:ostendo    文件:OPReturnListener.java   
@Override
public void onTransaction(Peer peer, Transaction transaction) {
    transaction.getOutputs().stream()
            .filter(transactionOutput -> transactionOutput.toString().contains(OP_RETURN_CODE))
            .forEach(transactionOutput -> {
                messageQueue.add(extractMessage(transactionOutput.toString()));
                log.info("Found a message in Transaction: " + transaction.toString());
            });
}