class PeerStore implements ReadWriterStore<PeerId, Peer> {

    public void overwrite(List<Peer> peerList) {
        lock.lock();
        try {
            // remove all
            for (int i = 1; i <= peerSize; i++) {
                byte[] indexKey = getIndexKey(i);
                byte[] key = db.get(indexKey);
                if (key != null) {
                    db.delete(key);
                }
            }
            peerSize = 0L;
            // put all
            peerList.forEach(peer -> put(peer.getPeerId(), peer));
        } finally {
            lock.unlock();
        }
    }

      PeerStore(DbSource<byte[], byte[]> dbSource);

}