Maintaining a list of transactions propagated from other peers

This commit is contained in:
Tomasz Drwięga
2016-12-10 14:56:41 +01:00
parent 6eb63a7316
commit e1ade5b375
12 changed files with 137 additions and 29 deletions

View File

@@ -48,7 +48,6 @@ class BaseTransaction extends Component {
<IdentityIcon
address={ transaction.from }
/>
0x{ transaction.nonce.toString(16) }
</div>
);
}
@@ -87,6 +86,17 @@ class BaseTransaction extends Component {
</span>
);
}
renderReceived (stats) {
const noOfPeers = Object.keys(stats.receivedFrom).length;
const noOfPropagations = Object.values(stats.receivedFrom).reduce((sum, val) => sum + val, 0);
return (
<span className={ styles.nowrap }>
{ noOfPropagations } ({ noOfPeers } peers)
</span>
);
}
}
export class Transaction extends BaseTransaction {
@@ -103,7 +113,8 @@ export class Transaction extends BaseTransaction {
isLocal: false,
stats: {
firstSeen: 0,
propagatedTo: {}
propagatedTo: {},
receivedFrom: {}
}
};
@@ -129,6 +140,9 @@ export class Transaction extends BaseTransaction {
<th>
# Propagated
</th>
<th>
# Received
</th>
<th />
</tr>
);
@@ -165,6 +179,9 @@ export class Transaction extends BaseTransaction {
<td>
{ this.renderPropagation(stats) }
</td>
<td>
{ this.renderReceived(stats) }
</td>
</tr>
);
}
@@ -193,7 +210,8 @@ export class LocalTransaction extends BaseTransaction {
static defaultProps = {
stats: {
propagatedTo: {}
propagatedTo: {},
receivedFrom: {}
}
};
@@ -317,6 +335,8 @@ export class LocalTransaction extends BaseTransaction {
{ this.renderStatus() }
<br />
{ status === 'pending' ? this.renderPropagation(stats) : null }
<br />
{ status === 'pending' ? this.renderReceived(stats) : null }
</td>
</tr>
);