Bitcoin Forum
May 08, 2021, 04:45:04 AM
 News: Latest Bitcoin Core release: 0.21.0 [Torrent]
 Home Help Search Login Register More
 Pages: [1]
 Author Topic: Some homemade analysis: Environmental flows of merit on BitcoinTalk  (Read 94 times)
Slava79
Member

Offline

Activity: 183
Merit: 13

¯\_(ツ)_/¯

 April 25, 2018, 03:56:03 PMMerited by Jet Cash (1)

Hello everybody

I'm learning a new programming language nowadays - Kotlin and could not miss the opportunity to practice it with the BitcoinTalk raw data for merit flow available by  https://bitcointalk.org/merit.txt.xz.

I've got an idea that probably merit is going in circles - one user merits another, then second user merits the third and then third returns merit to the first. For whatever reason.

With the available data it is quite easy to check. I'm not that good at algorithms, so just created a quick and dirty script.

The data result  is quite interesting.

There are circles and some of them of different size.

These which are user1 -> user2 - > user1 I call circle size 2, these of type  user1 -> user2 -> user3 - > user1 circle of size 3 etc

The example script output:

Quote
Circle found: [988147, 521226, 995414, 929472, 995414, 521226, 988147]
Circle found: [988147, 521226, 995414, 929472, 995414, 929472, 995414, 521226, 995414, 521226, 988147]
Circle found: [988147, 521226, 995414, 929472, 995414, 929472, 995414, 521226, 988147]
Circle found: [988147, 521226, 995414, 929472, 995414, 929472, 995414, 929472, 995414, 521226, 988147]
Circle found: [988147, 521226, 988147]
Circle found: [1343594, 1196051, 1343594]
Circle found: [1517809, 658788, 1517809]

The script itself (warning - ugly, inefficient and probably contains bugs):

Code:
import java.io.File

// max recursion level
val maxLevel = 10

// minimum circle size
val maxCircleSize = 5

// restrict check only to users who gave merit less than maxMeritedUsers times
val maxMeritedUsers = 5

val events = File("../merit.txt")
.drop(1)
.map { it.split("\t") }
.map { (_, _, _, userFrom, userTo) -> Pair(userFrom, userTo) }
.groupBy { it.first }
.map { (userFrom, events) -> Pair(userFrom, events.map { it.second }) }
.filter { it.second.size < maxMeritedUsers }
.associate { it.first to it.second }

fun checkCircle(userFrom: String, usersTo: List<String>, circle: List<String>, level: Int) {

if (level >= maxLevel) {
return
}

usersTo.forEach { userTo ->

if (userFrom == userTo) {
println("Circle found: \${circle + userTo}")
} else {
checkCircle(userFrom, events[userTo].orEmpty(), circle + userTo, level + 1)
}
}
}

println("Unique user sent merit: \${events.keys.size}")

events.keys.forEach { userFrom ->

val circle = listOf(userFrom)

checkCircle(userFrom, events[userFrom].orEmpty(), circle, 0)

}

In order to run it you need to install Kotlin compiler.

Please feel free to play with it, for whatever goal. I hope it is interesting )

Building a JavaScript Smart Contracts Engine
Github | Site | Chat
1620449104
Hero Member

Offline

Posts: 1620449104

Ignore
 1620449104

1620449104
 Report to moderator
1620449104
Hero Member

Offline

Posts: 1620449104

Ignore
 1620449104

1620449104
 Report to moderator
1620449104
Hero Member

Offline

Posts: 1620449104

Ignore
 1620449104

1620449104
 Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
Jet Cash
Legendary

Offline

Activity: 1974
Merit: 2090

https://fittotalk.com/english-talk/

 April 25, 2018, 04:08:15 PM

All these new programming languages ( can we still call them languages) are quite fascinating. I've been collecting the free ebooks from packt, and I keep meaning to try to use some of them.

[
Offgrid campers allow you to enjoy life and preserve your health and wealth.
Slava79
Member

Offline

Activity: 183
Merit: 13

¯\_(ツ)_/¯

 April 25, 2018, 04:16:31 PM

All these new programming languages ( can we still call them languages) are quite fascinating. I've been collecting the free ebooks from packt, and I keep meaning to try to use some of them.

I started a new project in Java recently, but Java really drives me mad, too verbose even with lambdas. And in Java10 they fucked up with 'var' and 'val'. So I switched to Kotlin as I can't avoid JVM anyway. Very happy with the language so far.

Building a JavaScript Smart Contracts Engine
Github | Site | Chat
 Pages: [1]