Ejemplo n.º 1
0
 @Override
 public FieldDefinition getField(final String fieldName) {
   if (fields.containsKey(fieldName)) {
     return fields.get(fieldName);
   } else if (priorityField != null && priorityField.getName().equals(fieldName)) {
     return priorityField;
   } else {
     return null;
   }
 }
Ejemplo n.º 2
0
 private static void informListenerForNewTransactions(
     Block block,
     NewBlockType newBlockType,
     @Nullable List<Sha256Hash> filteredTxHashList,
     @Nullable Map<Sha256Hash, Transaction> filteredTxn,
     StoredBlock newStoredBlock,
     boolean first,
     BlockChainListener listener,
     Set<Sha256Hash> falsePositives)
     throws VerificationException {
   if (block.transactions != null) {
     // If this is not the first wallet, ask for the transactions to be duplicated before being
     // given
     // to the wallet when relevant. This ensures that if we have two connected wallets and a tx
     // that
     // is relevant to both of them, they don't end up accidentally sharing the same object (which
     // can
     // result in temporary in-memory corruption during re-orgs). See bug 257. We only duplicate in
     // the case of multiple wallets to avoid an unnecessary efficiency hit in the common case.
     sendTransactionsToListener(
         newStoredBlock, newBlockType, listener, 0, block.transactions, !first, falsePositives);
   } else if (filteredTxHashList != null) {
     checkNotNull(filteredTxn);
     // We must send transactions to listeners in the order they appeared in the block - thus we
     // iterate over the
     // set of hashes and call sendTransactionsToListener with individual txn when they have not
     // already been
     // seen in loose broadcasts - otherwise notifyTransactionIsInBlock on the hash.
     int relativityOffset = 0;
     for (Sha256Hash hash : filteredTxHashList) {
       Transaction tx = filteredTxn.get(hash);
       if (tx != null) {
         sendTransactionsToListener(
             newStoredBlock,
             newBlockType,
             listener,
             relativityOffset,
             Collections.singletonList(tx),
             !first,
             falsePositives);
       } else {
         if (listener.notifyTransactionIsInBlock(
             hash, newStoredBlock, newBlockType, relativityOffset)) {
           falsePositives.remove(hash);
         }
       }
       relativityOffset++;
     }
   }
 }
Ejemplo n.º 3
0
 @Override
 public EntityHookDefinition getHook(
     final String type, final String className, final String methodName) {
   EntityHookDefinition hook =
       hooksByMethodPath.get(
           type.toUpperCase(Locale.ENGLISH) + "." + className + "." + methodName);
   checkNotNull(
       hook,
       "Cannot find hook "
           + type.toUpperCase(Locale.ENGLISH)
           + "."
           + className
           + "."
           + methodName
           + " for dataDefinition "
           + this);
   return hook;
 }
Ejemplo n.º 4
0
 public synchronized Chatroom getChatroomByName(String chatroom) throws ChatroomNotFoundExeption {
   checkNotNull(chatroom);
   if (chatroom.equals(defaultChatName)) return defaultChat;
   if (!chatrooms.containsKey(chatroom)) throw new ChatroomNotFoundExeption(chatroom);
   return chatrooms.get(chatroom);
 }
Ejemplo n.º 5
0
 public synchronized ClientThread getChatClientByUsername(String username)
     throws UsernameNotFoundException {
   checkNotNull(username);
   if (!containsUser(username)) throw new UsernameNotFoundException(username);
   return takenUsernames.get(username);
 }