File tree 1 file changed +6
-1
lines changed 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,8 @@ type PostgresClient struct {
132
132
peerMappings map [peer.ID ]int
133
133
134
134
// ... TODO
135
- routingTables map [peer.ID ]struct {
135
+ routingTablesMu sync.Mutex
136
+ routingTables map [peer.ID ]struct {
136
137
neighbors []peer.ID
137
138
errorBits uint16
138
139
}
@@ -640,13 +641,15 @@ func (c *PostgresClient) InsertVisit(ctx context.Context, args *VisitArgs) error
640
641
wg .Wait ()
641
642
642
643
if c .cfg .PersistNeighbors && (len (args .Neighbors ) > 0 || args .ErrorBits != 0 ) {
644
+ c .routingTablesMu .Lock ()
643
645
c .routingTables [args .PeerID ] = struct {
644
646
neighbors []peer.ID
645
647
errorBits uint16
646
648
}{
647
649
neighbors : args .Neighbors ,
648
650
errorBits : args .ErrorBits ,
649
651
}
652
+ c .routingTablesMu .Unlock ()
650
653
}
651
654
652
655
var crawlID * int
@@ -933,6 +936,8 @@ func (c *PostgresClient) FetchUnresolvedMultiAddresses(ctx context.Context, limi
933
936
934
937
// Flush .
935
938
func (c * PostgresClient ) Flush (ctx context.Context ) error {
939
+ c .routingTablesMu .Lock ()
940
+ defer c .routingTablesMu .Unlock ()
936
941
if len (c .routingTables ) == 0 || ! c .cfg .PersistNeighbors {
937
942
return nil
938
943
}
You can’t perform that action at this time.
0 commit comments