public TransactionConfidence seen(Sha256Hash hash, PeerAddress byPeer) {
        TransactionConfidence confidence;
        boolean fresh = false;
        lock.lock();
        try {
            cleanTable();
            confidence = getOrCreate(hash);
            fresh = confidence.markBroadcastBy(byPeer);
        } finally {
            lock.unlock();
        }
        if (fresh)
            confidence.queueListeners(TransactionConfidence.Listener.ChangeReason.SEEN_PEERS);
        return confidence;
    }
@Test
    public void testSeen() {
        PeerAddress peer = createMock(PeerAddress.class);

        Sha256Hash brokenHash = createMock(Sha256Hash.class);
        Sha256Hash correctHash = createMock(Sha256Hash.class);

        TransactionConfidence brokenConfidence = createMock(TransactionConfidence.class);
        expect(brokenConfidence.getTransactionHash()).andReturn(brokenHash);
        expect(brokenConfidence.markBroadcastBy(peer)).andThrow(new ArithmeticException("some error"));

        TransactionConfidence correctConfidence = createMock(TransactionConfidence.class);
        expect(correctConfidence.getTransactionHash()).andReturn(correctHash);
        expect(correctConfidence.markBroadcastBy(peer)).andReturn(true);
        correctConfidence.queueListeners(anyObject(TransactionConfidence.Listener.ChangeReason.class));
        expectLastCall();

        TransactionConfidence.Factory factory = createMock(TransactionConfidence.Factory.class);
        expect(factory.createConfidence(brokenHash)).andReturn(brokenConfidence);
        expect(factory.createConfidence(correctHash)).andReturn(correctConfidence);

        replay(factory, brokenConfidence, correctConfidence);

        TxConfidenceTable table = new TxConfidenceTable(1, factory);

        try {
            table.seen(brokenHash, peer);
        } catch (ArithmeticException expected) {
            // do nothing
        }

        assertNotNull(table.seen(correctHash, peer));
    }