mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-22 14:41:08 -04:00
support multithreading in api and protocols
close trade wallets while unused for scalability verify txs do not use unlock height increase trade init timeout to 60s
This commit is contained in:
parent
fdddc87477
commit
bb95b4b1d6
82 changed files with 2786 additions and 2338 deletions
|
@ -42,43 +42,61 @@ public abstract class PersistableList<T extends PersistablePayload> implements P
|
|||
}
|
||||
|
||||
public void setAll(Collection<T> collection) {
|
||||
this.list.clear();
|
||||
this.list.addAll(collection);
|
||||
synchronized (this.list) {
|
||||
this.list.clear();
|
||||
this.list.addAll(collection);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean add(T item) {
|
||||
if (!list.contains(item)) {
|
||||
list.add(item);
|
||||
return true;
|
||||
synchronized (list) {
|
||||
if (!list.contains(item)) {
|
||||
list.add(item);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean remove(T item) {
|
||||
return list.remove(item);
|
||||
synchronized (list) {
|
||||
return list.remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
public Stream<T> stream() {
|
||||
return list.stream();
|
||||
synchronized (list) {
|
||||
return list.stream();
|
||||
}
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return list.size();
|
||||
synchronized (list) {
|
||||
return list.size();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean contains(T item) {
|
||||
return list.contains(item);
|
||||
synchronized (list) {
|
||||
return list.contains(item);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return list.isEmpty();
|
||||
synchronized (list) {
|
||||
return list.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
public void forEach(Consumer<? super T> action) {
|
||||
list.forEach(action);
|
||||
synchronized (list) {
|
||||
list.forEach(action);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
list.clear();
|
||||
synchronized (list) {
|
||||
list.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,11 +66,14 @@ public abstract class Task<T extends Model> {
|
|||
}
|
||||
|
||||
protected void failed(Throwable t) {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
t.printStackTrace(pw);
|
||||
errorMessage = sw.toString();
|
||||
log.error(t.getMessage(), t);
|
||||
// // append stacktrace to error message (only for development)
|
||||
// StringWriter sw = new StringWriter();
|
||||
// PrintWriter pw = new PrintWriter(sw);
|
||||
// t.printStackTrace(pw);
|
||||
// errorMessage = sw.toString();
|
||||
|
||||
errorMessage = t.getMessage() + " (task " + getClass().getSimpleName() + ")";
|
||||
log.error(errorMessage, t);
|
||||
taskHandler.handleErrorMessage(errorMessage);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue